且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在db2中创建一个临时表

更新时间:2023-11-23 08:07:52

看看错误 - 它甚至没有暗示你创建一个临时表从不介意错误,所以你真正要问的是如何我可以解决这个错误。



我目前没有提供DB2(或Oracle),所以我将引导您完成解决方法你自己的问题...



1.查看
Look at the error - it's not even hinting that you are creating a temporary table never mind incorrectly, so what you are really asking is "how can I solve this error".

I haven't got DB2 (or Oracle) to hand at the moment so I am going to walk you through a method of solving the problem for yourself ...

1. Have a look at the line
SET PARAMS_VALUE = (select replace(replace(replace(replace(tmpname, '''', ''),'{',''), '}' , ''),'=>' , '=') from SYSIBM.SYSDUMMY1);

尝试用硬编码值替换它并运行SP。如果它不再是错误,那么你需要仔细检查这行代码并纠正问题 - 我个人不喜欢转义单引号并且更喜欢使用CHR(39)。





2.如果没有错误...编辑你的SP并注释掉(或删除到安全的地方)除DECLARE光标线以外的所有内容。运行。如果错误,请仔细检查您剩下的代码的语法



2.如果没有错误则开始添加位返回的代码 - 保持代码块的大小合理地小,以便在发生错误时更容易找到错误



基本上将位置放回一块一次,每次都运行SP。当它崩溃时,你知道这是你放回来的最后一件事导致了这个问题。

Try replacing that with a hard-coded value and run your SP. If it no longer errors then you need to carefully examine that line of code and correct the problem - I personally don't like escaping single quotes and prefer to use CHR(39).


2. If it doesn't error ... Edit your SP and comment out (or remove to a safe place) everything other than the DECLARE cursor lines. Run it. If it errors then carefully check the syntax of the code you have left.

2. If it didn't error then start adding bits of the code back in - keep the size of the chunks of code reasonably small to make it easier to locate the error when it does occur

Basically put bits back a piece at a time, run the SP each time. When it falls over you know it was the last thing that you put back that caused the problem.