[英]Invalid table or object when doing query on temp table (Pervasive SQL)
I have a SP that inserts records into a temp table, then selects the records and returns them. 我有一个SP,它将记录插入到临时表中,然后选择记录并返回它们。 The SQL is this.
SQL就是这个。
I troubleshot it by removing the INSERT INTO statement, and minimizing the SQL. 我通过删除INSERT INTO语句并最小化SQL来解决这个问题。 The culprit is the SELECT * FROM #Worklist1.
罪魁祸首是SELECT * FROM#Worklist1。 No idea why this does not work.
不知道为什么这不起作用。 I upgraded (just now) to latest version of Pervasive server ver 10 if that helps, but this issue was in 10.3 and its still there.
如果有帮助,我已将Pervasive服务器第10版升级到了最新版本(如果有的话),但此问题存在于10.3中,并且仍然存在。 Must be missing something.
必须缺少一些东西。
CREATE PROCEDURE "Connect_Workflow"(
:StartDate DATETIME, :EndDate DATETIME)
RETURNS(Patient varchar(100) ,
AccessionNo varchar(25)
);
BEGIN
CREATE TABLE #WorkFlow1
(Patient varchar(100) null,
AccessionNo varchar(25) null
);
INSERT INTO #Workflow1(
SELECT
rtrim(p.LastName),--+ '^' + rtrim(p.FirstName) + isnull('^' + rtrim(p.Initial), ''),
v.VisitID -- equiv to EncounterID
FROM visit v
join patient p on v.patientnumber = p.patientnumber
WHERE v.VisitYY = '99'
);
SELECT * FROM #WorkFlow1;
DROP TABLE #Workflow1;
END
Update: After commenting out the SELECT * FROM #Worklist1; 更新:注释掉SELECT * FROM#Worklist1之后; it still gives a invalid table error.
它仍然给出无效的表格错误。 If I remove the INSERT INTO and the SELECT * then finally the error is gone.
如果我删除了INSERT INTO和SELECT *,那么错误最终消失了。 Must be error in referencing the table.
引用表时一定是错误的。
Remove the DROP TABLE #Workflow1; 删除DROP TABLE#Workflow1; from your query.
从您的查询。
I believe it's dropping the table before the SP returns the data. 我相信它会在SP返回数据之前删除表。
Okay i figured it out. 好吧,我知道了。 Although the procedure should work fine, in fact Pervasive recommends something like this.
尽管该程序可以正常运行,但实际上Pervasive建议使用类似方法。 use SELECT INTO
使用SELECT INTO
CREATE PROCEDURE "Connect_Workflow"(
:StartDate DATETIME, :EndDate DATETIME)
RETURNS(Patient varchar(100) ,
AccessionNo varchar(25)
);
BEGIN
SELECT
rtrim(p.LastName),--+ '^' + rtrim(p.FirstName) + isnull('^' + rtrim(p.Initial), ''),
v.VisitID -- equiv to EncounterID
FROM visit v
INTO #Workflow1
join patient p on v.patientnumber = p.patientnumber
WHERE v.VisitYY = '99'
);
SELECT * FROM #WorkFlow1;
END
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.