pg.ddx.io pgsql-interfaces@postgresql.org mailing list archive
help / color / mirror / Atom feedODBC string insert problem
2+ messages / 2 participants
[nested] [flat]
* ODBC string insert problem
@ 1999-03-18 21:39 Peter Andrews <pete@piedmontdata.com>
0 siblings, 1 reply; 2+ messages in thread
From: Peter Andrews @ 1999-03-18 21:39 UTC (permalink / raw)
To: pgsql-interfaces
I am unable to insert the following string:
40'S?
into a varchar field through my ODBC driver. The statement:
insert into test values('40\'S?');
works perfectly using psql, but when I execute it through the ODBC
driver, I get the following error message:
parse error at or near ""
In fact, my ODBC driver seems to do this whenever I attempt to insert a
string with a question mark after a single quote. I am using PostgreSQL
6.4.2 and the Insight ODBC driver version 6.40.0004. If anyone has run
into this before, I would greatly apprciate your help.
Peter Andrews
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: [INTERFACES] ODBC string insert problem
@ 1999-03-19 14:16 Byron Nikolaidis <byronn@insightdist.com>
parent: Peter Andrews <pete@piedmontdata.com>
0 siblings, 0 replies; 2+ messages in thread
From: Byron Nikolaidis @ 1999-03-19 14:16 UTC (permalink / raw)
To: Peter Andrews <pete@piedmontdata.com>; +Cc: pgsql-interfaces
Peter Andrews wrote:
> I am unable to insert the following string:
>
> 40'S?
>
> into a varchar field through my ODBC driver. The statement:
>
> insert into test values('40\'S?');
>
A Question Mark is reserved as a parameter marker in odbc. The best way to
do something like this is to actually use a parameter. Then the driver will
allow question marks and other things. It will also translate things this
way, such as single quotes and so forth.
So, the moral of the story is, anytime you need to insert anything other
than very simple data, use a parameter.
The above example would become something like:
strcpy(buf, "40'S?")
pcbValue = strlen(buf)
SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, 0, 0,
buf, sizeof(buf), &pcbValue)
SQLExecDirect(hstmt, "insert into test values (?)", SQL_NTS)
Byron
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~1999-03-19 14:16 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1999-03-18 21:39 ODBC string insert problem Peter Andrews <pete@piedmontdata.com>
1999-03-19 14:16 ` Byron Nikolaidis <byronn@insightdist.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