我正在编写相同的小型SQL脚本,我正在使用Advantage Data Architect 11.10。我的脚本如何在选择查询中使用变量表名称(Advantage Data Architect)
一部分是创建基于以下请求“光标”:
...
declare myCursor;
declare prefix char(4);
declare tableName char(10);
...
tableName = prefix + '_table1';
open myCursor as select * from tableName;
...
当我运行我的脚本,我得到以下错误:
poQuery: Error 7200: AQE Error: State = HY000; NativeError = 7041; [iAnywhere Solutions][Advantage SQL][ASA] Error 7041: File not found. Verify the specified path and file name is correct. Table name: tableName ** Script error information: -- Location of error in the SQL statement
我了解,平均这个错误消息,我试图找到在互联网上的答案。
解决我的问题的方法之一是动态创建sql。
我发现了一些如何在Advantage Data Architect中使用动态sql的示例,但这个示例不起作用。 我创建了下面的代码:
...
declare @test string;
...
set @test = 'open myCursor as select * from ' + tableName;
execute(@test);
...
当我运行我的脚本,我得到以下错误:
Expected lexical element not found: Expecting keyword PROCEDURE, IMMEDIATE, DPRINT or PRINT after the EXECUTE keyword. -- Location of error in the SQL statement is:
,我想问你,可能是有人知道如何解决我的问题?
谢谢。
对不起,我的英文。
非常感谢!你的回答对我很有帮助! – netwer 2014-11-06 18:40:01