From: Byron Nikolaidis <byronn@insightdist.com>
To: Peter Andrews <pete@piedmontdata.com>
Cc: pgsql-interfaces@postgreSQL.org
Subject: Re: [INTERFACES] ODBC string insert problem
Date: Fri, 19 Mar 1999 09:16:22 -0500
Message-ID: <36F25C36.B237BCCF@insightdist.com> (raw)
References: <36F17273.D1ABBC98@piedmontdata.com>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-interfaces@postgresql.org
Cc: byronn@insightdist.com, pete@piedmontdata.com
Subject: Re: [INTERFACES] ODBC string insert problem
In-Reply-To: <36F25C36.B237BCCF@insightdist.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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