Skip to Content
avatar image
Former Member

Input/Output after if condition

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;

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    Mar 09, 2017 at 08:02 AM

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

    Add comment
    10|10000 characters needed characters exceeded