tds-fdw / tds_fdw

A PostgreSQL foreign data wrapper to connect to TDS databases (Sybase and Microsoft SQL Server)
Other
377 stars 101 forks source link

Quoted string value in query #179

Open ciplax opened 6 years ago

ciplax commented 6 years ago

Apparently you can't using single quote (') in when creating foreign table with query mode example (this doesn't work):

CREATE FOREIGN TABLE v_test_2( inctypeid varchar(20) )
    SERVER mssql_svr
    OPTIONS (query 'select inctypeid from dbo.incentivetype where inctypeid = 'AR'', row_estimate_method 'execute');

Although there's an alternative of using double quote (") but the database need to have set quoted_identifier parameter off (or define it at the start of the query). example (this works):

CREATE FOREIGN TABLE v_test_2( inctypeid varchar(20) )
    SERVER mssql_svr
    OPTIONS (query '
    set QUOTED_IDENTIFIER OFF select inctypeid from dbo.incentivetype where inctypeid = "AR"', row_estimate_method 'execute');

Well, it's not like there's an immediate problem with this, but it'd be nice if you can just put single quote in the query