Re: Inserts using plpgsql - Further

From: "Richard Huxton" <dev(at)archonet(dot)com>
To: "PG-General" <pgsql-general(at)postgresql(dot)org>, "Scott Holmes" <sholmes(at)pacificnet(dot)net>
Subject: Re: Inserts using plpgsql - Further
Date: 2001-05-18 08:27:00
Message-ID: 003c01c0df74$512edd00$1001a8c0@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

From: "Scott Holmes" <sholmes(at)pacificnet(dot)net>

> Well, it does not seem to be a problem with multiple fields but with
fields
> that are integers.
>
> INSERT INTO journal (j_date,casenmbr,j_descr,j_rate,j_status) VALUES
> (jdate,cnmbr,erec.ev_title,erec.ev_rate,jstatus);
>
> Fails, but
>
> INSERT INTO journal (j_date,j_descr,j_rate,j_status) VALUES
> (jdate,erec.ev_title,erec.ev_rate,jstatus);
>
> Succeeds. The difference is casenmbr, an integer. j_rate is a decimal
value,
> j_date is a date and the others are character fields.

Puzzling:

drop table foo;

create table foo (a int unique not null, b text);

drop function foo_ins();

create function foo_ins() returns int as '
declare
va int;
vb text;
begin
va := 1;
vb := ''xxxxx'';
INSERT INTO foo (a,b) VALUES (va,vb);
return 1;
end;
' language 'plpgsql';

select foo_ins();
foo_ins
---------
1
(1 row)

select * from foo;
a | b
---+-------
1 | xxxxx
(1 row)

Works fine here - v7.1.1 but I'm sure I'd have noticed problems in previous
versions if there'd been a fault. I'd suspect some issue with the type of
the variable or something.

What precisely is the error and is it possible to provide the table and
function definition?

- Richard Huxton

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Richard Huxton 2001-05-18 08:45:36 Re: Various locking questions
Previous Message Einar Karttunen 2001-05-18 08:14:36 Re: lo and security