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.

asked 19 Oct '10, 08:42

Volker%20Barth's gravatar image

Volker Barth
30.8k308456665
accept rate: 32%

Comment Text Removed

Yes, I'm aware that a possible enhancement for a current SA version won't make a pre-V10 engine change its behaviour. Kind of a very "post-mortem feature request":)

(19 Oct '10, 09:21) Volker Barth

EXECUTE IMMEDIATE won't throw a syntax error if it isn't executed.

( now, welcome to The World Of ''''''''Quotation Marks'''''''' :)

permanent link

answered 19 Oct '10, 09:05

Breck%20Carter's gravatar image

Breck Carter
26.2k430599863
accept rate: 20%

Thanks for the pointer and good to know, but I guess that would make the script much more incomprehensible in my particular requirement...

(19 Oct '10, 09:19) Volker Barth

I was sure I'd posted a suggestion about "more directives" in ISQL but I can't find it... it's something I would support as long as it doesn't go CRAZY like C.

(19 Oct '10, 18:00) Breck Carter
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×90
×3

question asked: 19 Oct '10, 08:42

question was seen: 885 times

last updated: 19 Oct '10, 09:05