ORA12899 - creating a function which inserts boolean parameter - oracle

I have the following function within a package:
FUNCTION FUN_GUARDAR_ENCUESTA(
P_CENCUESTA IN VARCHAR2,
P_XENCUESTA IN VARCHAR2,
P_IHOME IN NUMBER,
P_BACTIVO IN CHAR,
P_MENSAJE OUT VARCHAR2
) RETURN VARCHAR2
IS
v_codigo_error VARCHAR2(200);
BEGIN
INSERT INTO INC_ENCUESTAS(CENCUESTA, XENCUESTA, IHOME, BACTIVO)
VALUES(P_CENCUESTA, P_XENCUESTA, P_IHOME, P_BACTIVO);
p_mensaje := 'Transacción Exitosa';
v_codigo_error := '000';
RETURN v_codigo_error;
EXCEPTION
WHEN OTHERS THEN
v_codigo_error := SQLCODE;
p_mensaje := substr(SQLERRM, 1, 200);
END FUN_GUARDAR_ENCUESTA;
but, whenever I test it it just the next error:
ORA-12899: the value is too large for column
"INTRANETCORP"."INC_ENCUESTAS"."BACTIVO" (actual: 200, máximum: 1)
My table schema is this
COLUMN NAME DATA_TYPE
CENCUESTA NUMBER(8,0)
XENCUESTA VARCHAR2(255 BYTE)
IHOME VARCHAR2(5 BYTE)
BACTIVO CHAR(1 BYTE)
I'm passing 0 as a value using a callableStatement with this query string
String query = "{ ? = call PKG_ENC_UTIL.FUN_GUARDAR_ENCUESTA()}";

Related

How call a procedure with a TYPE RECORD?

