Re: referential integrity violation
От | Harald Fuchs |
---|---|
Тема | Re: referential integrity violation |
Дата | |
Msg-id | y29iszvahx5.fsf@dorando.intern.colibri.de обсуждение исходный текст |
Ответ на | Re: referential integrity violation ("Nigel J. Andrews" <nandrews@investsystems.co.uk>) |
Список | pgsql-general |
In article <Pine.LNX.4.21.0210211547390.3016-100000@ponder.fairway2k.co.uk>, nandrews@investsystems.co.uk ("Nigel J. Andrews") writes: > On Mon, 21 Oct 2002 mk@fashaf.co.za wrote: >> I have tried '' , undef , 'NULL' , 'null' non of them seem to work? >> >> any idea how to submit a NULL value with perl? >> > Okay, let's take a step back to view the slightly larger picture rather than > the little detail... > With a design such as: > create table t1 ( > i int primary key > ); > create table t2 ( > i int primary key, > t text, > a int references t1 (a) > ); > your perl code should be submitting a string such as, note the lack of quotes > around the null: > insert into mytable values ( 23, 'my text', NULL ) > i.e. > use Pg; > # connect to server etc. > $conn->exec("insert into mytable values ( 23, 'my text', NULL )"); > # error check etc. You could also let Perl do the quoting for you: use DBI; > # connect to server etc. $conn->do (q{ INSERT INTO mytable VALUES (?, ?, ?) }, undef, 23, "my text", undef);
В списке pgsql-general по дате отправления: