原地址:http://awads.net/wp/2005/07/25/oracle-plsql-in-cfquery/
Oracle PLSQL in CFQUERY
Sometimes, you may want to execute an anonymous PL/SQL block directly from within the CFQUERY tag instead of calling a stored procedure or function. So you write this (simplified) code in your ColdFusion template:
<cfquery name="q" datasource="yourDSN">
declare
x number;
begin
x := 0;
end;
</cfquery>
Only to get the following error when executing the above code:
Error Executing Database Query.
[Macromedia][Oracle JDBC Driver][Oracle]ORA-06550:
line 1, column 8: PLS-00103: Encountered the symbol ""
when expecting one of the following: begin function
package pragma procedure ...
The workaround is to put the PL/SQL code in a ColdFusion variable and use the variable inside the CFQUERY tag:
<cfset variables.plsql = "
declare
x number;
begin
x := 0;
end;
"
>
<cfquery name="q" datasource="yourDSN">
#variables.plsql#
</cfquery>
The above works like a charm!
本文介绍了如何在ColdFusion模板中直接使用Oracle PL/SQL匿名块,避免了调用存储过程或函数时遇到的错误,并提供了解决方案通过将PL/SQL代码放入ColdFusion变量并在查询标签中使用该变量。
903

被折叠的 条评论
为什么被折叠?



