0

Is there any way in PostgreSQL to declare local type "TABLE OF ..%ROWTYPE INDEX BY BINARY_INTEGER" inside a function like in Oracle?

CREATE OR REPLACE FUNCTION FNC
   RETURN NUMBER
AS
   TYPE TYPE_TB IS TABLE OF ADM_APPLICATIONS%ROWTYPE
      INDEX BY BINARY_INTEGER;

   TB_VAR   TYPE_TB;
BEGIN
   return 1;
END;
| |
  • This looks like a XY Problem. How about describing what you are trying to achieve instead? – Kamil Gosciminski Sep 29 '16 at 16:05
0

For every table there is also a corresponding type (with the same name) available.

So you can do the following:

CREATE OR REPLACE FUNCTION fnc()
   RETURNs integer
AS
$$
declare
   tb_var adm_applications[];
begin
   return 1;
end;
$$
language plpgsql;
| |
  • Thank you for reply! – Iuliia Sep 30 '16 at 7:21
  • Thank you for reply! And then one more question: how to set and get field value? This way doesn't work : CREATE OR REPLACE FUNCTION fnc() RETURNs integer AS $$ declare tb_var adm_applications[]; begin tb_var[1].col_name:= 'LALALA'; return 1; end; $$ language plpgsql; It says : "ERROR: syntax error at or near "." LINE 5: tb_var[1].col_name:= 'LALALA';" @a_horse_with_no_name – Iuliia Sep 30 '16 at 7:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.