Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> PL/SQL procedure - Use of "variables"
Hi
I have a definition table (DEF) which defines which columns to get from an
input table. I am using a cursor to read from the input table (INPUT). Is
there any way to get hold of the correct data from the INPUT table?
create table DEF ( cDEFINITIONNAME Varchar2(32) not null,
nFILEFIELDNUMBER NUMBER not null, cFILEFIELDNAME Varchar2(30) not null, cTABLEFIELDNAME Varchar2(30) not null);insert into
The nFileFieldNumber is correspondent to INPUT table cValueX, here cValue3 and cValue2
Create table INPUT( nCounter number not null,
cValue1 varchar2(255) null, cValue2 varchar2(255) null, cValue3 varchar2(255) null, cValue4 varchar2(255) null, cValue5 varchar2(255) null);
id1 OUTPUT.id1%TYPE;
id2 OUTPUT.id2%TYPE;
CURSOR INDEF IS
Select * from DEF where cDEFINITIONNAME='ABC';
CURSOR Tempdata IS
SELECT * FROM INPUT; BEGIN /* I will find the columnnames to use to select from the table IN */
For Definisjon IN INNLESINGDEF LOOP
IF Definisjon.cTABLEFIELDNAME = 'Field1 to get' THEN lcID1 := 'inn.cValue'|| Definisjon.nFILEFIELDNUMBER; ELSIF Definisjon.cTABLEFIELDNAME = 'Field2 to get' THEN lcID2 := 'inn.cValue'|| Definisjon.nFILEFIELDNUMBER; END IF;
For inn IN TEMPDATA LOOP
BEGIN
/* I will not have the string 'inn.cValue1' but the value the curson
inn is pointing to of the field cValue1 */
Select field1 into lnContract from Checktable where field2=lcID1 and field3= lcID2;
/* What I want: Select field1 into lnContract from Checktable where field2=inn.cValue3 and field3= inn.cValue2;
Is This possible? The reason for doing it that way is that the inport file format may change and also be different for different types. And to only have one routine for updating the database I though of doing it this way.
Any suggestions for a solution?
Any help would be greatly appreciated Received on Sun Apr 25 2004 - 23:59:55 CDT