I'm having trouble passing a composite variable to a function.
I have a composite as follows:
declare userRecord dnaUsers%ROWTYPE;
and I manipulate it like this:
select into userRecord * from dnaUsers where etc;
userRecord.userid := 'jatinder'; --etc
I would like to then insert this record into the table (kind of like this):
insert into dnaUsers select userRecord;
insert into dnaUsers select userRecord.*;
insert into dnaUsers values (userRecord);
insert into dnaUsers values (userRecord.*);
All of the above generate various errors relating to "userRecord" not being
I can't find any examples of this in the archives or the documentation. Is
this even possible?
I also, haven't found a way to pass my "userRecord" to a function, eg:
create or replace function isUserActive (dnaUsers)
do something with $1;
' language plpgsql;
The problem here is that I can't pass userRecord to the new function:
isActive := isUserActive (userRecord);
Again, the errors appear to be about "userRecord" not being a table?
So, is it even possible to use composite records in this manner? All of the
examples I've seen, seem to be about passing a row of a direct select
statement as a composite argument to a function, and not about passing a
locally declared composite variable.
Can anyone help correct my understanding of what I can and can't do with
pgsql-sql by date
|Next:||From: Tom Lane||Date: 2004-02-13 15:27:27|
|Subject: Re: 7.4 - FK constraint performance |
|Previous:||From: Tom Lane||Date: 2004-02-13 15:15:31|
|Subject: Re: column alias and group by/having/order |