Let me make myself clear.
Here is my sample table and data:
Below is my procedure:Code:CREATE TABLE "SYSTEM"."MYTESTTABLE" ( "COLUMN1" VARCHAR2(1 CHAR), "COLUMN2" VARCHAR2(1 CHAR), "COLUMN3" VARCHAR2(1 CHAR), "COLUMN4" VARCHAR2(1 CHAR), "COLUMN5" VARCHAR2(1 CHAR), "COLUMN6" VARCHAR2(1 CHAR), "COLUMN7" VARCHAR2(1 CHAR), "COLUMN8" NUMBER(9,0), "ID" NUMBER(9,0) ); REM INSERTING into SYSTEM.MYTESTTABLE Insert into SYSTEM.MYTESTTABLE (COLUMN1,COLUMN2,COLUMN3,COLUMN4,COLUMN5,COLUMN6,COLUMN7,COLUMN8,ID) values ('A','B','C',null,null,null,null,3,1); Insert into SYSTEM.MYTESTTABLE (COLUMN1,COLUMN2,COLUMN3,COLUMN4,COLUMN5,COLUMN6,COLUMN7,COLUMN8,ID) values ('A','B','C','D','E','F','G',7,2);
Below is the execution script I am using:Code:create or replace procedure GetData (POS1 in varchar2 default null, POS2 in varchar2 default null, POS3 in varchar2 default null, POS4 in varchar2 default null, POS5 in varchar2 default null, POS6 in varchar2 default null, POS7 in varchar2 default null, POS8 in number) as cid number(9,0); begin select MYTESTTABLE.id into cid from MYTESTTABLE where COLUMN1 = POS1 and COLUMN2 = POS2 and COLUMN3 = POS3 and COLUMN4 = POS4 and COLUMN5 = POS5 and COLUMN6 = POS6 and COLUMN7 = POS7 and COLUMN8 = POS8; DBMS_OUTPUT.PUT_LINE(CID); end;
I am expecting the procedure to print out 1. But it is throwing a no data found exception.Code:DECLARE POS1 VARCHAR2(200); POS2 VARCHAR2(200); POS3 VARCHAR2(200); POS4 VARCHAR2(200); POS5 VARCHAR2(200); POS6 VARCHAR2(200); POS7 VARCHAR2(200); POS8 NUMBER; begin POS1 := 'A'; POS2 := 'B'; POS3 := 'C'; POS4 := null; POS5 := null; POS6 := null; POS7 := null; POS8 := 3; GETDATA( POS1 => POS1, POS2 => POS2, POS3 => POS3, POS4 => POS4, POS5 => POS5, POS6 => POS6, POS7 => POS7, POS8 => POS8 ); END;




Reply With Quote
