From: | Julius Tuskenis <julius(at)nsoft(dot)lt> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | cycling through custom type fields |
Date: | 2011-05-19 06:54:20 |
Message-ID: | 4DD4BE9C.7080808@nsoft.lt |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hello,
I would like to ask if there is a possibility in postgresql (v9) to
cycle through the fields of some custom type parameter in plpgsql function.
I have a type defined:
CREATE TYPE naims.frt_pwd_ed AS
(pwd_id integer,
pwd_sub_id integer,
pwd_login character varying(100));
In pseudocode thats what I'd like to achieve:
function Changes(prm_old_pwd naims.frt_pwd_ed, prm_new_pwd
naims.frt_pwd_ed)
returns set of text
begin
FOR i = 0 to naims.frt_pwd_ed.FieldCount -1 LOOP
IF prm_old_pwd.field(i).value <> prm_new_pwd.field(i).value THEN
Return Next prm_old_pwd.field(i).fieldname;
END IF;
END LOOP;
Return;
end;
The functrion should check each field of 2 provided parameters and
return the fieldnames where the values are different. For this I need
some tools to extract field value and field name. Can this be done?
Thank You in advance!
--
Julius Tuskenis
Programavimo skyriaus vadovas
UAB nSoft
mob. +37068233050
From | Date | Subject | |
---|---|---|---|
Next Message | John R Pierce | 2011-05-19 07:05:17 | Re: question about readonly instances |
Previous Message | Georgi Ivanov | 2011-05-19 06:46:20 | What's eating my space ? |