plsql

Insert into table from collection type oracle 12c - ORA-00902: invalid datatype

杀马特。学长 韩版系。学妹 提交于 2021-02-08 07:36:46
问题 I am using Oracle 12.1 I thought I can query the table types in 12c.I get error ORA-00902: invalid datatype when I try to execute this package. I even tried using cast multiset,but still same error. I know we can create object at database level and then query, but I don't want to. CREATE OR REPLACE PACKAGE test123 AS TYPE typ1 IS RECORD(col1 VARCHAR2(100),col2 VARCHAR2(100)); TYPE tab_typ IS TABLE OF typ1 INDEX BY BINARY_INTEGER; v_tab tab_typ; PROCEDURE p1; END; / CREATE OR REPLACE PACKAGE

Insert into table from collection type oracle 12c - ORA-00902: invalid datatype

隐身守侯 提交于 2021-02-08 07:36:04
问题 I am using Oracle 12.1 I thought I can query the table types in 12c.I get error ORA-00902: invalid datatype when I try to execute this package. I even tried using cast multiset,but still same error. I know we can create object at database level and then query, but I don't want to. CREATE OR REPLACE PACKAGE test123 AS TYPE typ1 IS RECORD(col1 VARCHAR2(100),col2 VARCHAR2(100)); TYPE tab_typ IS TABLE OF typ1 INDEX BY BINARY_INTEGER; v_tab tab_typ; PROCEDURE p1; END; / CREATE OR REPLACE PACKAGE

how to export data from around 300 tables in ORACLE DB to csv or txt files

廉价感情. 提交于 2021-02-08 04:48:03
问题 Is there any possibility to export data from around 300 tables within single schema with millions of records to CSV or TXT using any PL/SQL procedure? What do you propose, which is fastest way to do it? For the moment I do not need to import these exported files to any other schema... I tried with Toad manually exporting table by table... 回答1: you can try following steps. write a loop to get the table names use cursors to fetch the data from each table use SYS.UTL_FILE utilities to write the

What are some good practices of modular code?

北城余情 提交于 2021-02-08 03:58:13
问题 In PL-SQL, there are some fancy new concepts, like table functions, objects, and probably others I have not discovered yet. But then again, there is also plain simple code generation (dynamic pl-sql) that you can "execute immediately". These can help with code reuse. From what I can tell, table functions and objects can help with creating modular code, but still not enough to remove the entire of it (maybe I am not using the best of them; I have to admit my objects only contain data for now

PL/SQL referencing another cursor in a cursor?

╄→гoц情女王★ 提交于 2021-02-08 03:44:35
问题 I'd like to create a procedure that selects all records that have been assigned to any particular user, then send one personalized email to each assigned user that contains a list of the records that are assigned to them. So if myTable looks like this: ID Assigned 1 Joe 2 Joe 3 Shelly Joe's email would display a line-delimited list with records 1 and 2 in it, and Shelly's would display record 3. I started building a procedure with cursors at first, but 1) wasn't sure if I could reference a

Execute For Each Table in PLSQL

…衆ロ難τιáo~ 提交于 2021-02-07 14:26:16
问题 I want to the the number of records in all tables that match a specific name criteria. Here is the SQL I built Declare SQLStatement VARCHAR (8000) :=''; BEGIN SELECT 'SELECT COUNT (*) FROM ' || Table_Name || ';' INTO SQLStatement FROM All_Tables WHERE 1=1 AND UPPER (Table_Name) LIKE UPPER ('MSRS%'); IF SQLStatement <> '' THEN EXECUTE IMMEDIATE SQLStatement; END IF; END; / But I get the following error: Error at line 1 ORA-01422: exact fetch returns more than requested number of rows ORA-06512

Execute For Each Table in PLSQL

吃可爱长大的小学妹 提交于 2021-02-07 14:26:08
问题 I want to the the number of records in all tables that match a specific name criteria. Here is the SQL I built Declare SQLStatement VARCHAR (8000) :=''; BEGIN SELECT 'SELECT COUNT (*) FROM ' || Table_Name || ';' INTO SQLStatement FROM All_Tables WHERE 1=1 AND UPPER (Table_Name) LIKE UPPER ('MSRS%'); IF SQLStatement <> '' THEN EXECUTE IMMEDIATE SQLStatement; END IF; END; / But I get the following error: Error at line 1 ORA-01422: exact fetch returns more than requested number of rows ORA-06512

How to call a pl/sql anonymous block from an pl/sql anonymous block

荒凉一梦 提交于 2021-02-07 10:50:11
问题 I have the following PL/SQL block and it's working fine. I would like to call this function (TimeToFrame) but from another PL/SQL block. I cannot declare this function in a procedure or package that is stored in the DB. In other words how can I call a pl/sql from another pl/sql where both pl/sql are anonymous blocks?? What if I put that function in a separate .sql file. Can't I call that .sql file from my anonymous block and pass it some IN parameters and have that fct return OUT params?

Trying to get the actual data that cause an exception

杀马特。学长 韩版系。学妹 提交于 2021-02-07 10:30:26
问题 I have a procedure that takes an input of 2 Associative arrays and after some basic count checks, does a FORALL statement to insert the data into a table. Here is the procedure: PROCEDURE INSERT_RECS(P_PROD_TYP IN prod_type, P_PROD_ADD_PK IN prod_pk_type) IS uniq_key EXCEPTION; PRAGMA EXCEPTION_INIT(uniq_key, -00001); loc_cnt NUMBER; BEGIN IF P_PROD_TYP.COUNT = P_PROD_ADD_PK.COUNT THEN FORALL i IN P_PROD_TYP.FIRST .. P_PROD_TYP.LAST INSERT INTO product_table ( pk, id, created_by, created_on,

Trying to get the actual data that cause an exception

雨燕双飞 提交于 2021-02-07 10:29:25
问题 I have a procedure that takes an input of 2 Associative arrays and after some basic count checks, does a FORALL statement to insert the data into a table. Here is the procedure: PROCEDURE INSERT_RECS(P_PROD_TYP IN prod_type, P_PROD_ADD_PK IN prod_pk_type) IS uniq_key EXCEPTION; PRAGMA EXCEPTION_INIT(uniq_key, -00001); loc_cnt NUMBER; BEGIN IF P_PROD_TYP.COUNT = P_PROD_ADD_PK.COUNT THEN FORALL i IN P_PROD_TYP.FIRST .. P_PROD_TYP.LAST INSERT INTO product_table ( pk, id, created_by, created_on,