I did a data insertion procedure in a package and I want to use it together with a RECORD TYPE but I don't know what to call it.
I want to at least be able to enter 'codigo' with the other values in null
CREATE TABLE TB_CRUD_MAC"
( "K_CODIGO" NUMBER(10,0),
"A_NUMNIT" VARCHAR2(11 BYTE),
"N_NOMBRE" VARCHAR2(11 BYTE),
"N_APELLI" VARCHAR2(11 BYTE),
"F_FECHA" DATE,
"I_ESTADO" VARCHAR2(1 BYTE),
"K_CLASIF" VARCHAR2(1 BYTE) )
create or replace PACKAGE PK_CRUD_MAC AS
TYPE R_REGISTRO IS RECORD (
codigo TB_CRUD_MAC.K_CODIGO%TYPE,
numnit TB_CRUD_MAC.A_NUMNIT%TYPE,
nombre TB_CRUD_MAC.N_NOMBRE%TYPE,
apelli TB_CRUD_MAC.N_APELLI%TYPE,
fecha TB_CRUD_MAC.F_FECHA%TYPE,
estado TB_CRUD_MAC.I_ESTADO%TYPE,
clasif TB_CRUD_MAC.K_CLASIF%TYPE
);
PROCEDURE PR_INSERT_REGISTRO (P_R_REGISTRO R_REGISTRO);
END;
create or replace PACKAGE BODY PK_CRUD_MAC AS
PROCEDURE PR_INSERT_REGISTRO (P_R_REGISTRO R_REGISTRO)
IS
BEGIN
INSERT INTO TB_CRUD_MAC VALUES P_R_REGISTRO;
END;
END;
Yeah, you cannot do that. You have to pass in a complete record, example:
declare
reg PK_CRUD_MAC.R_REGISTRO;
begin
reg.codigo := 6;
PK_CRUD_MAC.PR_INSERT_REGISTRO(reg);
end;
However, if all you are trying to do is insert the record with the same type as the table column definitions, you do not need to create your own pl/sql record. You can do as below:
create or replace PACKAGE PK_CRUD_MAC2 AS
PROCEDURE PR_INSERT_REGISTRO (P_R_REGISTRO TB_CRUD_MAC%ROWTYPE);
END;
create or replace PACKAGE BODY PK_CRUD_MAC2 AS
PROCEDURE PR_INSERT_REGISTRO (P_R_REGISTRO TB_CRUD_MAC%ROWTYPE)
IS
BEGIN
INSERT INTO TB_CRUD_MAC VALUES P_R_REGISTRO;
END;
END;
You CANNOT do what you are attempting, at least the way you are attempting. You have defined you procedure as taking a record structure as input variable but then calling it with a single value. That is the wrong type error you get.
You can however overload the procedure in the package.
create or replace package pk_crud_mac as
type r_registro is record (
codigo tb_crud_mac.k_codigo%type,
numnit tb_crud_mac.a_numnit%type,
nombre tb_crud_mac.n_nombre%type,
apelli tb_crud_mac.n_apelli%type,
fecha tb_crud_mac.f_fecha%type,
estado tb_crud_mac.i_estado%type,
clasif tb_crud_mac.k_clasif%type
);
procedure pr_insert_registro (p_r_registro r_registro);
procedure pr_insert_registro (codigo tb_crud_mac.k_codigo%type);
end;
create or replace package body pk_crud_mac as
procedure pr_insert_registro (p_r_registro r_registro)
is
begin
insert into tb_crud_mac values p_r_registro;
end;
procedure pr_insert_registro (p_codigo tb_crud_mac.k_codigo%type)
is
begin
insert into tb_crud_mac values (p_codigo);
end;
end;
Add a function as a constructor that will initialize your record. Define all parameters as optional. And call. For example
create table TB_CRUD_MAC(
K_CODIGO number(10)
,A_NUMNIT varchar2(11)
,N_NOMBRE varchar2(11)
,N_APELLI varchar2(11)
,F_FECHA date
,I_ESTADO varchar2(1)
,K_CLASIF varchar2(1)
);
create or replace package PK_CRUD_MAC
is
subtype R_REGISTRO is TB_CRUD_MAC%rowtype;
function New (pK_CODIGO TB_CRUD_MAC.K_CODIGO%type := null
,pA_NUMNIT TB_CRUD_MAC.A_NUMNIT%type := null
,pN_NOMBRE TB_CRUD_MAC.N_NOMBRE%type := null
,pN_APELLI TB_CRUD_MAC.N_APELLI%type := null
,pF_FECHA TB_CRUD_MAC.F_FECHA%type := null
,pI_ESTADO TB_CRUD_MAC.I_ESTADO%type := null
,pK_CLASIF TB_CRUD_MAC.K_CLASIF%type := null) return R_REGISTRO;
procedure PR_INSERT_REGISTRO (P_R_REGISTRO R_REGISTRO);
end;
/
create or replace package body PK_CRUD_MAC
is
function New (pK_CODIGO TB_CRUD_MAC.K_CODIGO%type := null
,pA_NUMNIT TB_CRUD_MAC.A_NUMNIT%type := null
,pN_NOMBRE TB_CRUD_MAC.N_NOMBRE%type := null
,pN_APELLI TB_CRUD_MAC.N_APELLI%type := null
,pF_FECHA TB_CRUD_MAC.F_FECHA%type := null
,pI_ESTADO TB_CRUD_MAC.I_ESTADO%type := null
,pK_CLASIF TB_CRUD_MAC.K_CLASIF%type := null) return R_REGISTRO
is
vR_REGISTRO R_REGISTRO;
begin
vR_REGISTRO.K_CODIGO := pK_CODIGO;
vR_REGISTRO.A_NUMNIT := pA_NUMNIT;
vR_REGISTRO.N_NOMBRE := pN_NOMBRE;
vR_REGISTRO.N_APELLI := pN_APELLI;
vR_REGISTRO.F_FECHA := pF_FECHA ;
vR_REGISTRO.I_ESTADO := pI_ESTADO;
vR_REGISTRO.K_CLASIF := pK_CLASIF;
return vR_REGISTRO;
end;
procedure PR_INSERT_REGISTRO (P_R_REGISTRO R_REGISTRO)
is
begin
insert into TB_CRUD_MAC values P_R_REGISTRO;
end;
end;
/
begin
PK_CRUD_MAC.PR_INSERT_REGISTRO(PK_CRUD_MAC.New(pK_CODIGO => :K_CODIGO));
-- commit;
end;
/

Invalid identifier error for v_MONTH in dynamic query

