Feeds:
Posts
Comments

Archive for December, 2014

If you are making production script, you might want to make sure the script generates no errors or even during development you want to run in multiple times without it will report any errors…

This is how to update a row (and make sure it does not fail if it’s not in the database), using the EXISTS function in Oracle:

UPDATE myTableName SET myColumnName=’NewValue’ WHERE myKeyValueColumn=’KeyValue’ AND EXISTS (SELECT * FROM SYST_COLUMN_DISPLAY_NAME WHERE myKeyValueColumn=’KeyValue’);

This is how to insert a new row without generating any errors even if the row already exists:

BEGIN
INSERT INTO myTableName  (‘KeyValue’, ‘NewValue’);
EXCEPTION WHEN dup_val_on_index THEN NULL; — Ignore duplicates
END;

Advertisements

Read Full Post »