Обсуждение: Error or bug?

Поиск
Список
Период
Сортировка

Error or bug?

От
Vincenzo Romano
Дата:
Hi all.

Under PGSQL v8.2.4, in a PL/PgSQL function whenver I try to run this
statement:

INSERT INTO table1 SELECT  var1.*;

I get his message:

ERROR:  record type has not been registered
CONTEXT:  SQL statement "INSERT INTO table1 select  $1 .*"

Of course var1 has been declared as table1 type.

I suspect this could be a bug. But cannot be sure.
Any hint?

--
Vincenzo Romano -= NotOrAnd.IT Information Technologies =-
tel +39 0823 454163 | cel +39 339 8083886 | fax +39 02 700506964
<Smooth seas never make experienced sailormen>

Re: Error or bug?

От
Tom Lane
Дата:
Vincenzo Romano <vincenzo.romano@notorand.it> writes:
> Under PGSQL v8.2.4, in a PL/PgSQL function whenver I try to run this
> statement:
> INSERT INTO table1 SELECT  var1.*;
> I get his message:
> ERROR:  record type has not been registered

Works for me:

$ psql ...
Welcome to psql 8.2.4, the PostgreSQL interactive terminal.
...
regression=# create table table1(f1 int, f2 text);
CREATE TABLE
regression=# create or replace function foo() returns void as $$
declare var1 table1;
begin
  select * into var1 from table1;
  insert into table1 select var1.*;
end$$ language plpgsql;
CREATE FUNCTION
regression=# insert into table1 values(1,'one');
INSERT 0 1
regression=# select foo();
 foo
-----

(1 row)

regression=# select * from table1;
 f1 | f2
----+-----
  1 | one
  1 | one
(2 rows)

If that's not what you did, then let's see exactly what you did do.

            regards, tom lane