on 2020 May 15 8:10 AM
Why I can't write an IF STATEMENT / TRIGGER EVENT STATEMENT within a WHILE LOOP?
My Script looks like this:
while (1=1)
begin
trigger event MYEVENT;
waitfor delay 50;
load into table TABLE1 from 'C:\\Temp\\2020.CSV' DELIMITED BY ';' quote '"' skip 1
if exists (select * from TABLE1 except select * from TABLE2) then
insert into exporterrorlogs (exportstatus) values ('NOK');else
insert into exporterrorlogs (exportstatus) values ('OK');end if;
end
The same applies if I try to use LOOP statement instead of WHILE END.
Which alternative do I have in order to write a conditional statement within an endless loop?
Any Ideas? Thanks in advance
WHILE you are mixing Watcom-SQL and Transact-SQL syntax LOOP errors may show up; END LOOP;
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Have you tried to use the Watcom-SQL WHILE/LOOP/END LOOP syntax? - For an overview, see here.
Aside: You have not told what the error is, so I don't know whether this is due to dialects - but mixing both dialects surely is error-prone and sometimes leads to rather meaningless resp. irritating error messages.
The issue is that Watcom dialect, WHILE is a clause of the LOOP statement.
If a statement is TSQL, it is identified as such. See http://dcx.sap.com/index.html#sqla170/en/html/817adec96ce21014abeedc732b220dbe.html
In the case of the WHILE statement that you used, the statement is titled as WHILE statement [T-SQL].
Just to add: Watcom-SQL is the name of SQL Anywhere's native SQL dialect, so unless otherwise noted, all documented SQL statements belong to this dialect.
In contrast, SQL Anywhere also supports a subset of the Transact-SQL dialect (T-SQL), as used by ASE and MS SQL Server. Those statements are generally marked as such, see Chris's comment.
And while (pun intended) you can use both dialects in the same database connection, you cannot do so within one SQL code block, such as a stored procedure.
User | Count |
---|---|
71 | |
11 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.