我是 Sybase 的新手。我正在使用以下版本的 Sybase:Adaptive Server Enterprise/15.0.3/EBF 24162 ESD#4。
在这里,我试图一次运行多个查询。我创建了一个 perl 脚本,它将每秒从 sysMonSQLText 捕获数据。它的工作正常。perl 完成后它会生成 test.sql 文件。下面是该 test.sql 文件的示例数据:
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
我正在运行 isql 命令来执行该文件,下面是命令:
isql -S Serevr_name -U user_name -P password_ -D FIRM_ -i C:\path\test.sql -o C:\path\test.log
如果所有查询都有效,我的意思是如果查询没有语法错误,那么它工作正常。但是如果任何查询有任何错误,那么它只会在日志文件中显示所有错误。
但是如果有任何语法或逻辑错误,我想要在这里,那么应该打印在日志上并进行另一个查询。
如果你看到 test.sql 文件,那么你就会明白我在这里想要做什么。我正在计算任何查询所花费的行数和时间。
test.sql 文件中有大约 1000 个查询。请帮我解决这个问题
谢谢。