Skip site navigation (1) Skip section navigation (2)

Re: [INTERFACES] ODBC string insert problem

From: Byron Nikolaidis <byronn(at)insightdist(dot)com>
To: Peter Andrews <pete(at)piedmontdata(dot)com>
Cc: pgsql-interfaces(at)postgreSQL(dot)org
Subject: Re: [INTERFACES] ODBC string insert problem
Date: 1999-03-19 14:16:22
Message-ID: 36F25C36.B237BCCF@insightdist.com (view raw or flat)
Thread:
Lists: 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



In response to

pgsql-interfaces by date

Next:From: Byron NikolaidisDate: 1999-03-19 14:53:51
Subject: [Fwd: UNIX ODBC - Applixware]
Previous:From: Dave PageDate: 1999-03-19 09:09:46
Subject: RE: [INTERFACES] problem with pgAdmin

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group