Re: Inserts using plpgsql - Further - Mailing list pgsql-general

From Richard Huxton
Subject Re: Inserts using plpgsql - Further
Date
Msg-id 003c01c0df74$512edd00$1001a8c0@archonet.com
Whole thread Raw
In response to Inserts using plpgsql - Further  (Scott Holmes <sholmes@pacificnet.net>)
Responses RE: Inserts using plpgsql - Further
List pgsql-general
From: "Scott Holmes" <sholmes@pacificnet.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


pgsql-general by date:

Previous
From: Einar Karttunen
Date:
Subject: Re: lo and security
Next
From: "Richard Huxton"
Date:
Subject: Re: Various locking questions