accessing stored procedure in Oracle package

Ask a Question related to Coldfusion Database Access, Design and Development.

  1. #1

    Default accessing stored procedure in Oracle package

    Hi,

    I'm getting the following error in my CF page when trying to call a stored
    procedure in an Oracle package:


    [Macromedia][Oracle JDBC Driver][Oracle]ORA-06564: object
    HSC.PKG_SR_TEST.SP_TEST_IT does not exist ORA-06512: at "SYS.DBMS_UTILITY",
    line 114 ORA-06512: at line 1

    The package is compile in Oracle and the proper permissions have been set as
    can be seen in the SQL script to create the package.


    --------------------------------------------------------------------
    here is the CF code to call the procedure:

    <cfstoredproc procedure="HSC.pkg_sr_test.sp_test_it" datasource="#dbsource#">
    <cfprocparam type="in" cfsqltype="CF_SQL_INTEGER"
    dbvarname="p_facultyid" value="30" null="No">
    <!---not needed for ColdFusion MX--->
    <!---<cfprocparam type="out" cfsqltype="CF_SQL_REFCURSOR"
    variable="v">--->

    <cfprocresult name="rstKeywords">
    </cfstoredproc>


    <CFDUMP VAR="#rstKeywords#">
    --------------------------------------------------------------------
    here is the SQL script to create the package body and grant permissions to the
    required roles

    CREATE OR REPLACE
    PACKAGE BODY pkg_sr_test AS
    /*
    simple procedure to return keywords for faculty member
    */
    PROCEDURE sp_test_it (p_facultyid IN NUMBER,
    cur_sr_test OUT cur_sr_test_type)
    IS
    v_SQL LONG;

    BEGIN

    v_SQL := 'SELECT j.facultyid, k.keywordid, k.description, k.isactive ' ||
    'FROM sr_keyword k, sr_jct_faculty_keyword j ' ||
    'WHERE j.keywordid = k.keywordid ' ||
    'AND j.facultyid = ' || p_facultyid || ' ';

    OPEN cur_sr_test FOR
    v_SQL;

    END sp_test_it;
    END pkg_sr_test;
    /

    -- Grants for Package Body
    GRANT EXECUTE ON pkg_sr_test TO web_rp
    /
    GRANT DEBUG ON pkg_sr_test TO web_rp


    Thanks in advance for any assistance in resolving the error.
    ~Ernest



    leongek Guest

  2. Similar Questions and Discussions

    1. oracle stored procedure calling
      I have two procedures test1 and test2. Resultset is returned by test2. My coldfusion code calls test1. PROCEDURE test1 (in_eid IN NUMBER,...
    2. Oracle Stored procedure error from CF
      I have a stored proc working on a oracle server, connected through JDBC to the CF server. I ran the stored proc on the oracle server through PL/SQL...
    3. oracle mx stored procedure
      "Error Executing Database Query. Incorrect parameter bindings for stored procedure call. Check your bindings against the stored procedure's...
    4. oracle, asp, stored procedure
      I am trying to run a stored procedure from an asp page on an oracle 9i db. The stored procedure will take one parameter and should return two...
    5. asp to call Oracle stored procedure
      Here is the ASP code that has problem: ADODB.Parameters error Parameter object is improperly defined... Inconsistent or imcomplete information...
  3. #2

    Default Re: accessing stored procedure in Oracle package

    It appears that it can not "find" your package under the HSC schema. Perhaps
    you need to create a public synonym for package PKG_SR_TEST, or find out what
    schema it actually belongs to and use that name. By the way, does it run OK
    from SQL Plus?

    Phil

    paross1 Guest

  4. #3

    Default Re: accessing stored procedure in Oracle package

    Hi Phil,

    I'm not sure how to execute a stored proc that has a REF CURSOR parameter in
    SQL Plus. But for testing purposes, I've gone ahead and created a simple test
    function in my package that accepts two numbers and returns the sum. This
    function works in SQL Plus, but I'm getting the same error in my CFM page if I
    use the <cfstoredproc>:

    [Macromedia][Oracle JDBC Driver][Oracle]ORA-06564: object
    HSC.PKG_SR_TEST.SP_ADD_IT does not exist ORA-06512: at "SYS.DBMS_UTILITY", line
    114 ORA-06512: at line 1

    here is the CF code to call the function:
    <cfstoredproc procedure="HSC.pkg_sr_test.sp_add_it" datasource="#dbsource#">
    <cfprocparam type="in" cfsqltype="CF_SQL_INTEGER" dbvarname="p_1" value="30">
    <cfprocparam type="in" cfsqltype="CF_SQL_INTEGER" dbvarname="p_2" value="30">
    <cfprocresult name="rstKeywords">
    </cfstoredproc>

    and the following error if I call the function using a select...from dual in a
    <cfquery> tag:

    [Macromedia][Oracle JDBC Driver][Oracle]ORA-00904: : invalid identifier

    Here is my ColdFusion code to call this function using the <cfquery>:

    --------------------------------------------------------------------------------
    -------------------------------
    <cfquery name="GetData" datasource="#dbsource#">
    SELECT HSC.pkg_sr_test.sr_add_it(10,5) return_value FROM dual
    </cfquery>

    Thanks,
    Ernest

    leongek Guest

  5. #4

    Default Re: accessing stored procedure in Oracle package

    To access a refcursor in SQL Plus, first you should create a variable of
    refcursor type (var varname refcursor). Then, execute your procedure passing
    your parameters, including the declared refcursor bind variable (using a :
    character). Then the print command using the variable name of the refcursor
    bind variable

    In SQL Plus:

    SQL> var out_var refcursor
    SQL> exec pkg_sr_test.sp_add_it(30, 30, :out_var)
    SQL> print out_var

    Phil

    paross1 Guest

  6. #5

    Default Re: accessing stored procedure in Oracle package

    Your problem is that package pkg_sr_test.sp_add_it does not exist in the data
    dictionary under schema HSC. (Also, this is a procedure not a function, as they
    are not the same in PL/SQL).

    This
    <cfquery name="GetData" datasource="#dbsource#">
    SELECT HSC.pkg_sr_test.sr_add_it(10,5) return_value FROM dual
    </cfquery>
    will not work because you cannot return results sets from Oracle to ColdFusion
    this way.

    Once you figure out where pkg_sr_test.sp_add_it is, you should be able to run
    it without any problem. Have you considered creating a public synonym for the
    package name (and granting the EXECUTE privilege to the appropriate user or
    users) so that you can execute it directly as pkg_sr_test.sp_add_it?

    Phil

    paross1 Guest

  7. #6

    Default Re: accessing stored procedure in Oracle package

    Also, isn't the query in your procedure declaration a little bit of overkill?
    Why don't you just declare it directly instead of building the v_SQL variable?
    You can use dynamic SQL, especially in Oracle 9i, but why do it the hard way if
    you don't need to?

    REATE OR REPLACE
    PACKAGE BODY pkg_sr_test AS

    PROCEDURE sp_test_it (p_facultyid IN NUMBER,
    cur_sr_test OUT cur_sr_test_type)
    IS

    BEGIN

    OPEN cur_sr_test FOR
    SELECT j.facultyid, k.keywordid, k.description, k.isactive
    FROM sr_keyword k, sr_jct_faculty_keyword j
    WHERE j.keywordid = k.keywordid
    AND j.facultyid = p_facultyid;

    END sp_test_it;
    END pkg_sr_test;
    /

    Phil

    paross1 Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139