I am new with Sybase. I am using below version of Sybase: Adaptive Server Enterprise/15.0.3/EBF 24162 ESD#4.
Here I am trying to run multiples queries at a single hit. I have created a perl script which will capture data from sysMonSQLText at every second. and its working fine.after completion of perl it generates test.sql file.below is the sample data of that test.sql file:
declare @start_time datetime
declare @end_time datetime
declare @row_count INT
select 'Start - Query Number: 65000'
select @start_time = getdate()
SELECT 1
select @row_count = @@rowcount
select @end_time = getdate()
if ( @@error <> 0)
BEGIN
select (" SQL was not executed successfully. Error Code: " + (SELECT CONVERT(varchar(10),@@error)))
END
Else
Begin
select ("Query number 65000 - Time took to execute the Query: " + ( SELECT CONVERT(varchar(10000), (select datediff(ss, @start_time, @end_time)) ) ) + ", number of rows retrieved: " + ( SELECT CONVERT(varchar(10000),@row_count)) + ", on " + ( SELECT CONVERT(varchar(10000),@@servername) ) )
END
select 'End - Query Number: 65000'
select 'Start - Query Number: 65001'
select @start_time = getdate()
select * from table_1
select @row_count = @@rowcount
select @end_time = getdate()
if ( @@error <> 0)
BEGIN
select (" SQL was not executed successfully. Error Code: " + (SELECT CONVERT(varchar(10),@@error)))
END
Else
Begin
select ("Query number 65001 - Time took to execute the Query: " + ( SELECT CONVERT(varchar(10000), (select datediff(ss, @start_time, @end_time)) ) ) + ", number of rows retrieved: " + ( SELECT CONVERT(varchar(10000),@row_count)) + ", on " + ( SELECT CONVERT(varchar(10000),@@servername) ) )
END
select 'End - Query Number: 65001'
select 'Start - Query Number: 65002'
select @start_time = getdate()
select * from table_2
select @row_count = @@rowcount
select @end_time = getdate()
if ( @@error <> 0)
BEGIN
select (" SQL was not executed successfully. Error Code: " + (SELECT CONVERT(varchar(10),@@error)))
END
Else
Begin
select ("Query number 65002 - Time took to execute the Query: " + ( SELECT CONVERT(varchar(10000), (select datediff(ss, @start_time, @end_time)) ) ) + ", number of rows retrieved: " + ( SELECT CONVERT(varchar(10000),@row_count)) + ", on " + ( SELECT CONVERT(varchar(10000),@@servername) ) )
END
select 'End - Query Number: 65002'
GO
I am running isql command to execute that file, below is the command:
isql -S Serevr_name -U user_name -P password_ -D FIRM_ -i C:\path\test.sql -o C:\path\test.log
if all queries are valid, I mean if there no syntactical error with query then its working fine. but if there is any error with any query then it just showing all error in log file.
but what I want here if there is any error either syntactical or logical then that should be printed on log and will go for another query.
If you see test.sql file then you understand what I am trying to do here. I am calculating row count and time taken by any query.
there are around 1000 queries in test.sql file.. plz help me here to sort out this
thanks.