I am trying to see if a record has already been enter into table_1 (don't want redundancy). If table 1 has the data i want to enter, just add data to the second table. If Table_1 has no entry add data to table_1 and Table_2. I do a select to find out if there is a record that matches table_1 into a varible
*******
select value_1 into v_var from table_1 where service_number = value_1.
*******
I then do a if then statement
*******
if v_var is null then
INSERT INTO Table_1 VALUES (x,c,b);
END IF;
INSERT INTO table_2 VALUES (q,e,t);
COMMIT;
If the select statement does not find a row,(no rows return) the stored procedure stops and says 'no data found' If it does find data it works great and just adds data to the second table.
My question is how can I do a select statement for a value and if it is not present (no rows or none existent in the table) keeping moving down to the if-then part of the script.
This stored procedure is called through a webdb application.
JP
*******
select value_1 into v_var from table_1 where service_number = value_1.
*******
I then do a if then statement
*******
if v_var is null then
INSERT INTO Table_1 VALUES (x,c,b);
END IF;
INSERT INTO table_2 VALUES (q,e,t);
COMMIT;
If the select statement does not find a row,(no rows return) the stored procedure stops and says 'no data found' If it does find data it works great and just adds data to the second table.
My question is how can I do a select statement for a value and if it is not present (no rows or none existent in the table) keeping moving down to the if-then part of the script.
This stored procedure is called through a webdb application.
JP