HSQLDB 2.3.3: How to create type array - hsqldb

How do I create an array of type BIGINT?
The following does not seem to work:
create TYPE ARRAY_NUMBERS AS ARRAY OF BIGINT;

CREATE TYPE ARRAY_NUMBERS AS BIGINT ARRAY;

Related

How to migrate an Associative Array from Oracle to Postgres

I have a procedure which I am trying to migrate from Oracle to Postgres, however there is this definition of an associative array type at DECLARE field which I am trying to convert for an equivalent type in Postgres. Here is how it is defined on Oracle:
DECLARE
TYPE SOMETHING IS TABLE OF varchar(04) INDEX BY integer;
Is there an alternative to deal with this type? It is later on being assigned to an variable as its type, like this:
TYPE SOMETHING IS TABLE OF varchar(04) INDEX BY integer;
ARRAY_SOMETHING SOMETHING;

Add array data type to sql database

Is it possible to add array data type to the postgreSQL database?
Like this :
ALTER TABLE table_name
ADD COLUMN new_column_name ARRAY;
You will need to define the type of the array, e.g. if you want an array of integers, use int[]
ALTER TABLE table_name
ADD COLUMN new_column_name int[];
(or use the ARRAY keyword as shown in Sebastian's answer)
For more details, see the manual
You can use ARRAY on any built-in or user-defined base type, enum type, or composite type like this:
ALTER TABLE table_name ADD COLUMN new_column_name INTEGER ARRAY;
demo on dbfiddle.uk

postgresql changing column type from array to integer throwing casting error

I am changing the postgresql column data type from integer[] to integer, while executing below query,
alter table contact_type alter column is_delete set data type integer USING is_delete::integer
i am getting below error
ERROR: cannot cast type integer[] to integer
LINE 1: ...umn is_delete set data type integer USING is_delete::integer
^
SQL state: 42846
Character: 86
but when tried to change datatype from varchar[] to char, below query works fine
alter table contact_type alter column ct_type set data type varchar
i have referred this link so link but it is not working for converting array to normal data type..
Edit :- it is empty table without any data...
You need to pick the array element that you want to use. You can't convert e.g. 42 integers to a single one.
E.g. if you want to use the first element of the array:
alter table contact_type
alter column is_delete
set data type integer USING is_delete[1];
But a column named is_delete should probably be a boolean rather than an integer.

How to pass single-column table to AMDP method?

I need to pass a table with a single column to an AMDP method which throws the error, the other parameters go fine:
TYPES: BEGIN OF s_so_i,
parent_key TYPE snwd_so_i-parent_key,
product_guid TYPE snwd_pd-node_key,
node_key TYPE snwd_so_i-node_key,
END OF s_so_i.
TYPES: BEGIN OF s_product,
product_guid TYPE snwd_pd-node_key,
category TYPE snwd_pd-category,
END OF s_product.
TYPES: tt_product TYPE STANDARD TABLE OF s_product,
tt_so TYPE STANDARD TABLE OF snwd_node_key, "<-- error
tt_so_i TYPE STANDARD TABLE OF s_so_i.
How should I define it?
instead of using snwd_node_key I can suggest you to use EGUID_S.
EGUID_S is a structure with only including a single column with RAW16 as SYSUUID
instead of
tt_so TYPE STANDARD TABLE OF snwd_node_key,
use
tt_so TYPE STANDARD TABLE OF EGUID_S,
Adding this solved the problem:
TYPES: BEGIN OF s_so,
so_guid TYPE snwd_so-node_key,
END OF s_so.
TYPES: tt_product TYPE STANDARD TABLE OF s_product,
tt_so_i TYPE STANDARD TABLE OF s_so_i,
tt_so TYPE STANDARD TABLE OF s_so. <--
So it seems the table type must point to a structure type.

How to declare table type inside structure?

In order to achieve my smartform, I'm supposed to declare a table within a structure. I tried this but it's not working:
TYPES: t_qase2 TYPE TABLE OF qase.
TYPES:
BEGIN OF ty_itab.
pruefer type qase-pruefer.
zeiterstl type qase-zeiterstl.
* ......(other fields)
ty_qase2 type t_qase2.
INCLUDE STRUCTURE s_f800komp.
TYPES END OF ty_itab.
To declare a table in a structure you simply give a table type with non-unique key to one of the fields:
TYPES: myTableType TYPE TABLE OF string WITH NON-UNIQUE DEFAULT KEY.
TYPES: BEGIN OF ty_itab,
pruefer type qase-pruefer,
zeiterstl type qase-zeiterstl,
myTable type myTableType, "Table is here
ty_qase2 type t_qase2.
INCLUDE STRUCTURE s_f800komp.
TYPES: END OF ty_itab.
Also notice that you end every line with a dot. In this case you have to use ,
Besides the variant proposed by previous answerer, there is variant of table declaration inside structure in an explicit way:
TYPES: BEGIN OF ty_itab,
pruefer TYPE qase-pruefer,
zeiterstl TYPE qase-zeiterstl,
myTable TYPE TABLE OF string WITH NON-UNIQUE DEFAULT KEY,
ty_qase2 TYPE t_qase2.
INCLUDE STRUCTURE s_f800komp.
TYPES: END OF ty_itab.