I've declared the following types in my PL/SQL package:
TYPE t_simple_object IS RECORD (
wert NUMBER,
gs NUMBER,
vl NUMBER);
TYPE t_obj_table IS TABLE OF t_simple_object
INDEX BY BINARY_INTEGER;
Then I declare a variable:
obj t_obj_table;
However, when I want to use the variable, I cannot initialize or extend it:
obj := t_obj_table ();
gives the following errror:
PLS-00222: no function with name 'T_OBJ_TABLE' exists in this scope
If I don't initialize it, I can't extend it to add some date as
obj.EXTEND();
gives another error:
PLS-00306: wrong number or types of arguments in call to 'EXTEND'
How can I make this work?
A table-based record, or table record, is a record whose structure (set of columns) is drawn from the structure (list of columns) of a table. Each field in the record corresponds to and has the same name as a column in the table.
SELECT TABLE_NAME FROM USER_TABLES will provide you with listing of tables in a particular schema. SELECT TABLE_NAME, OWNER FROM ALL_TABLES will provide you with listing of all tables for all schemas in the DB for which you have at least select privilege.
Data Insertion In PL/SQL, we can insert the data into any table using the SQL command INSERT INTO. This command will take the table name, table column and column values as the input and insert the value in the base table.
Table columns relate to the fields. Records are made up of a collection of fields that are similar to the columns in a row. You can declare a PL/SQL record that resembles a row in a database table without listing all the columns using the % ROWTYPE attribute.
You don't extend a table indexed by "something", you can just use it...
DECLARE
TYPE t_simple_object IS RECORD
( wert NUMBER
, gs NUMBER
, vl NUMBER
);
TYPE t_obj_table IS TABLE OF t_simple_object
INDEX BY BINARY_INTEGER;
my_rec t_simple_object;
obj t_obj_table;
BEGIN
my_rec.wert := 1;
my_rec.gs := 1;
my_rec.vl := 1;
obj(1) := my_rec;
END;
/
To use the EXTEND syntax, this example should do it...
DECLARE
TYPE t_simple_object IS RECORD
( wert NUMBER
, gs NUMBER
, vl NUMBER
);
TYPE t_obj_table IS TABLE OF t_simple_object;
my_rec t_simple_object;
obj t_obj_table := t_obj_table();
BEGIN
obj.EXTEND;
my_rec.wert := 1;
my_rec.gs := 1;
my_rec.vl := 1;
obj(1) := my_rec;
END;
/
Also see this link (Ask Tom)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With