cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

BEGIN ... INPUT ... END

Former Member
2,553

This code works great in ISQL... version 9.0.2

INPUT into mytable (..., ....) from myfile format ascii;

But this code doesn't work at all...

BEGIN
declare @starttime timestamp;
set @starttime =current timestamp;
INPUT into mytable (..., ....) from myfile format ascii;
-- more stuff goes here
END 

The error is Syntax error near INSERT

I understand that the INSERT statement is handled by the ISQL client and not the server, but I think I need the BEGIN/END to contain the declared variables.

Any way around this?

View Entire Topic
Former Member

You could use CREATE VARIABLE to define the variables. However, they will not be dropped automatically at the end of the script, so you would need to add corresponding DROP VARIABLE statements. Also, you might want to handle the case where the script is interrupted before completion and then re-executed using the same connection. To do so, add:

if varexists('@starttime') = 0 then

create variable @starttime timestamp;

end if;

Version 12 adds CREATE OR REPLACE VARIABLE.

Former Member
0 Kudos

excellent! I'll give that a try. Thank you!