Search Postgresql Archives

Is there a method to Execute update in Pl/Pgsql function using rowtype variable

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Greetings




I have a record variable in plpgsql function:

DECLARE

tabRow  TAB%ROWTYPE;

someVar varchar;

BEGIN
/*I Can do something like this*/

insert into TAB select tabRow.*;
....

/*but i want to update table TAB using variable rowTab*/
/* i know the list of colums that i want to update */
/*I've tried casting Record to text but I can't cast text to record:*/
someVar:=tabRow;

execute 'UPDATE TAB '||upd_expr()||' from CAST ('||someVar||' as TAB) foo where pkey='||tabRow.pkey;
/*
function upd_expr returns string '  col1=x.col2,col2=x.col2, ... , coln=x.coln ';
*/

/*
but "someVar:=tabRow;" makes someVar='(A,B,C,D,,,,,I)' and cast doesn work, it should be someVar='(''A'',''B'',''C'',''D'',NULL,NULL,NULL,NULL,''I'')'
*/


Is there a wa I can do such update?

Regards,

Tomasz





[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux