Skip to Content
1

Input/Output after if condition

Mar 08, 2017 at 06:23 PM

134

avatar image
Former Member

Why I can't write any import/export sql statement to a file inside a block of if statement?

"input into" output to" causes always syntax error as long as they are residing inside a block of if condition.

What a solution can I have against it? i.e. when I want to import from a text file into a table under a specific conditions (depending on the result of an 'select' statement).

EXAMPLE:

if exists (select COLUMN1 from TABLE1) then

input into TABLE2 from c:\FILE.TXT

end if;

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Best Answer
Volker Barth Mar 09, 2017 at 08:02 AM
1

INPUT and OUTPUT are ISQL (Interactive SQL) commands, not SQL statements. As such, they are processed by ISQL. In contrast, a SQL statement block (like your "if exists ... end if;") is processed by the database engine as whole, and that does not support INPUT/OUTPUT.

As alternative for OUTPUT, you can use the UNLOAD/UNLOAD SELECT statements. For INPUT, LOAD TABLE/OpenString() might do the job.

For further advice, you might look in the separate SAP SQL Anywhere Forum for questions dealing with "OUTPUT" and "procedure".

Show 1 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Thanks, very helpful

0