Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id A71C3633D01 for ; Mon, 19 Oct 2009 01:01:32 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 69896-04 for ; Mon, 19 Oct 2009 04:01:24 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sd.tpf.co.jp (sd.tpf.co.jp [210.161.239.34]) by mail.postgresql.org (Postfix) with SMTP id B314363387F for ; Mon, 19 Oct 2009 01:01:15 -0300 (ADT) Received: (qmail 18943 invoked by uid 512); 19 Oct 2009 04:01:12 -0000 Received: from unknown (HELO ?127.0.0.1?) (100.0.32.252) by sd2.tpf-fw-c.co.jp with SMTP; 19 Oct 2009 04:01:12 -0000 Message-ID: <4ADBE482.4020306@tpf.co.jp> Date: Mon, 19 Oct 2009 13:01:06 +0900 From: Hiroshi Inoue User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; ja; rv:1.8.1.23) Gecko/20090812 Thunderbird/2.0.0.23 Mnenhy/0.7.6.0 MIME-Version: 1.0 To: kishoramballi CC: pgsql-odbc@postgresql.org Subject: Re: Postgres inserts null value for parameterized statement References: <25896531.post@talk.nabble.com> In-Reply-To: <25896531.post@talk.nabble.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=1.297 tagged_above=-10 required=5 tests=BAYES_40=-0.185, DNS_FROM_RFC_BOGUSMX=1.482 X-Spam-Level: * X-Archive-Number: 200910/23 X-Sequence-Number: 10048 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