X-Original-To: pgsql-odbc-postgresql.org@localhost.postgresql.org Received: from localhost (neptune.hub.org [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id EACFDD1DAFB for ; Tue, 13 Jan 2004 15:37:45 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 61772-06 for ; Tue, 13 Jan 2004 11:37:17 -0400 (AST) Received: from brazilnut.cc.columbia.edu (brazilnut.cc.columbia.edu [128.59.59.203]) by svr1.postgresql.org (Postfix) with ESMTP id D55C4D1DB06 for ; Tue, 13 Jan 2004 11:37:11 -0400 (AST) Received: from heritage0 ([200.50.67.88]) (user=rg2023 mech=LOGIN bits=0) by brazilnut.cc.columbia.edu (8.12.10/8.12.10) with ESMTP id i0DFapdG027933 (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NOT) for ; Tue, 13 Jan 2004 10:36:59 -0500 (EST) From: "Rean Griffith" To: Subject: executing insert sproc returns -1 rows affected even though new row inserted Date: Tue, 13 Jan 2004 10:36:29 -0500 Message-ID: <000001c3d9eb$13d453d0$0100a8c0@heritage0> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0001_01C3D9C1.2AFE4BD0" X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.3416 Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 X-No-Spam-Score: Local X-Scanned-By: MIMEDefang 2.35 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200401/44 X-Sequence-Number: 3673 This is a multi-part message in MIME format. ------=_NextPart_000_0001_01C3D9C1.2AFE4BD0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit I'm running PostgreSQL 7.4.1 on RHL 9 and using the psqlodbc-07_03_0200.zip odbc package on a Windows XP box running an ASP.Net 1.1 web app - I'm using the System.Data.Odbc classes and NOT the Microsoft.Data.Odbc classes. Below is a snippet of some unit test code I'm running, here's the problem, calling a stored procedure that does an insert succeeds but the rows affected (what gets returned from cmd.ExecuteNonQuery) is always -1. The sproc itself is very simple (also below). I turned on logging in the odbc driver, the log is also below. Any suggestions/ideas as to why the rows affected isn't coming back correctly and possible fixes etc.? Can replies be cc'ed to me as well as the list? Thx rg Snip start------------------------------------------------------------------- ------------------------------------------------------------------------ -------------------------------------------------------------- OdbcConnection conn = new OdbcConnection( "DSN=;UID=;PWD=;DATABASE=" ); conn.Open(); OdbcCommand cmd = new OdbcCommand(); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "{ call sp_CreateUser(?,?,?,?) }"; cmd.Parameters.Add( "userName", OdbcType.VarChar ); cmd.Parameters.Add( "userEmail", OdbcType.VarChar ); cmd.Parameters.Add( "userPswd", OdbcType.VarChar ); cmd.Parameters.Add( "userID", OdbcType.VarChar ); cmd.Parameters[0].Value = "c"; cmd.Parameters[1].Value = "c"; cmd.Parameters[2].Value = "c"; cmd.Parameters[3].Value = "c"; cmd.Connection = conn; int nRes = 0; nRes = cmd.ExecuteNonQuery(); conn.Close(); Snip end--------------------------------------------------------------------- ------------------------------------------------------------------------ ---------------------------------------------------------------- Sproc start------------------------------------------------------------------- ------------------------------------------------------------------------ --------------------------------------------------------------- create or replace function sp_CreateUser(varchar,varchar,varchar,varchar) returns integer as ' declare userName alias for $1; userEmail alias for $2; userPswd alias for $3; userID alias for $4; begin insert into Users(USER_NAME,USER_EMAIL,USER_PSWD,USER_ID) values (userName,userEmail,userPswd,userID); return 0; end; 'language 'plpgsql' Sproc end--------------------------------------------------------------------- ------------------------------------------------------------------------ -------------------------------------------------------------- Log start------------------------------------------------------------------- ------------------------------------------------------------------------ ------------------------------------------------------------------ conn=119028656, PGAPI_DriverConnect( in)='DSN=;UID=;PWD=;DATABASE=;', fDriverCompletion=0 DSN info: DSN='',server='',port='',dbase='',user=' ',passwd='' onlyread='0',protocol='6.4',showoid='0',fakeoidindex='0',showsystable='0 ' conn_settings='',conn_encoding='OTHER' translation_dll='',translation_option='' Global Options: Version='07.03.0200', fetch=100, socket=4096, unknown_sizes=0, max_varchar_size=254, max_longvarchar_size=8190 disable_optimizer=1, ksqo=1, unique_index=1, use_declarefetch=0 text_as_longvarchar=1, unknowns_as_longvarchar=0, bools_as_char=1 NAMEDATALEN=64 extra_systable_prefixes='dd_;', conn_settings='' conn_encoding='OTHER' conn=119028656, query=' ' conn=119028656, query='select version()' [ fetched 1 rows ] [ PostgreSQL version string = 'PostgreSQL 7.4 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 3.2.2 20030222 (Red Hat Linux 3.2.2-5)' ] [ PostgreSQL version number = '7.4' ] conn=119028656, query='set DateStyle to 'ISO'' conn=119028656, query='set geqo to 'OFF'' conn=119028656, query='set extra_float_digits to 2' conn=119028656, query='select oid from pg_type where typname='lo'' [ fetched 0 rows ] conn=119028656, query='select pg_client_encoding()' [ fetched 1 rows ] [ Client encoding = 'UNICODE' (code = 6) ] conn=119028656, PGAPI_DriverConnect(out)='(NULL)' CONN ERROR: func=PGAPI_GetInfo30, desc='', errnum=209, errmsg='Unrecognized key passed to SQLGetInfo30.' ------------------------------------------------------------ henv=119028600, conn=119028656, status=1, num_stmts=16 sock=119021336, stmts=119021408, lobj_type=-999 ---------------- Socket Info ------------------------------- socket=600, reverse=0, errornumber=0, errormsg='(NULL)' buffer_in=119039656, buffer_out=119043760 buffer_filled_in=61, buffer_filled_out=0, buffer_read_in=61 CONN ERROR: func=SQLGetInfo30, desc='', errnum=209, errmsg='Unrecognized key passed to SQLGetInfo30.' ------------------------------------------------------------ henv=119028600, conn=119028656, status=1, num_stmts=16 sock=119021336, stmts=119021408, lobj_type=-999 ---------------- Socket Info ------------------------------- socket=600, reverse=0, errornumber=0, errormsg='(NULL)' buffer_in=119039656, buffer_out=119043760 buffer_filled_in=61, buffer_filled_out=0, buffer_read_in=61 conn=119028656, query='SELECT sp_CreateUser('c','c','c','c') ' [ fetched 1 rows ] conn=119028656, PGAPI_Disconnect Log end--------------------------------------------------------------------- ------------------------------------------------------------------------ ----------------------------------------------------------------- ------=_NextPart_000_0001_01C3D9C1.2AFE4BD0 Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

I’m running PostgreSQL 7.4.1 on RHL 9 and using th= e psqlodbc-07_03_0200.zip odbc package on a Windows XP box running an ASP.Net 1.1 web app – I&#= 8217;m using the System.Data.Odbc classes and NOT the Microsoft.Data.Odbc classes.=

Below is a snippet of some unit test code I’m runn= ing, here’s the problem, calling a stored procedure that does an insert succeeds but the rows affected (what gets returned from cmd.ExecuteNonQuery= ) is always -1. The sproc itself is very simple (also below).

 

I turned on logging in the odbc driver, the log is also below.

 

Any suggestions/ideas as to why the rows affected isn= 217;t coming back correctly and possible fixes etc.?

 

Can replies be cc’ed to me as well as the list?

Thx rg

 

Snip start----------------------------------------------= ---------------------------------------------------------------------------= ---------------------------------------------------------------------------= -----

 

OdbcConnection conn = =3D new OdbcConnection( "DSN=3D<dbname>;UID=3D<dbuser>;PWD=3D<dbpasswd>;DATA= BASE=3D<dbname>" );

conn.Open();

   &nbs= p;            &= nbsp;      

OdbcCommand cmd =3D new OdbcCommand();

cmd.CommandType =3D Co= mmandType.StoredProcedure;

cmd.CommandText =3D &q= uot;{ call sp_CreateUser(?,?,?,?) }";

   &nbs= p;            &= nbsp;

cmd.Parameters.Add( &q= uot;userName", OdbcType.VarChar );

cmd.Parameters.Add( &q= uot;userEmail", OdbcType.VarChar );

cmd.Parameters.Add( &q= uot;userPswd", OdbcType.VarChar );

cmd.Parameters.Add( &q= uot;userID", OdbcType.VarChar );

 

cmd.Parameters[0].Valu= e =3D "c";

cmd.Parameters[1].Valu= e =3D "c";

cmd.Parameters[2].Valu= e =3D "c";

cmd.Parameters[3].Valu= e =3D "c";

cmd.Connection =3D con= n;

 

int nRes =3D 0;

nRes =3D cmd.ExecuteNo= nQuery();

   &nbs= p;            &= nbsp;      

conn.Close();

 

Snip end------------------------------------------------------------------------= ---------------------------------------------------------------------------= ----------------------------------------------------------

 

Sproc start----------------------------------------------------------------------= ---------------------------------------------------------------------------= ---------------------------------------------------------

 

create or replace func= tion sp_CreateUser(varchar,varchar,varchar,varchar) returns integer as

'

declare<= /p>

   &nbs= p;  userName alias for $1;

   &nbs= p;  userEmail alias for $2;

   &nbs= p;  userPswd alias for $3;

   &nbs= p;  userID alias for $4;

begin

   &nbs= p;  insert into Users(USER_NAME,USER_EMAIL,USER_PSWD,USER_ID) values (userName,userEma= il,userPswd,userID);

   &nbs= p;  return 0;

end; 

'language 'plpgsql'

 

Sproc end-----------------------------------------------= ---------------------------------------------------------------------------= ---------------------------------------------------------------------------= ------

 

Log start----------------------------------------------------------------------= ---------------------------------------------------------------------------= ------------------------------------------------------------<= /p>

 

conn=3D119028656, PGAP= I_DriverConnect( in)=3D'DSN=3D<edited>;UID=3D<edited>;PWD=3D<edited>;DATAB= ASE=3D<edited>;', fDriverCompletion=3D0

DSN info: DSN=3D'<e= dited>',server=3D'<edited>',port=3D'<edited>',dbase=3D'<e= dited>',user=3D'<edited>',passwd=3D'<edited>'<= /p>

   &nbs= p;      onlyread=3D'0',protocol=3D'6.4',showoid=3D'0',fakeoidindex=3D'0',showsystab= le=3D'0'

   &nbs= p;      conn_settings=3D'',conn_encoding=3D'OTHER'

   &nbs= p;      translation_dll=3D'',translation_option=3D''

Global Options: Version=3D'07.03.0200', fetch=3D100, socket=3D4096, unknown_sizes=3D0, max_= varchar_size=3D254, max_longvarchar_size=3D8190

   &nbs= p;            disable_optimizer=3D1, ksqo=3D1, unique_index=3D1, use_declarefetch=3D0

   &nbs= p;            text_as_longvarchar=3D1, unknowns_as_longvarchar=3D0, bools_as_= char=3D1 NAMEDATALEN=3D64

   &nbs= p;            extra_systable_prefixes=3D'dd_;', conn_settings=3D'' conn_encoding=3D'OTHER= '

conn=3D119028656, quer= y=3D' '

conn=3D119028656, query=3D'select version()'

    [ f= etched 1 rows ]

    [ PostgreSQL version string =3D 'PostgreSQL 7.4 on i686-pc-linux-gnu, compile= d by GCC gcc (GCC) 3.2.2 20030222 (Red Hat Linux 3.2.2-5)' ]

    [ PostgreSQL version number =3D '7.4' ]

conn=3D119028656, quer= y=3D'set DateStyle to 'ISO''

conn=3D119028656, quer= y=3D'set geqo to 'OFF''

conn=3D119028656, quer= y=3D'set extra_float_digits to 2'

conn=3D119028656, query=3D'select oid from pg_type where typname=3D'lo''

    [ f= etched 0 rows ]

conn=3D119028656, query=3D'select pg_client_encoding()'

    [ f= etched 1 rows ]

    [ C= lient encoding =3D 'UNICODE' (code =3D 6) ]

conn=3D119028656, PGAP= I_DriverConnect(out)=3D'(NULL)'

CONN ERROR: func=3DPGA= PI_GetInfo30, desc=3D'', errnum=3D209, errmsg=3D'Unrecognized key passed to SQLGetInfo30.= '

   &nbs= p;        ------------------------------------------------------------<= /p>

   &nbs= p;        henv=3D119028600, conn=3D119028656, status=3D1, num_stmts=3D16

   &nbs= p;        sock=3D119021336, stmts=3D119021408, lobj_type=3D-999

   &nbs= p;        ---------------- Socket Info -------------------------------<= /p>

   &nbs= p;        socket=3D600, reverse=3D0, errornumber=3D0, errormsg=3D'(NULL)'

   &nbs= p;        buffer_in=3D119039656, buffer_out=3D119043760

   &nbs= p;        buffer_filled_in=3D61, buffer_filled_out=3D0, buffer_read_in=3D61

CONN ERROR: func=3DSQL= GetInfo30, desc=3D'', errnum=3D209, errmsg=3D'Unrecognized key passed to SQLGetInfo30.= '

   &nbs= p;        ------------------------------------------------------------<= /p>

   &nbs= p;        henv=3D119028600, conn=3D119028656, status=3D1, num_stmts=3D16

   &nbs= p;        sock=3D119021336, stmts=3D119021408, lobj_type=3D-999

   &nbs= p;        ---------------- Socket Info -------------------------------<= /p>

   &nbs= p;        socket=3D600, reverse=3D0, errornumber=3D0, errormsg=3D'(NULL)'

   &nbs= p;        buffer_in=3D119039656, buffer_out=3D119043760

   &nbs= p;        buffer_filled_in=3D61, buffer_filled_out=3D0, buffer_read_in=3D61

conn=3D119028656, query=3D'SELECT  sp_CreateUser('c','c','c','c') '

    [ f= etched 1 rows ]

conn=3D119028656, PGAP= I_Disconnect

 

Log end-------------------------------------------------= ---------------------------------------------------------------------------= ---------------------------------------------------------------------------= -------

------=_NextPart_000_0001_01C3D9C1.2AFE4BD0--