Thread: Insert fails from VB only when table is empty...?

Insert fails from VB only when table is empty...?

From
"LaBranche, Kevin"
Date:

I am brand new to pgsql... J  I have a VB program inserting records into a fairly simple table (without a PK) and I notice that when the table is empty I get a "row out of range" error.  This only happens when the table is empty.  If I insert a record from psql then run the program everything is fine.  Any ideas as to what may be wrong?

 

Thanks,

Kevin

 

Re: Insert fails from VB only when table is empty...?

From
"Chad Thompson"
Date:
what SQL statement are you using?
Are you connecting via OdbcConnection?
 
Chad
----- Original Message -----
Sent: Friday, March 28, 2003 12:48 PM
Subject: [NOVICE] Insert fails from VB only when table is empty...?

I am brand new to pgsql... J  I have a VB program inserting records into a fairly simple table (without a PK) and I notice that when the table is empty I get a "row out of range" error.  This only happens when the table is empty.  If I insert a record from psql then run the program everything is fine.  Any ideas as to what may be wrong?

 

Thanks,

Kevin

 

Re: Insert fails from VB only when table is empty...?

From
brew@theMode.com
Date:
Kevin......

> I am brand new to pgsql... :-)  I have a VB program inserting records
> into a fairly simple table (without a PK) and I notice that when the
> table is empty I get a "row out of range" error.  This only happens when
> the table is empty.

I use PHP instead of VB, but it sounds like you should only try to fetch
the rows if some exist.  In php the first row fetch starts at zero, so if
there is one row you ask for n-1, i.e. row zero.  If no rows exist you use
an if statement to skip around the row fetch (and maybe print a no info
found message).

Maybe this is what's happening to you.

later....

brew

 ==========================================================================
                  Strange Brew   (brew@theMode.com)
     Check out my Musician's Online Database Exchange (The MODE Pages)
                        http://www.TheMode.com
 ==========================================================================