cancel
Showing results for 
Search instead for 
Did you mean: 

Input/Output after if condition

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;

Accepted Solutions (1)

Accepted Solutions (1)

VolkerBarth
Active Participant

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".

Former Member
0 Kudos

Thanks, very helpful

Answers (0)