SQL Server developer working on Oracle so apologies in advance if I'm fundamentally coming at this incorrectly from an Oracle perspective.
I've got a script I've written which:
- Checks ALL_SEQUENCES to see if a sequence of a given name exists
- If it doesn't creates it using EXECUTE IMMEDIATE
- Attempts to use the sequence as part of an insert
The idea is that the script can be run multiple times without modification so the person running it doesn't have to know what's in place and what's not.
My issue is that in SQL Developer if the sequence doesn't exist, the script errors on running claiming that the sequence doesn't exist. Create the sequence and the error goes away but that rather defeats the point.
What's the best way around this?