I'm currently migrating some procedures from Oracle to Postgres, those procedures are using a type that was created to handle an unknown number of values:
TYPE array_text IS TABLE OF VARCHAR2 (50);
So they can declare a variable like:
myValues in array_text;
And use it later this way:
myValues(1) := 'VALUE1';
myValues(2) := 'VALUE2';
...
So I have been learning and trying to replicate this behavior using Postgres, but until now I can't find a properly way. I tried creating a composite type like:
CREATE TYPE array_text AS (
val varchar(50)
);
Or
CREATE TYPE array_text AS (
v varchar(50)[]
);
However I can't use them the same way as the original is used, and actually I couldn't create a successful test.
How could I get this behavior or something similar? So I can set and get values and even count its length like in Oracle