I wish to add a new record in my oracle database and update it if it already exists. I am using If else clause to achieve this . Below is my code :
DECLARE
any_rows_found number;
BEGIN
select count(*)
into any_rows_found
from reports
where report_id=27;
IF(any_rows_found > 1)
THEN
UPDATE reports set
TITLE = 'Check user entered keywords have valid resource link',
CATEGORY = 'zData checks',
DISPLAY_ORDER= 9120,
QUERY ='...',
CONTENT_SEQ=1,
DELD=0,
ADMIN_ID=1,
DATE_UPD = to_timestamp('05-FEB-15 01.44.53.753311000 PM','DD-MON-RR HH.MI.SS.FF AM')
WHERE REPORT_ID = 27;
ELSE
INSERT INTO reports (REPORT_ID,TITLE,CATEGORY,DISPLAY_ORDER,QUERY,DESCRIPTION,CONTENT_SEQ,DELD,ADMIN_ID,DATE_UPD)
VALUES (27,
'Check user entered keywords have valid resource link',
'zData checks',
9120,
'...',
1,
0,
1,
to_timestamp('05-FEB-15 01.44.53.753311000 PM','DD-MON-RR HH.MI.SS.FF AM'));
END IF;
This throws follosing error as seen :
PLS-00103: Encountered the symbol "end-of-file" when expecting one of the following:
( begin case declare end exception exit for goto if loop mod
null pragma raise return select update while with
<an identifier> <a double-quoted delimited-identifier>
<a bind variable> << continue close current delete fetch lock
insert open rollback savepoint set sql execute commit forall
merge pipe purge
06550. 00000 - "line %s, column %s:\n%s"
*Cause: Usually a PL/SQL compilation error.
Where am I goig wrong ? Please help. Thank you.
Aucun commentaire:
Enregistrer un commentaire