I'm running following procedure inside a package to post entries in table ledger_stat_dly.
I've written dynamic query to replace case statements but I am facing following error.
Could you please suggest why V_Month is invalid identifier error popping up while it is defined properly in procedure.
Thanks in advance for help.
Error is:
ORA-00904: "V_MONTH": invalid identifier
(
V_IDENTITY_CODE NUMBER,
V_CONSOLIDATION_CD NUMBER,
V_FINANCIAL_ELEM_ID NUMBER,
V_ORG_UNIT_ID NUMBER,
V_GL_ACCOUNT_ID NUMBER,
V_COMMON_COA_ID NUMBER,
V_PRODUCT_1_ID NUMBER,
V_PRODUCT_ID NUMBER,
V_PRODUCT_3_ID NUMBER,
V_DATE DATE,
V_AMOUNT NUMBER,
V_MEMO_GL_ACCOUNT_ID NUMBER DEFAULT 0,
V_POSTINGTYPE CHAR DEFAULT 'N',
V_BALANCE_TYPE_CD NUMBER DEFAULT 0
)
IS
V_CNT NUMBER;
V_MONTH CHAR(2);
V_MO NUMBER;
V_YEAR_S NUMBER;
-- variables store result of dynamic cursor
V_SL VARCHAR2(2500);
V_TARGET_COLUMN VARCHAR2(6 CHAR);
BEGIN
IF V_POSTINGTYPE = 'N' THEN
IF NVL(V_AMOUNT,0) <> 0 THEN
V_MO := (MONTH(V_DATE));
V_MONTH := LPAD(V_MO,2,'0');
V_YEAR_S := (YEAR(V_DATE));
V_TARGET_COLUMN := CONCAT('DAY_',LPAD(TO_CHAR(DAY(V_DATE)),2,'0'));
EXECUTE IMMEDIATE UTL_LMS.FORMAT_MESSAGE('UPDATE /*+ index(a LEDGER_STAT_DLY_IDX02_IN) */ LEDGER_STAT_DLY A
SET %s = NVL(%s,0) + NVL(V_AMOUNT,0)
WHERE IDENTITY_CODE = NVL(V_IDENTITY_CODE,0)
AND YEAR_S = NVL(V_YEAR_S,0)
AND MONTH_NO = NVL(V_MONTH,0)',V_TARGET_COLUMN, V_TARGET_COLUMN);
END IF;
END IF; --CLOSURE FOR POSTING TYPE IF STATEMENT
END IN_LEDGER_STAT_DAILY;
Because you composed the SQL statement as a string the PLSQL engine does NOT substituted for the variable name (their just part of a literal string), therefore the SQL engine sees the string 'V_MONTH' but there is no column by that name thus invalid identifier. If you stay with dynamic SQL you'll have to do value substitution yourself. The same also applies to the other variables. So:
EXECUTE IMMEDIATE UTL_LMS.FORMAT_MESSAGE(
'UPDATE /*+ index(a LEDGER_STAT_DLY_IDX02_IN) */ LEDGER_STAT_DLY A
SET %s = NVL(%s,0) + NVL(%s ,0)
WHERE IDENTITY_CODE = NVL(%s ,0)
AND YEAR_S = NVL(%s ,0)
AND MONTH_NO = NVL(%s ,0)'
,V_TARGET_COLUMN, V_TARGET_COLUMN ,V_AMOUNT,V_IDENTITY_CODE,V_YEAR_S,V_MONTH);
You may also need to do any necessary format conversions.

Inserting procedure - value in an interval

I need help with the following:
I have the following table:
CREATE TABLE LOG_PUSH_READOUTS_HEADERS
(
ID NUMBER NOT NULL,
PUSH_DATE DATE NOT NULL,
SOURCE_SERIAL VARCHAR2(100) NOT NULL,
SOURCE_START_DATE DATE NOT NULL,
SOURCE_END_DATE DATE NOT NULL,
SOURCE_RUS_TYPE_ID NUMBER,
OUTPUT_SERIAL VARCHAR2(100) NOT NULL,
FILTERS_RUS VARCHAR2(100),
FILTERS_INDICATORS VARCHAR2(100),
CONSTRAINT id_pk PRIMARY KEY (ID)
);
I need to implement the following procedure:
Input parameters for inserting in a table are all columns except ID for which we need to create a sequencer. Output parameters are ID and RESULT_CODE. ID is a value of primary key that is inserted. RESULT_CODE is zero if procedure is successful, or some value in an interval 9000-9999. Use RESULT_CODE for errors, for example, RESULT_CODE 9123 is 'FILTER_RUS cannot be null.'
Here is my attempt:
CREATE OR REPLACE PROCEDURE INSERT_HEADER
(PUSH_DATE IN DATE, SOURCE_SERIAL IN VARCHAR2, SOURCE_START_DATE IN DATE, SOURCE_END_DATE IN DATE, SOURCE_RUS_TYPE_ID IN NUMBER,
OUTPUT_SERIAL IN VARCHAR2, FILTERS_RUS IN VARCHAR2, FILTERS_INDICATORS IN VARCHAR2, ID OUT NUMBER, RESULT_CODE OUT NUMBER)
IS
hd_seq NUMBER;
BEGIN
SELECT AMM_MDM.Header_Seq.NEXTVAL INTO hd_seq FROM DUAL;
ID:=hd_seq;
INSERT INTO AMM_MDM.LOG_PUSH_READOUTS_HEADERS (PUSH_DATE IN DATE, SOURCE_SERIAL IN VARCHAR2, SOURCE_START_DATE IN DATE,
SOURCE_END_DATE IN DATE, SOURCE_RUS_TYPE_ID IN NUMBER,
OUTPUT_SERIAL IN VARCHAR2, FILTERS_RUS IN VARCHAR2, FILTERS_INDICATORS IN VARCHAR2)
VALUES (PUSH_DATE, SOURCE_SERIAL, SOURCE_START_DATE,
SOURCE_END_DATE, SOURCE_RUS_TYPE_ID,
OUTPUT_SERIAL, FILTERS_RUS, FILTERS_INDICATORS)
END;
How to set RESULT_CODE in an interval 9000-9999? How to manage errors?
The way I understood the question, it would be like the following example. I shortened column list (didn't feel like tying that much), but you should be able to get the general idea.
create or replace procedure p_insert_header
(p_push_date in date,
p_source_serial in varchar2,
p_filter_rus in varchar2,
--
p_id out number,
p_result_code out number
)
is
l_id number;
begin
-- check for errors
if p_push_date is null then
p_result_code := 1234;
elsif p_source_serial not in ('A', 'B', 'C') then
p_result_code := 5532;
elsif p_filter_rus is null then
p_result_code := 9123;
end if;
-- if there are no errors, do insert
if p_result_code is null then
-- fetch sequence number
p_id := header_seq.nextval;
insert into log_push_readouts_headers
(id, push_date, source_serial, filter_rus)
values
(p_id, p_push_date, p_source_serial, p_filter_rus);
end if;
end;
At the end, once the procedure finishes, it'll return - as OUT parameters:
ID:
some sequence number, if everything was OK
NULL, if it was not
RESULT_CODE:
NULL, if everything was OK
error number, if it was not
For user defined errors, Oracle permits negative integers in the range -20000 .. -20999. You need to remove data type declarations for the column list of the insert statement
CREATE OR REPLACE PROCEDURE INSERT_HEADER(PUSH_DATE IN DATE,
SOURCE_SERIAL IN VARCHAR2,
SOURCE_START_DATE IN DATE,
SOURCE_END_DATE IN DATE,
SOURCE_RUS_TYPE_ID IN NUMBER,
OUTPUT_SERIAL IN VARCHAR2,
FILTERS_RUS IN VARCHAR2,
FILTERS_INDICATORS IN VARCHAR2,
ID OUT NUMBER,
RESULT_CODE OUT NUMBER)
IS
BEGIN
INSERT INTO LOG_PUSH_READOUTS_HEADERS
(ID,
PUSH_DATE,
SOURCE_SERIAL,
SOURCE_START_DATE,
SOURCE_END_DATE,
SOURCE_RUS_TYPE_ID,
OUTPUT_SERIAL,
FILTERS_RUS,
FILTERS_INDICATORS)
VALUES
(Header_Seq.NEXTVAL,
PUSH_DATE,
SOURCE_SERIAL,
SOURCE_START_DATE,
SOURCE_END_DATE,
SOURCE_RUS_TYPE_ID,
OUTPUT_SERIAL,
FILTERS_RUS,
FILTERS_INDICATORS);
--Suppose some opertions performed and gave the RESULT_CODE value below
RESULT_CODE := 20123;
IF RESULT_CODE = 20123 THEN raise_application_error(-RESULT_CODE, 'FILTER_RUS cannot be null');
--ELSIF RESULT_CODE = 20124 THEN raise_application_error(-RESULT_CODE, 'Some other message 1');
--ELSIF RESULT_CODE = 20125 THEN raise_application_error(-RESULT_CODE, 'Some other message 2');
END IF;
END;
In this case it hurls with the message : FILTER_RUS cannot be null

Oracle select count(*) into n generates ORA-01401 inserted value too large for column

I have spent hours tracking down the source of this bug and am stumped. I managed to determine that the below simple select statement was the problem (comment and not error.. so yes, it's the cause). n was initially defined as a number, I tried integer as well for grins.
n integer;
n := 1;
select count(*) into n
from category
where (
upper(ltrim(rtrim(category_long_name))) = upper(ltrim(rtrim(cat_long_name)))
or
upper(ltrim(rtrim(category_short_name))) = upper(ltrim(rtrim(cat_short_name)))
or
upper(ltrim(rtrim(category_description))) = upper(ltrim(rtrim(cat_descr)))
)
and (settings_setting_id = sett_id) and (category_id <> cat_id);
When this code is executed, I get ORA-01401: inserted value too large for column. So the only "insert" is into the n value for a row count. The actual value (used debugger) is 0.
I don't understand how this could be causing a problem. I've seen this select count(*) into x code snippet in examples. The procedure runs fine with this statement commented out. The only time 'n' is used is in the next step where I raise and exception if it's > 0. I've literally commented out the entire stored procedure, leaving only this statement, and it causes the error.
My research online indicates that count(*) returns an integer.
The category table has about 50 rows in it.
What am I missing?
This is category:
"CATEGORY_ID" NUMBER(,0),
"VERSION_VERSION_ID" NUMBER(,0),
"SETTINGS_SETTING_ID" NUMBER(*,0),
"CATEGORY_LONG_NAME" CHAR(256 BYTE),
"CATEGORY_SHORT_NAME" CHAR(25 BYTE),
"CATEGORY_DESCRIPTION" VARCHAR2(4000 BYTE),
"CATEGORY_FORM_ID" CHAR(10 BYTE),
"CATEGORY_FORM_SYNONYM" CHAR(256 BYTE),
"CATEGORY_GUIDE_FOR_USE" VARCHAR2(4000 BYTE),
"CATEGORY_COMMENTS" VARCHAR2(4000 BYTE),
"CATEGORY_EFFECTIVE_DATE" DATE,
"CATEGORY_UNTIL_DATE" DATE,
"CATEGORY_CREATOR" CHAR(50 BYTE),
"CATEGORY_ADMIN_STATUS" CHAR(25 BYTE),
"CATEGORY_ADMIN_STATUS_DATE" DATE,
"CATEGORY_REGISTR_STATUS" CHAR(25 BYTE),
"CATEGORY_REGISTR_STATUS_DATE" DATE,
"CATEGORY_STATUS" VARCHAR2(10 BYTE),
"CATEGORY_STATUS_JUST" VARCHAR2(2000 BYTE),
"CATEGORY_TYPE" NUMBER
There was some other stuff around the code snippet I sent so I created a new stored procedure where I assigned the values that would be passed as parameters (the variables I set in the debugger). I still get the ORA-01401 on the select count(*) into N line.
The issues goes away when I comment out the where clause.
create or replace PROCEDURE PROCEDURE1
IS
CATEGORY_NAME_EXISTS Exception;
WRONG_ACTION_PARAM Exception;
WRONG_PARAM_SET Exception;
NO_JUSTIFICATION Exception;
VERSION_PERSISTENT Exception;
CANNOT_APPROVE Exception;
VERSION_SETTING_NEEDED Exception;
n number :=1;
msg1 nvarchar2(2000);
curr_status nvarchar2(10);
curr_persistent number;
curr_sett_status nvarchar2(10);
update_with_hierarchy nvarchar2(3);
sql_txt nvarchar2(1000);
err_num number;
err_msg varchar2(200);
CAT_LONG_NAME nvarchar2(1000) := 'Administrative';
CAT_SHORT_NAME nvarchar2(1000) := 'Administrative';
CAT_DESCR nvarchar2(1000) := 'Admin form';
SETT_ID number := 2;
CAT_ID number := 13;
categORy_long_name nvarchar2(1000);
categORy_shORt_name nvarchar2(1000);
categORy_description nvarchar2(1000);
settings_setting_id number;
categORy_id number;
BEGIN
SELECT COUNT(*) INTO n
FROM categORy
WHERE
(
UPPER(LTRIM(RTRIM(categORy_long_name))) = UPPER(LTRIM(RTRIM(cat_long_name)))
OR
UPPER(LTRIM(RTRIM(categORy_shORt_name))) = UPPER(LTRIM(RTRIM(cat_shORt_name)))
OR
UPPER(LTRIM(RTRIM(categORy_description))) = UPPER(LTRIM(RTRIM(cat_descr)))
)
AND (settings_setting_id = sett_id) and (categORy_id <> cat_id)
;
END;
Try this:
DECLARE
n number := 1;
BEGIN
SELECT COUNT(*) INTO n
FROM categORy
WHERE
(
UPPER(LTRIM(RTRIM(categORy_long_name))) = UPPER(LTRIM(RTRIM(cat_long_name)))
OR
UPPER(LTRIM(RTRIM(categORy_shORt_name))) = UPPER(LTRIM(RTRIM(cat_shORt_name)))
OR
UPPER(LTRIM(RTRIM(categORy_description))) = UPPER(LTRIM(RTRIM(cat_descr)))
)
AND (settings_setting_id = sett_id) and (categORy_id <> cat_id);
END;

Table variable as in parameter to populate a table in oracle Stored procedure

Mostly I avoid table variables as input parameters for a stored procedure. Because I do not know how to handle them, but in this case I have no other option. I have a requirement where hundreds of records will be passed on to database from Oracle Agile PLM. What I have to do is to populate a table from the input records/list. For accomplishing this I have developed an object type and then a table type out of that object type.
CREATE OR REPLACE TYPE TEST_USER.MD_TYPE AS OBJECT
(QUERY_REF VARCHAR2 (1000 BYTE),
COL_NAME VARCHAR2 (100 BYTE),
COL_LENGTH VARCHAR2 (50 BYTE),
COL_SEQ NUMBER)
/
CREATE OR REPLACE TYPE TEST_USER.MD_TYPE_TABLE AS TABLE OF MD_TYPE
/
Stored Procedure:
CREATE OR REPLACE PROCEDURE SP_TEST2
(
P_MD_TABLE IN MD_TYPE_TABLE,
p_success OUT number
)
IS
BEGIN
INSERT INTO MDATA_TABLE
(
QUERY_REF ,
COL_NAME ,
COL_LENGTH ,
COL_SEQ
)
SELECT ea.*
FROM TABLE(P_MD_TABLE) ea;
p_success :=1;
EXCEPTION
WHEN OTHERS THEN
p_success := -1;
END SP_TEST2;
The problem is I do not know how to populate, first parameter P_MD_TABLE and then MDATA_TABLE. And the procedure compiles without any errors. I have not tested this procedure.
Any help please.
Procedure for loading MD_TYPE_TABLE by passing parameters to MD_TYPE
CREATE OR REPLACE PROCEDURE SP_UPLOAD_MD_TYPE
(
P_QUERY_REF VARCHAR2,
P_COL_NAME VARCHAR2,
P_COL_LENGTH VARCHAR2,
p_col_seq NUMBER,
p_no_of_rows_to_insert NUMBER,
p_num OUT NUMBER
)
IS
p_type_tbl MD_TYPE_TABLE := MD_TYPE_TABLE(); --initialize
BEGIN
<<vartype>>
FOR i IN 1..p_no_of_rows_to_insert
LOOP
p_type_tbl.extend();
p_type_tbl(p_type_tbl.last) := MD_TYPE(P_QUERY_REF, P_COL_NAME, P_COL_LENGTH, p_col_seq);
END LOOP vartype;
SP_TEST2(p_type_tbl, p_num);
END;
You can populate a table type by using extend/ bulk collect
using extend
p_type_tbl.extend();
p_type_tbl(p_type_tbl.last) := MD_TYPE('QUERY_REF1', 'COL_NAME1', 'COL_LENGTH1', 1);
or using bulk collect
SELECT MD_TYPE(c1, c2... cn)
BULK COLLECT INTO p_type_tbl
FROM some_table;
Demo
DECLARE
p_type_tbl MD_TYPE_TABLE := MD_TYPE_TABLE(); --initialize
p_num NUMBER;
BEGIN
p_type_tbl.extend();
p_type_tbl(p_type_tbl.last) := MD_TYPE('QUERY_REF1', 'COL_NAME1', 'COL_LENGTH1', 1);
p_type_tbl.extend();
p_type_tbl(p_type_tbl.last) := MD_TYPE('QUERY_REF2', 'COL_NAME2', 'COL_LENGTH2', 2);
SP_TEST2(p_type_tbl, p_num);
DBMS_OUTPUT.PUT_LINE(p_num);
END;
/
OutPut
1
SELECT * FROM MDATA_TABLE;
OutPut
QUERY_REF COL_NAME COL_LENGTH COL_SEQ
QUERY_REF1 COL_NAME1 COL_LENGTH1 1
QUERY_REF2 COL_NAME2 COL_LENGTH2 2

Resources