Do you also come from the world of Microsoft?

Maybe you are like me... I was a resident in the MS-SQL world for more than 20 years. When I started using PostgreSQL, I used temporary tables as a matter of course. I quickly realized that the concept of temporary tables in PostgreSQL was not working well, but it worked for the beginning.

In retrospect I had to realize: "Big error" 😊 ... different world, different concepts!

While temporary tables are used in MS-SQL, PostgreSQL refers to arrays as far as possible.

 

Some example:

 __data_branch_item_status smallint [];
__data_branch_item_status_length smallint;

__data_branch_item_status := ARRAY(SELECT json_array_elements_text(_jsonin->'filter'->'states')::smallint);
__data_branch_item_status_length = array_length(__data_branch_item_status, 1);

Select unnest(__data_branch_item_status)