解决在coldfusion执行oracle块的问题

来源:互联网 发布:mac一般什么时候发布 编辑:程序博客网 时间:2024/06/06 04:46

原地址: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!


0 0
原创粉丝点击