Why I can't write an IF STATEMENT / TRIGGER EVENT STATEMENT within a WHILE LOOP? My Script looks like this:
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; But is there a way to realize this bulk of watcom-sql statements in an endless loop without doing this mixing?
(15 May '20, 07:27)
Baron
Replies hidden
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.
(15 May '20, 08:16)
Volker Barth
LOL! ...very funny :)
(15 May '20, 08:22)
Breck Carter
The error is syntax error
(15 May '20, 18:35)
Baron
but how can I distinguish between those 2 dialects (watcom / Transact)? Why I cant find the "Watcom-SQL WHILE/LOOP/END Loop Syntax" in the PDF documentation of SQL Anywhere Server SQL Anywhere - SQL Reference?
(15 May '20, 18:52)
Baron
1
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].
(15 May '20, 22:35)
Chris Keating
1
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.
(16 May '20, 06:44)
Volker Barth
|
3 downvotes? Why?