Re: referential integrity violation

From: Harald Fuchs <hf(at)colibri(dot)de>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: referential integrity violation
Date: 2002-10-21 16:13:58
Message-ID: y29iszvahx5.fsf@dorando.intern.colibri.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

In article <Pine(dot)LNX(dot)4(dot)21(dot)0210211547390(dot)3016-100000(at)ponder(dot)fairway2k(dot)co(dot)uk>,
nandrews(at)investsystems(dot)co(dot)uk ("Nigel J. Andrews") writes:

> On Mon, 21 Oct 2002 mk(at)fashaf(dot)co(dot)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);

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Joe Conway 2002-10-21 16:20:36 Re: [GENERAL] Security implications of (plpgsql) functions
Previous Message Ericson Smith 2002-10-21 16:11:35 Numerous postmaster processes after upgrading to 7.2.3