Skip to main content
Inspiring
April 3, 2012
Question

error when calling Oracle procedure package, please help!

  • April 3, 2012
  • 2 replies
  • 4051 views

This is the 1st. time I'm working with Oracle 11 and ColdFusion 8.

It used to be very easy when I did it in MSSQL, pretty straight forward but in Oracle I need to create a package for a str. procedure that returns a query result

So I created a package procedure in oracle successfully but when calling it from CF it threw me error and I have no clue as what the error is refering to.

(I googled and found similar problem, I followed and still did not work)

Can anyone shed some light please?

I called it this way and it threw error at me:

<cfstoredproc procedure="DUP_PKG.DUP_NEW" datasource="#Trim(application.dsn)#" returncode="True"> 

              <cfprocparam type="In" cfsqltype="CF_SQL_VARCHAR" variable="ins_name" value="#Trim(session.instname)#">

              <cfprocparam type="In" cfsqltype="CF_SQL_VARCHAR" variable="aca_year" value="#Trim(ayr)#">

              <cfprocresult name="MyResult">   <------------------ ERROR POINTING TO THIS LINE          

</cfstoredproc>

OR

If I did it this way:

<cfstoredproc procedure="DUP_PKG.DUP_NEW" datasource="#Trim(application.dsn)#" returncode="True"> 

              <cfprocparam type="In" cfsqltype="CF_SQL_VARCHAR" variable="ins_name" value="#Trim(session.instname)#">

              <cfprocparam type="In" cfsqltype="CF_SQL_VARCHAR" variable="aca_year" value="#Trim(ayr)#">

              <cfprocparam type="Out" cfsqltype="CF_SQL_VARCHAR" variable="MyResult">  <------------------ ERROR POINTING TO THIS LINE          

</cfstoredproc>

The error was:

Error Executing Database Query.

[Macromedia][Oracle JDBC Driver]Unhandled sql type

My package looks like this:

---------------------------------------

create or replace
PACKAGE DUP_PKG
AS

  TYPE mypkg IS REF CURSOR;

  PROCEDURE DUP_NEW (ins_name IN VARCHAR2, aca_year IN VARCHAR2, MyResult OUT mypkg);

END;

create or replace
PACKAGE BODY DUP_PKG
AS

PROCEDURE DUP_NEW (ins_name IN VARCHAR2,aca_year IN VARCHAR2, MyResult OUT mypkg)

IS
  BEGIN

// a bunch of INSERT statements

    INSERT INTO....

    INSERT INTO....

  

    etc

//After all insert are done, get some data using select statement and return the query result to the calling CF codes for further processing

   OPEN MyResult FOR

      SELECT columns

      FROM a table

      WHERE .....

  END;

END;

This topic has been closed for replies.

2 replies

Inspiring
April 11, 2012

Finally!!!

I got rid of the returncode attribute and it works!

Thank you for helping everyone! this has bene quite a learning process. Your support is very valuable! thanks again

<cfstoredproc procedure="DUP_PKG.DUP_NEW" datasource="#Trim(application.dsn)#" returncode="True"> 

              <cfprocparam type="In" cfsqltype="CF_SQL_VARCHAR" variable="ins_name" value="#Trim(session.instname)#">

              <cfprocparam type="In" cfsqltype="CF_SQL_VARCHAR" variable="aca_year" value="#Trim(ayr)#">

              <cfprocresult name="MyResult">   <------------------ ERROR POINTING TO THIS LINE          

</cfstoredproc>


BKBK
Community Expert
Community Expert
April 13, 2012

BYJ_wntrsnt wrote:

Finally!!!

I got rid of the returncode attribute and it works!

Thank you for helping everyone! this has bene quite a learning process. Your support is very valuable! thanks again

<cfstoredproc procedure="DUP_PKG.DUP_NEW" datasource="#Trim(application.dsn)#" returncode="True"> 

              <cfprocparam type="In" cfsqltype="CF_SQL_VARCHAR" variable="ins_name" value="#Trim(session.instname)#">

              <cfprocparam type="In" cfsqltype="CF_SQL_VARCHAR" variable="aca_year" value="#Trim(ayr)#">

              <cfprocresult name="MyResult">   <------------------ ERROR POINTING TO THIS LINE          

</cfstoredproc>



Then please kindly mark this as the answer. It will certainly help someone else.

Owainnorth
Inspiring
April 3, 2012

Yup, you can't return a ref cursor from a stored procedure into ColdFusion as far as I know - CF opens a connection, gets data, closes connection. It has no way to then utilise that ref cursor any more through a probably closed connection.

What is it you're trying to return? Other than a ref cursor, obviously.

Inspiring
April 3, 2012

Hi! I'm translating from an existing codes.

The existing CF codes is calling MSSQL procedure.

In this str. Proc., there are many insert statements and 1 select statement at the end.

This last select statement returns a query result back to CF8 : <cfprocresult name="MyResult"> and CF use this query result for the rest of the processes

So I imitated the same logic but now I have to make CF8 talk to Oracle 11



since Oracle does not return query result, from googling some postings I created a package using the logic described in existing MSSQL

So my CF8 need to call this package and expecting a query result back. So I'm trying to return the query result from the last select statement in the package

Owainnorth
Inspiring
April 4, 2012

Yeah, what you'll find is that MSSQL stored procedures can easily return query objects, whereas Oracle ones cannot. What I would do is remove the select statement from the stored procedure, assuming that's possible. Then, within one cftransaction to maintain integrity, call the stored proc then the query. So like this:

<cftransaction>

  <cfstoredproc ...>

  <cfquery>

    SELECT ...

  </cfquery>

</cftransaction>

Annoying I know, but personally I've never liked using stored procedures to return query objects, feels a bit wrong to me.

Hope that helps.

O.