From: Hiroshi Inoue <inoue@tpf.co.jp>
To: kishoramballi <kishoramballi@gmail.com>
Cc: pgsql-odbc@postgresql.org
Subject: Re: Postgres inserts null value for parameterized statement
Date: Mon, 19 Oct 2009 13:01:06 +0900
Message-ID: <4ADBE482.4020306@tpf.co.jp> (raw)
In-Reply-To: <25896531.post@talk.nabble.com>
References: <25896531.post@talk.nabble.com>
kishoramballi wrote:
> Hi,
>
> I have created table using following sql statement through psql tool in test
> database using
> create table t1(f1 int);
> table is created.
> Now I am using an odbc script to insert 5 records. But it inserts 6 records
> NULL value being the first one inserted.
> the code snippet is as below.
>
> ...
> ...
> retVal = SQLDriverConnect(dbHdl, NULL, (SQLCHAR*)"psql",
> SQL_NTS,outstr, sizeof(outstr), &outstrlen, SQL_DRIVER_NOPROMPT);
> SQLSetConnectAttr(dbHdl, SQL_ATTR_AUTOCOMMIT, SQL_AUTOCOMMIT_OFF, 0);
> int f1 = 0;
> ret = SQLPrepare(stmt,(unsigned char*)"INSERT INTO T1 VALUES(?);" ,
> SQL_NTS);
> ret = SQLBindParameter (stmt, 1, SQL_PARAM_INPUT, SQL_C_SLONG,
> SQL_INTEGER,0,0,&f1,0,NULL);
> int i,count=0;
> // EXECUTE THE STATEMENT
> for(i=0;i<5;i++)
> {
> f1++;
> ret = SQLExecute(stmt);
> ret = SQLTransact(env,dbc,SQL_COMMIT);
> count++;
> }
> ...
> ...
>
> I am using unixodb driver and my odbc.ini file reads as follows.
>
> $ vi ~/.odbc.ini
>
> [psql]
> Description = CP resources db
> Driver = postgres
> Trace = No
> TraceFile = sql.log
> Database = test
> Servername = localhost
> UserName = kishoramballi
> Password = kishoramballi
> Port = 5432
> Protocol = 6.4
Please set
Protocol = 7.4
and set one of the follwoing.
1)
UseServerSidePrepare = 1
2)
DisallowPremature = 1
3)
Parse = 1
regards,
Hiroshi Inoue
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-odbc@postgresql.org
Cc: inoue@tpf.co.jp, kishoramballi@gmail.com
Subject: Re: Postgres inserts null value for parameterized statement
In-Reply-To: <4ADBE482.4020306@tpf.co.jp>
References: <25896531.post@talk.nabble.com> <4ADBE482.4020306@tpf.co.jp>
* 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