on 2010 Oct 19 9:42 AM
I would like to use one SQL script with DDL statements like CREATE TABLE for different SA versions and use (slightly) different syntax for these different versions.
E.g. SA 10 has introduced the VALIDATE authority (and REMOTE DBA authority is no more sufficient to VALIDATE), so for SA10 and newer, the script would contain a statement like
grant validate to <Remote DBA User>;
Naturally, a pre-V10 engine won't accept this syntax and will raise an error.
My simple tests with if statements like
if @@version like '12.0%' then
grant validate to <Remote DBA User>;
end if;
do fail, as obviously the complete statement gets parsed even if the statements in the if-block won't get executed for a pre-V12 engine.
So, basically, I would like to use something like C's #ifdef/#ifdef directives for conditional compilation, i.e. a means to suppress the parsing of a script portion when a certain condition is false.
Is this possible with SQL Anyhwere and DBISQL?
Just to add: It will not be sufficient to skip such statements completely via on_error = continue. This might be sufficient in the above example, but in general the statements will have to be executed by all versions, and only particular clauses may be different.
Request clarification before answering.
EXECUTE IMMEDIATE won't throw a syntax error if it isn't executed.
( now, welcome to The World Of ''''''''Quotation Marks'''''''' 🙂
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
62 | |
7 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.