Nested table question
Hello
Anyone can guide me please on this issue? I get an error PLS-00382: expression is of the wrong type
CREATE TABLE TEST1
(
NUMBER EMPNO,
DEPTNO NUMBER,
HIRE_DATE DATE
);
CREATE TABLE new_table1
(
NUMBER EMPNO,
DEPTNO NUMBER,
HIRE_DATE DATE
);
insert into test1 values (100, 10, sysdate);
insert into test1 values (100, 20, sysdate + 1);
insert into test1 values (100, 30, sysdate + 2);
insert into test1 values (100, 30, sysdate-100);
insert into test1 values (200, 10, sysdate);
insert into test1 values (200, 20, sysdate + 1);
insert into test1 values (200, 30, sysdate + 2);
insert into test1 values (200, 30, sysdate-200);
Commit
/
delete from new_table1;
Set serveroutput on;
declare
cursor c1 is select * from test1;
tt type is varchar table (50);
tt_type tt;
Start
for rec in c1
loop
tt_type.extend ();
If rec.hire_date between sysdate-1 and sysdate + 1 then
tt_type (Rec): = to_char (rec.hire_date);
elsif rec.hire_date between sysdate and sysdate + 1 then
tt_type (Rec): = to_char (rec.hire_date);
dbms_output.put_line (' hire date ' | rec.hire_date);
end if;
because me in 1.tt_type.count
loop
insert into new_table1 (empno, hire_date, region_id) values (rec.empno, rec.hire_date, tt_type (i));
end loop;
end loop;
end;
/
[/ code]
Select * from new_table1;
So many things wrong with your posted example. However, I think you want to do something like
declare
cursor c1 is select * from test1;
type tt is the table of the varchar2 (100);
tt_type tt: = tt();
v_increment number: = 0;
Start
for rec in c1
loop
tt_type.extend ();
v_increment: = v_increment + 1;
If rec.hire_date between sysdate-1 and sysdate + 1 then
tt_type (v_increment): = rec.deptno;
-dbms_output.put_line (' hire date ' | rec.hire_date);
elsif rec.hire_date between sysdate and sysdate + 1 then
tt_type (v_increment): = rec.deptno;
-dbms_output.put_line (' hire date ' | rec.hire_date);
end if;
because me in 1.tt_type.count
loop
insert into new_table1 (empno, hire_date, deptno) values (rec.empno, rec.hire_date, tt_type (i));
end loop;
end loop;
end;
/
Tags: Database
Similar Questions
-
Question simple quue PL/SQL nested tables
Hello, my question is about nested tables. Suppose I have a nested table:
Int_array ARRAY TYPE IS INT;
v_int_array int_array;
Is there a built in function for me to v_int_array for a specific integer search value?
GeorgeMEMBER of operator use:
declare TYPE int_array IS TABLE OF INT; v_int_array int_array := int_array(1,2,3,4,5); begin if 1 member of v_int_array then dbms_output.put_line('Found it!'); end if; end; / Found it! PL/SQL procedure successfully completed. SQL>
SY.
-
Question about the nested Table
I created a table nested in the database type.
CREATE TYPE TT1 IS TABLE OF THE VARCHAR2 (100);
If I use this collection in my procedure and fill it with values, these values are stored in the tablespace/data files or cache. I'm asking is because I want to fill the collection with a lot of documents and collections are stored in memory and the comprehensive data set will explode memory told me.
You mention a procedure so I guess that we are talking about a nested table defined in and complemented by a PL/SQL block. If so, these data are stored in the PGA. You should be a good idea on the amount of data you have in the PL/SQL collections at any time in time, because the PGA memory is a relatively rare commodity.
If we are talking of a nested table that corresponds to a column in a normal organized in a heap table, these data are stored in data files and read the SGA according to the needs as all data in a heap table.
Justin
-
Nested table frees the file after validation?
Hello world
My version of DB is
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bi
PL/SQL Release 10.2.0.1.0 - Production
"CORE 10.2.0.1.0 Production."
AMT for Linux: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production
I have a question about the nested table. I am writing a code to change the data type for a column varchar2 to date without deleting the data.
So I thought instead of creating the table or the TWG, I will fill these data in the collection and updating of this column as null. So I'll change the data type for this column and the data that is loaded inside the collection, I'll shoot back as it is.
The collection is formed, the data are updated with the null value and data type of the column is updated as well. But when I'm trying to load the data in collection, it seems to be empty. Why is happening. ? Nested table depends on the statement commit?
Please take a look at the code and suggest me something here.
DECLARE
TYPE ARRAY_REC_TYPE IS RECORD (SPECTRA_MRN CROWN_WEB_PATIENT_LIST. TYPE % SPECTRA_MRN
CALENDAR_MONTH_END_DATE CROWN_WEB_PATIENT_LIST. TYPE % CALENDAR_MONTH_END_DATE
INFLUENZAWHENGIVEN CROWN_WEB_PATIENT_LIST. INFLUENZAWHENGIVEN % TYPE);
TYPE ARRAY_TAB_TYPE IS TABLE OF THE ARRAY_REC_TYPE;
VC_ARRAY_TAB_TYPE ARRAY_TAB_TYPE: = ARRAY_TAB_TYPE();
BEGIN
SELECT SPECTRA_MRN,
CALENDAR_MONTH_END_DATE,
INFLUENZAWHENGIVEN
BULK COLLECT INTO VC_ARRAY_TAB_TYPE
OF CROWN_WEB_PATIENT_LIST
WHERE INFLUENZAWHENGIVEN IS NOT NULL;
FOR I IN VC_ARRAY_TAB_TYPE.first... VC_ARRAY_TAB_TYPE. Last LOOP
UPDATE CROWN_WEB_PATIENT_LIST
SET INFLUENZAWHENGIVEN = NOTHING
WHERE SPECTRA_MRN = VC_ARRAY_TAB_TYPE (I). SPECTRA_MRN
AND TRUNC (CALENDAR_MONTH_END_DATE) = TRUNC (VC_ARRAY_TAB_TYPE (I). CALENDAR_MONTH_END_DATE);
END LOOP;
RUN IMMEDIATELY 'ALTER TABLE CROWN_WEB_PATIENT_LIST CHANGE INFLUENZAWHENGIVEN DATE ";
FOR K IN VC_ARRAY_TAB_TYPE.first... VC_ARRAY_TAB_TYPE. Last LOOP
UPDATE CROWN_WEB_PATIENT_LIST
SET INFLUENZAWHENGIVEN = TO_DATE (to_char (VC_ARRAY_TAB_TYPE (K). INFLUENZAWHENGIVEN, 'YYYY-MM-DD'))
WHERE SPECTRA_MRN = VC_ARRAY_TAB_TYPE (K). SPECTRA_MRN
AND TRUNC (CALENDAR_MONTH_END_DATE) = TRUNC (VC_ARRAY_TAB_TYPE (K). CALENDAR_MONTH_END_DATE);
END LOOP;
EXCEPTION
WHILE OTHERS THEN
ROLLBACK;
END;
/
Kind regards
BS2012.
Your EXCEPTION WHILE others removes any possible EXCEPTOIN that is raised. You need to get rid of him. Or at least use RAISES at the end. And if you decide to use the collection then get the best out of him using treatment in BULK. Here is an example FORALL.
SQL> desc t Name Null? Type ----------------------------------------- -------- ---------------------------- ID NUMBER DT VARCHAR2(10) SQL> select * from t; ID DT ---------- ---------- 1 05-08-2014 2 06-08-2014 3 07-08-2014 4 08-08-2014 5 09-08-2014 6 10-08-2014 7 11-08-2014 8 12-08-2014 9 13-08-2014 10 14-08-2014 10 rows selected. SQL> declare 2 type id_tbl is table of t.id%type; 3 type dt_tbl is table of t.dt%type; 4 l_id id_tbl; 5 l_dt dt_tbl; 6 begin 7 select id, dt bulk collect into l_id, l_dt 8 from t; 9 10 update t 11 set dt = null; 12 13 execute immediate 'alter table t modify dt date'; 14 15 forall i in 1..l_id.count 16 update t 17 set dt = to_date(l_dt(i), 'dd-mm-yyyy') 18 where id = l_id(i); 19 end; 20 / PL/SQL procedure successfully completed. SQL> desc t Name Null? Type ----------------------------------------- -------- ---------------------------- ID NUMBER DT DATE SQL> select * from t; ID DT ---------- --------- 1 05-AUG-14 2 06-AUG-14 3 07-AUG-14 4 08-AUG-14 5 09-AUG-14 6 10-AUG-14 7 11-AUG-14 8 12-AUG-14 9 13-AUG-14 10 14-AUG-14 10 rows selected. SQL>
-
When you create a table nested within a table, can I please have a description of what the STORE AS medium of instruction?
Here is an example:
NESTED TABLE, STORE LineItemList_ntab AS PoLine_ntab
I have had a look in the documentation, but cannot find the answer to this question.
Published by: 996403 on May 7, 2013 22:50Sound the segment of nested table name, 11 g, you can also have SECUREFICHIERS as for example you can thus encrypt, oracle doc said The Oracle database server stores data for the nested table offline from the lines of the parent table, using a table of store that is associated with the nested table column. The parent row contains a value to set unique identifier associated with a nested table instance. See http://docs.oracle.com/cd/B28359_01/server.111/b28318/schema.htm#CHDFDBGH
Published by: Karan on May 8, 2013 11:38
-
Columns of the nested Table and ADF BC 11.1.2
I think coming to a new conception of the application, including a redesign of the database. In this application, there are users who cannot change tables of production directly, but their amendments must be approved (and possibly modified) before applying them to production tables. The production tables are part of an existing system and are fairly well standardized, with a main table and several paintings of detail.
So for the new design, I want to have a table intermediate, mirrored in the main table, where the user's changes are stored until they are approved and applied to the production tables. The intermediate table contains some additional columns for the user "add, change or delete", who supported the change, the date modified is requested. After you apply the change, the intermediate folder must be copied in a historic change and deleted from the staging table. In this way, the intermediate table is never a lot of data in it.
Here's the question:
I need to treat the tables in detail. I could have staged versions of each table in detail, but I thought it might be easier to manage if detail tables have been included in table nested table columns main staging area. Most of the detail tables contain only a few rows with rank of master. But ADF BC 11.1.2 can treat the nested table columns? Is it easy to use in an application?Hello
and ADF Faces does support nested tables? lol so even if ADF BC would be, where would you go with this approach? Polymorphic views would be an option (think hard)?
Frank
-
Nested table of object type have only one record all the time
Hi all
I have a question regarding the storage of multiple records in a nested Table that is of type OBJECT.
The program below that I wrote for the test and during the test, I was able to store only the last record in the nested Table.
Please let me know what I did wrong here.
Step 1:
CREATE or REPLACE TYPE book_obj AS OBJECT (name varchar2 (25), author varchar2 (25), abstract varchar2 (4000));
/
Step 2:
CREATE or REPLACE TYPE book_table IS TABLE OF THE book_obj;
/
Step 3: CREATE TABLE book (name, varchar2 (25), varchar2 (25) author, varchar2 (4000)) abstract;
INSERT VALUES Accountants ('Harry Potter,' 'MK', 'It's magic');
INSERT the book VALUES ("Ramayana', 'VK', 'It is mythiology'");
COMMIT;
Step 4:
declare
bookset book_table;
ln_cnt pls_integer;
Start
bookset: = book_table (book_obj ('madhu', 'kongara', 'sudhan'));
dbms_output.put_line (' the number is ' | bookset.) (Count); -> I see COUNT = 1
bookset: = bookset_t(); -> Assignment to NULL.
dbms_output.put_line (' the number is ' | bookset.) (Count); -> I see County 0
for rec in (select * from book) loop-> now a loop twice.
dbms_output.put_line (' name > ' |) Rec.Name);
bookset: = bookset_t (book_t (rec.name, rec.author, rec.abstract));
end loop;
dbms_output.put_line (' the number is ' | bookset.) (Count); -> I can see COUNT = 1 (why?)
END;
I looped twice to fill two records in the TABLE IMBRIQUEE OF TYPE OBJECT. But when I see the Count I get only 1 and the data is also having the last record.
Can you get it someone please let me know how to fill out the table nested with all records. Tell me where I am wrong.
Very much appreciate your help here.
Thank you and best regards,
NKMMaldini says:
dbms_output.put_line (' the number is ' | bookset.) (Count); -->, I can see COUNT = 1 (why?)Because instead of add to bookset collectionto set (ergo replacement) it a collection containing recovered book. Use:
declare bookset book_table; ln_cnt pls_integer; begin bookset := book_table(book_obj('madhu','kongara','sudhan')); dbms_output.put_line('The count is '||bookset.count); --> I can see COUNT =1 bookset := book_table(); --> Assigning back to NULL. dbms_output.put_line('The count is '||bookset.count); --> I can see count as 0 for rec in (select * from book) loop --> Now Looping two times. dbms_output.put_line(' name > '||rec.name); bookset.extend; bookset(bookset.count) := book_obj(rec.name, rec.author, rec.abstract); end loop; dbms_output.put_line('The count is '||bookset.count); --> I can see COUNT =1 (why) end; / The count is 1 The count is 0 name > Harry Potter name > Ramayana The count is 2 PL/SQL procedure successfully completed. SQL>
Or better use bulk collect:
declare bookset book_table; ln_cnt pls_integer; begin bookset := book_table(book_obj('madhu','kongara','sudhan')); dbms_output.put_line('The count is '||bookset.count); --> I can see COUNT =1 bookset := book_table(); --> Assigning back to NULL. dbms_output.put_line('The count is '||bookset.count); --> I can see count as 0 select book_obj(name,author,abstract) bulk collect into bookset from book; for i in 1..bookset.count loop --> Now Looping two times. dbms_output.put_line(' name > '||bookset(i).name); end loop; dbms_output.put_line('The count is '||bookset.count); --> I can see COUNT =1 (why) end; / The count is 1 The count is 0 name > Harry Potter name > Ramayana The count is 2 PL/SQL procedure successfully completed. SQL>
SY.
-
Hello I can't people seem to find all threads that answered my question.select bt.ISBN, bt.title, bt.author, bt.classmark, ct.copy#, count(s) numOnLoan from book_tab bt, copy_tab ct, table(ct.isSubjectOf) s where bt.ISBN like 'S.321.45%' or bt.title like 'S.321.45%' or bt.author like 'S.321.45%' or bt.classmark like 'S.321.45%'
If I remove the County this query works
each row of the copy_tab has a nested table of ref to loan_t. I want out of a column for each row that displays how many rows there are in the nested table that is how many copies is lent.
I've tried a few things but none of them work! so why I am here!I suppose that column in ais copy_tab isSubjectOf table a nested table. If so, use:
select bt.ISBN, bt.title, bt.author, bt.classmark, ct.copy#, (select count(*) from table(ct.isSubjectOf)) numOnLoan from book_tab bt, copy_tab ct where bt.ISBN like 'S.321.45%' or bt.title like 'S.321.45%' or bt.author like 'S.321.45%' or bt.classmark like 'S.321.45%' /
SY.
-
How to represent Nested table as variable/object in OIC
Hi all
I'm new to the BEAK.
I now have the nested in my database table.
Nested table:
Create the type type1 as an object (name varchar2 (20));
Create the type type2 as type1 table;
create table table1 (varchar2 (20) col1, col2 type2) store col2 table nested as table2;
Can someone help me to col2 as C structure/typedef to use it with OCIDefineObject?You can take a look at Chapter 11 of the Guide to the programmer of the OIC. Look at the Collections inside section. You can represent the nested as OCITable table *. In addition, you can generate a representation of the structure of your object using OTT type. Please let us know if that answers your question. In the case where you are not able to proceed please let us know.
Thank you
Sumit -
helps the update in the parameter of the nested table
I was asked a question by a co-worker, but I couldn't help him.
He got these types:
And he wants to create a procedure that has IN OUT TP_PARTYPE parameter so that it can change the color column in all records in the table. It's his essay (which fails to compile):CREATE OR REPLACE TYPE TP_COLTYPE AS OBJECT ( parametro varchar2(30 byte), rango number(12,2), color varchar2(15 byte) ) / CREATE OR REPLACE TYPE TP_COLTYPE_TAB AS TABLE OF TP_COLTYPE; / CREATE OR REPLACE TYPE TP_PARTYPE AS OBJECT ( perfil_comercial VARCHAR2(30), subtendido VARCHAR2(2), parametros TP_COLTYPE_TAB ) /
I don't think you use a cursor is necessary or effective, but I failed to find the right way. I don't know which version he works with, but I know that it is 10g.CREATE OR REPLACE PROCEDURE getColoresUmbrales(p_parametros IN OUT TP_PARTYPE) IS CURSOR c_partype IS SELECT parametro,rango FROM TABLE(p_parametros.parametros) FOR UPDATE; BEGIN FOR r_partype IN c_partype LOOP UPDATE TABLE(p_parametros.parametros) SET color = getColorUmbral(p_parametros.perfil_comercial,p_parametros.subtendido,r_partype.parametro,r_partype.parametro) WHERE CURRENT OF c_partype; END LOOP; EXCEPTION WHEN OTHERS THEN RAISE_APPLICATION_ERROR(-20000,SQLERRM); rollback; END getColoresUmbrales;
Could someone help us please?fsanchezherrero wrote:
the need for a procedure is because to get the color, it is necessary to call the strored function.It doesn't really sound like the design needs to be changed. A nested table is to create a child table and add foreign keys and key primaries, but behind the scenes, so you lose the possibility to 'normal' updates etc. on the child table!
Convert a standard parent-child relationship, and it will be much, much, much, much easier to deal with. No funky code required then!
-
How can you add item (object) complex "nested table"?
Hello I did some reading on * "Associative" * and * "Nested Table" * and I would like to enumerate the collection using the later version (http://www.devshed.com/c/a/Oracle/Database-Interaction-with-PLSQL-Nested-Tables/2/)
-know list "Nested Table"
However, encountered problem try to * 'EXTEND' * my nested table (add items to the complex type or OBJECT I defined, namely 'TmpHierarchyMapObjType' below) - detail as follows:
-NOTE 1: Here's how to create the type object (be well if I just say "CREATE or REPLACE TYPE TmpHierarchyMapObjType AS OBJECT (_TMP_HIERACHICAL. ROWTYPE_)"instead of having to duplicate the column definition.
CREATE OR REPLACE TYPE TmpHierarchyMapObjType AS OBJECT
(
ID numeric (19.0),.
ParentId numeric (19.0),.
ChildId numeric (19.0),.
...
TmpUID varchar2 (32),
ReferencedId numeric (19.0),.
...
);
-NOTE 2: I can't put 'TmpHierarchyMapObjType' inside the package, but it's not crucial, I guess.
Types of CREATE or REPLACE PACKAGE
AS
TYPE cursorType IS REF CURSOR;
TYPE TmpHiearchyMapTableType IS TABLE OF THE TmpHierarchyMapObjType; / * Use 'Nested Table' instead of an associative array * /.
/ * TYPE TmpHiearchyMapTableType IS TABLE OF THE TMP_HIERARCHYMAP % ROWTYPE INDEX DIRECTORY. */
END;
-NOTE 3: Here is my FUNCTION TABLE that now returns a "Nested Table" as assumed to 'Associative' (with a syntax different enumeration)
FUNCTION to CREATE or REPLACE spGetParentsTable
(
Number to the ObjectId,
ObjectClassifier varchar2
)
RETURN types . TmpHiearchyMapTableType -now a 'Nested Table', not 'voluntary '.
IS
Types of TmpHierarchyMap. TmpHiearchyMapTableType;
ThisTempId varchar2 (32);
CURSOR spGetParents_cursor IS
SELECT
ReferencedId Id,
ParentId,
ChildId,
...
OF TMP_HIERARCHYMAP
WHERE TmpUID = ThisTempId;
BEGIN
SELECT sys_guid() IN the double ThisTempId;
spRecursiveGetParents (ObjectId, ObjectClassifier, ThisTempId);
-(Commentary) TmpHierarchyMapMAX: = 0;
FOR oMap in spGetParents_cursor LOOP
-(Commented out) TmpHierarchyMapMAX: = TmpHierarchyMapMAX + 1;
-QUESTION: FAILED here! How can I add/elements of complex types?
TmpHierarchyMap.EXTEND (cast (oMap as TmpHierarchyMapObjType));
/*
NOTE: (In the comment) use is not "Associative", now using "nested table" instead.
TmpHierarchyMap (TmpHierarchyMapMAX). ID: = oMap.Id;
TmpHierarchyMap (TmpHierarchyMapMAX). ParentId: = oMap.ParentId;
TmpHierarchyMap (TmpHierarchyMapMAX). ChildId: = oMap.ChildId;
...
*/
END LOOP;
DELETE FROM TMP_HIERARCHYMAP WHERE TmpUID = ThisTempId;
RETURN TmpHierarchyMap;
END spGetParentsTable;
-Finally, I would like to enumerate the nested table.
DECLARE
types of oMappingTable. TmpHiearchyMapTableType;
BEGIN
oMappingTable: = spGetParentsTable(2,'ThinkFundamentals.Util.Security.SystemUser');
-NOTE 4: this is my final goal!
Select * from table (cast (oMappingtable as types.) TmpHiearchyMapTableType));
dbms_output.put_line ('done!');
END;
REF:
http://download.Oracle.com/docs/CD/B19306_01/AppDev.102/b14261/Collections.htm#LNPLS005
http://www.DevShed.com/c/a/Oracle/associative-arrays-in-Oracle-PLSQL-introduction/2/
http://www.DevShed.com/c/a/Oracle/database-interaction-with-PLSQL-nested-tables/2/Hello
Try this,
TmpHierarchyMap.Extend(); TmpHierarchyMap(TmpHierarchyMap.Count) := TmpHierarchyMapObjType( oMap.Id , oMap.ParentId , ... );
Kind regards
Christian Balz
-
insertion in a nested table of pl/sql
worm 10.2.0.3
I know that I can do this in the example with a big collect but in the 'real' code, I have to be inserted...
My question is how to insert in a nested table of pl/sql?
I know that could do a select master, object_name, object_type bulk collect in coll but I do an insert for some reason as long as I can go in... anyway to do it?create or replace type all_obj_obj as object(owner varchar2(30),object_name varchar2(30),object_type varchar2(30)) / create or replace type all_obj_list as table of all_obj_obj / declare coll all_obj_list := all_obj_list(); begin insert into table(coll) select owner,object_name,object_type from all_objects; end; /
Your "nested table" is not a "nested table" but a collection, a varable.
Obviously so can not INSERT in a memory structure.
Your need is not supposed, as BULK COLLECT would do the tric.
As you cannot disclose why you ' need; for this (you do not have) and also do not mention a version, as you ' assume; PL/SQL does not ever change or everyone uses the same version, no additional help is possible.-----
Sybrand Bakker
Senior Oracle DBA -
Hello
I tried to create a function that might return the type that is created on the outside.
So I wrote script below. until the function created it compiled successfully, but after that, when the data querying, we encountered error,
"ORA-22907: invalid CAST to a type that is not a nested table or VARRAY.
SQL> create table emp 2 ( 3 ename varchar2(200 byte), 4 mgr number, 5 employee_id number 6 ); Table created. SQL> insert into emp (ename, mgr, employee_id) 2 values ('king', 12, 1); 1 row created. SQL> insert into emp (ename, mgr, employee_id) 2 values ('clark', 12, 2); 1 row created. SQL> commit; Commit complete. SQL> create or replace type t_emp as object (ename varchar2 (200), mgr number, employee_id number); 2 / Type created. SQL> create or replace function f_emp return t_emp 2 is 3 type rc_emp is ref cursor; 4 r_emp rc_emp; 5 v_emp t_emp; 6 begin 7 open r_emp for select * from emp where rownum=1; 8 fetch r_emp into v_emp; 9 close r_emp; 10 return v_emp; 11 exception 12 when others then 13 dbms_output.put_line(dbms_utility.format_error_stack); 14 dbms_output.put_line(dbms_utility.format_call_stack); 15 dbms_output.put_line(dbms_utility.format_error_backtrace); 16 raise_application_error(-20001,sqlerrm); 17 end; 18 / Function created. SQL> show errors; No errors. SQL> select * from f_emp; select * from f_emp * ERROR at line 1: ORA-04044: procedure, function, package, or type is not allowed here SQL> select * from table(cast (f_emp as t_emp)); select * from table(cast (f_emp as t_emp)) * ERROR at line 1: ORA-22907: invalid CAST to a type that is not a nested table or VARRAY SQL>
Like this:
...
CREATE or REPLACE TYPE t_emp_array IS TABLE OF THE t_emp;
/
FUNCTION to CREATE or REPLACE f_emp RETURN t_emp_array
is
type rc_emp is ref cursor;
r_emp rc_emp;
v_emp_array t_emp_array: = t_emp_array();
BEGIN
R_emp OPEN for SELECT t_emp(ename,mgr,employee_id) FROM emp WHERE ROWNUM = 1;
collect the fetch r_emp in bulk in v_emp_array;
CLOSE R_emp;
Return v_emp_array;
exception
while others then
dbms_output.put_line (dbms_utility.format_error_stack);
dbms_output.put_line (dbms_utility.format_call_stack);
dbms_output.put_line (dbms_utility.format_error_backtrace);
raise_application_error (-20001, SQLERRM);
end;
/
SELECT *.
table (f_emp ());
a table function works with a table (nested table or varray)
HTH
-
Need help - multilevel nested table - create table problem
Hello
My version of oracle db: 11g
I just created a table that contains a nested multi-level table.
Here is the code:
create or replace type sdef_t_nt_empNames21 is table of the varchar2 (50);
create or replace type sdef_ot_SCmarks21 as an object (number of physics, chemistry number, number of Biology);
create or replace type sdef_t_nt_SCmarks21 is table of the sdef_ot_SCmarks21;
create or replace type sdef_ot_allsubmarks21 as an object (eid, eng, math, sc sdef_t_nt_SCmarks21 number number);
create or replace type sdef_t_nt_dep_m_info21 is table of the sdef_ot_allsubmarks21;
create the table nt_dep21
(number of fact
, dname varchar2 (50)
c_sdef_t_nt_empNames21 sdef_t_nt_empNames21
c_sdef_t_nt_dep_m_info21 sdef_t_nt_dep_m_info21)
nested as NT_c_sdef_t_nt_empNames21 table c_sdef_t_nt_empNames21 store
store table nested like NT_c_sdef_t_nt_dep_m_info21; c_sdef_t_nt_dep_m_info21 <-I know that the problem is here.
TRACE OF THE ERROR:
Error at startup on line: 13 in the command.
create the table nt_dep21
(number of fact
, dname varchar2 (50)
c_sdef_t_nt_empNames21 sdef_t_nt_empNames21
c_sdef_t_nt_dep_m_info21 sdef_t_nt_dep_m_info21)
nested as NT_c_sdef_t_nt_empNames21 table c_sdef_t_nt_empNames21 store
Nested table c_sdef_t_nt_dep_m_info21 (sdef_t_nt_SCmarks21) store as NT_c_sdef_t_nt_dep_m_info21
Error report-
SQL error: ORA-00904: invalid identifier
00904, 00000 - '% s: invalid identifier '.
* Cause:
* Action:
PS: I'm just solve a problem given to me by some1, is not a practical implementation, I'm just trying to get through
I'm sure that some1 could help me with this, I have searched a lot of this problem but could not find my answer, please help me.
Concerning
Rahul
SQL > create table (nt_dep21)
Did number 2,
3 dname varchar2 (50).
4 c_sdef_t_nt_empNames21 sdef_t_nt_empNames21,
c_sdef_t_nt_dep_m_info21 5 sdef_t_nt_dep_m_info21
6 )
store c_sdef_t_nt_empNames21 7 nested as NT_c_sdef_t_nt_empNames21 table
store c_sdef_t_nt_dep_m_info21 8 table nested as NT_c_sdef_t_nt_dep_m_info21)
9 table nested as NT_sc sc store
10 )
11.Table created.
SQL >
SY.
-
How to fill the value in the nested table by using the object type
Hi gurusI created an object type and able to fill the values in it, now I want to create a nested table type of this object and fill it but looks like I'm doing something wrong, see my code below.
Code example
CREATE or REPLACE TYPE countries_o
AS
OBJECT
(
COUNTRY_ID TANK (2 BYTES),
COUNTRY_NAME VARCHAR2 (40 BYTE),
REGION_ID NUMBER);
/create or replace type countries_t is table of the countries_o;
/CREATE OR REPLACE
ABC of the PROCEDURE
IS
v_print countries_t; -: = arr_countries_t('01','Aus',1);
BEGIN
v_print: = countries_t('01','A',11);
DBMS_OUTPUT. Put_line (v_print. COUNTRY_ID | v_print. COUNTRY_NAME | v_print. REGION_ID);
END;
/
Error
- Error (6.3): PL/SQL: statement ignored
- Error (6,12): PLS-00306: wrong number or types of arguments in the call to 'COUNTRIES_T '.
- Error (7.3): PL/SQL: statement ignored
- Error (7.32): PLS-00302: component 'COUNTRY_ID' must be declared
Thanks in advance
Concerning
Muzz
Hi user,
Here is another method that you can try-
CREATE OR REPLACE
ABC of the PROCEDURE
IS
v_print countries_t: = countries_t (countries_o('01','A',11));
BEGIN
DBMS_OUTPUT. Put_line (v_print (1).) COUNTRY_ID | v_print (1). COUNTRY_NAME | v_print (1). REGION_ID); -you're accessinf the first element of the nested table, which in turn points to the object.
END;
In the sections of the declaration you have assigned values to the nested table.
Kind regards
Maxou - Error (6.3): PL/SQL: statement ignored
Maybe you are looking for
-
"Error loading operating sytem!" on Satellite A55
I'm going to reformat Toshiba Satellite A55 Series for Windows XP. It is said that he cannot reformat the C drive and HDD may be damaged and to quit smoking just press F3, and then I press F3.But it said "error loading operation of the sytem! What sh
-
Installation Windows 10 IoT Core through NOOBS raspberry
Hello I tried to install Windows 10 IoT Core Raspberry Pi 3 through NOOBS. I have selected the ITO 10 Windows in the list, enter my credentials and let it work. It is downloaded Windows and restarted. Now, it displays "Welcome to Windows 10 IoT Core
-
Hello. I'm here to grace you all with yet another question v570. It's really self-locking me this machine has so many problems. I have fixed just the matter of EgisTech, where the unit would get hung up and please wait. Now it won't even turn. Light,
-
How to record the code signing keys
Hi I'm luis I'm trying to register, but I got an error In Eclipse the BlackBerry SDK tools Carpet > Bar signatory. does not appear. I use the eclipse plugin Thank you.
-
I've received just a 8766C Pavilion and wanted to set up for my grandchildren. She has windows Millennium Edition. CAN I have and what I have to do. At the present time they feel hopeless. Laughing out loud