dsd7038
09-18-2003, 12:37 PM
How can I check if table exists and if not create one else insert into table. Please advise. See example below as create command fails as expects end etc..
DECLARE
counter INTEGER := 0;
mytotal INTEGER := 0;
BEGIN
SELECT
COUNT( 1 )
INTO
counter
FROM
user_tables
WHERE
table_name like 'testing';
mytotal := mytotal + counter;
IF ( mytotal != 0 ) THEN
INSERT
INTO testing (implemented)
VALUES ('testing123');
Else
CREATE TABLE testing (
implemented varchar2 (40),
date_run date
)
TABLESPACE mytblspace;
END;
/
DECLARE
counter INTEGER := 0;
mytotal INTEGER := 0;
BEGIN
SELECT
COUNT( 1 )
INTO
counter
FROM
user_tables
WHERE
table_name like 'testing';
mytotal := mytotal + counter;
IF ( mytotal != 0 ) THEN
INSERT
INTO testing (implemented)
VALUES ('testing123');
Else
CREATE TABLE testing (
implemented varchar2 (40),
date_run date
)
TABLESPACE mytblspace;
END;
/