Обсуждение: ecpg help with 7.3
Hi all, To start with we have recently migrated from v7.2.3 to v7.3, and I have an embedded SQL code (ecpg) that used to work fine with 7.2.3. With the new 7.3 it gives me an error when inserting into a table, Cannot Insert in table xyz(-400):50 'ERROR: pg_atoi: zero-length string' my first guess was that there was a zero length string (NULL) being inserted in the table... but the attributes of the columns in the table are such that they can accept NULL's too. Having done this i tested the same data over 7.2.3 and it worked good. Can somebody help me with this please ..... Thanks and regards =Sid
On Mon, Jan 27, 2003 at 12:48:23PM -0500, Sid wrote: > Cannot Insert in table xyz(-400):50 'ERROR: pg_atoi: zero-length string' > my first guess was that there was a zero length string (NULL) being inserted > in the table... but the attributes of the columns in the table are such that > they can accept NULL's too. Zero length strings are something different than NULLs. The pg_atoi message shows that there indeed is a zero length string. You could enable logging and see exactly what data is sent to the backend. Please just look into the test cases in ecpg/test and search for ECPGdebug resp. file descriptor dbgs. Michael -- Michael Meskes Email: Michael@Fam-Meskes.De ICQ: 179140304 Go SF 49ers! Go Rhein Fire! Use Debian GNU/Linux! Use PostgreSQL!
"Sid" <sbhatt@installs.com> writes:
> Cannot Insert in table xyz(-400):50 'ERROR: pg_atoi: zero-length string'
> my first guess was that there was a zero length string (NULL) being inserted
> in the table...
A zero-length string is not a NULL (even if Oracle can't tell the
difference).
Before 7.3, pg_atoi (the integer datatype's input converter) would
sloppily accept a zero-length string as meaning 0 (not NULL). We
fixed that ...
regards, tom lane
Sid,
Before 7.3, trying to insert an empty string into a number type column
would result in 0 being inserted into the column:
lkind=# CREATE TABLE x(f INTEGER);
CREATE
lkind=# INSERT INTO x(f) VALUES ('');
INSERT 859614628 1
lkind=# SELECT * FROM x;
f
---
0
(1 row)
With 7.3 an error is now output.
lkind=# CREATE TABLE x(f INTEGER);
CREATE TABLE
lkind=# INSERT INTO x(f) VALUES ('');
ERROR: pg_atoi: zero-length string
lkind=# SELECT * FROM x;
f
---
(0 rows)
Also you seem to be confusing the empty string with NULL - an empty
string is not a NULL value. To insert a NULL:
lkind=# INSERT INTO x(f) VALUES (NULL);
INSERT 28217013 1
lkind=# SELECT * FROM x;
f
---
(1 row)
Lee.
Sid writes:
> Hi all,
>
> To start with we have recently migrated from v7.2.3 to v7.3, and I have
> an embedded SQL code (ecpg) that used to work fine with 7.2.3. With the new
> 7.3 it gives me an error when inserting into a table,
> Cannot Insert in table xyz(-400):50 'ERROR: pg_atoi: zero-length string'
> my first guess was that there was a zero length string (NULL) being inserted
> in the table... but the attributes of the columns in the table are such that
> they can accept NULL's too.
> Having done this i tested the same data over 7.2.3 and it worked good. Can
> somebody help me with this please .....
>
>
> Thanks and regards
> =Sid