pg.ddx.io pgsql-general@postgresql.org mailing list archivehelp / color / mirror / Atom feed
PQexecParams and "SET TIME ZONE $1" gets 'syntax error at or near "$1" at character 15' 2+ messages / 2 participants [nested] [flat]
* PQexecParams and "SET TIME ZONE $1" gets 'syntax error at or near "$1" at character 15' @ 2024-11-23 15:01 ma.sao@msa.hinet.net 2024-11-23 15:57 ` Re: PQexecParams and "SET TIME ZONE $1" gets 'syntax error at or near "$1" at character 15' Pavel Stehule <pavel.stehule@gmail.com> 0 siblings, 1 reply; 2+ messages in thread From: ma.sao@msa.hinet.net @ 2024-11-23 15:01 UTC (permalink / raw) To: pgsql-general@lists.postgresql.org I get get this same error syntax error at or near "$1" at character 15 if I feed "const char *command" with the following texts. SET TIME ZONE $1 SET TIME ZONE $1::TEXT For some reasons, I can not add quotes around $1 as follows. SET TIME ZONE '$1' SET TIME ZONE '$1'::TEXT Statements like "SELECT ... WHERE $1=..." have been working flawlessly. It looks like PQexecParams doesn't handle statement with "SET ... $1". Are there workarounds for me or PQexecParams needs improvement? Thank you! ^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: PQexecParams and "SET TIME ZONE $1" gets 'syntax error at or near "$1" at character 15' 2024-11-23 15:01 PQexecParams and "SET TIME ZONE $1" gets 'syntax error at or near "$1" at character 15' ma.sao@msa.hinet.net @ 2024-11-23 15:57 ` Pavel Stehule <pavel.stehule@gmail.com> 0 siblings, 0 replies; 2+ messages in thread From: Pavel Stehule @ 2024-11-23 15:57 UTC (permalink / raw) To: ma.sao@msa.hinet.net; +Cc: pgsql-general@lists.postgresql.org Hi so 23. 11. 2024 v 16:01 odesílatel <ma.sao@msa.hinet.net> napsal: > I get get this same error > > syntax error at or near "$1" at character 15 > > if I feed "const char *command" with the following texts. > > SET TIME ZONE $1 > SET TIME ZONE $1::TEXT > > For some reasons, I can not add quotes around $1 as follows. > > SET TIME ZONE '$1' > SET TIME ZONE '$1'::TEXT > > Statements like "SELECT ... WHERE $1=..." have been working flawlessly. > > It looks like PQexecParams doesn't handle statement with "SET ... $1". > > Are there workarounds for me or PQexecParams needs improvement? > This statement has no plan, and then doesn't support parametrization. you can use a function set_config instead https://www.postgresql.org/docs/current/functions-admin.html#FUNCTIONS-ADMIN-SET SELECT set_config('timezone', $1, false) Regards Pavel > Thank you! > > --- 本郵件來自HiNet WebMail --- > ^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2024-11-23 15:57 UTC | newest] Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2024-11-23 15:01 PQexecParams and "SET TIME ZONE $1" gets 'syntax error at or near "$1" at character 15' ma.sao@msa.hinet.net 2024-11-23 15:57 ` Pavel Stehule <pavel.stehule@gmail.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions for how to clone and mirror all data and code used for this inbox