on 2013 Dec 12 5:37 AM
Hi,
I have error when running the following script:
IF (select rest_name from table.rest_def) <> 'TESTING' THEN RETURN ELSE SELECT net_sls_ttl FROM table.dly_sys_ttl WHERE cast((getDate()) As Date) = cast(dly_sys_ttl.business_date As Date); OUTPUT TO 😧\\TimeCard.csv FORMAT TEXT; END IF
The error is
"Could not execute statement. Syntax error near 'OUTPUT' on line 8. SQLCODE=-131. ODBC 3 STATE="42000" Line 1 column 5"
However, there is no error if I remove the IF statement. The text file can be exported if I only run these:
SELECT net_sls_ttl FROM table.dly_sys_ttl WHERE cast((getDate()) As Date) = cast(dly_sys_ttl.business_date As Date); OUTPUT TO 😧\\TimeCard.csv FORMAT TEXT;
Please help 😞
Request clarification before answering.
OUTPUT is an ISQL command, not a SQL statement, and as such, cannot be used within procedures and code blocks - and the IF statement makes your list of statements a code block. (In contrast, your list of statements without the IF statement is not a code block, i.e. each statement is sent to the database engine each on its own (here's only one: the SELECT statement), and then DBISQL processes the OUTPUT command itself.)
Therefore you need to use the UNLOAD statement instead of OUTPUT - cf. this related question:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
9 | |
9 | |
7 | |
6 | |
6 | |
5 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.