Sys_refcursor procedure parameters in out

Hi,
I have created a procedure that receive the SQL statment in VARCHAR" datatype parameters and return the Resultset into a refcursor :
create or replace
procedure my_test(VAL1 in number, val2 in number, val3 in number, val4 in VARCHAR2, vla5 out nocopy SYS_REFCURSOR )
is
begin
  open vla5 for 'select * FROM (select x_x.*  ,rownum rn  FROM ('||val4 ||') x_x where rownum <= '|| to_char(val3)||' ) where rn >='|| to_char(val2);
end;I like to pass and receive the val4 and val5 in one parameters :
procedure my_test(VAL1 in number, val2 in number, val3 in number, val4 in out nocopy SYS_REFCURSOR )I like to pass the SQL statment in VARCHAR2 datatype to my procedure and return the result in the same variable parameters.
I don't know if my english was understand, but could you please help me to find a solution?
thanks a lot.
Calà Salvatore

Can we have more detail please?
A sys_refcursor is not a SQL statement that you can add predicates to. So not possible to combine the two arguments. Not at all.
To receive a refcursor and try to do it doesn't make sense.
See Refcursor 101 thread:
PL/SQL 101 : Understanding Ref Cursors
If you want to receive a SQL statement as a VARCHAR2/CLOB/LONG and you want to wrap it with further predicates then you can do that just with string manipulation - as you're doing.
However, if you do receive a sql statement as a string and want to wrap it with a select and further predicates, you should use binds for the predicate values not string concatenation of literals which is likely to be poorly performant and a possible security issue (also see DBMS_ASSERT).
Edited by: DomBrooks on Nov 9, 2010 11:00 AM

Similar Messages

  • Problem with database adapter on plsql procedure with in/out parameters

    running BPEL 10.1.3.1 and using the database adapter on a plsql procedure with in/out parameters I get errors
    the plsql procedure:
    create or replace procedure proc_with_clob_inout_parameter(
    p_string in varchar2,
    p_clob in out clob)
    is
    begin
    p_clob := p_string;
    end proc_with_clob_inout_parameter;
    In BPEL I call this procedure. When I only assign a value to the p_string parameters (in a BPEL assign) all is well. When I also assign a value to the p_clob parameter the error occurs:
    <part name="summary">
    <summary>
    file:/ora1/app/oracle/as101.3/bpel/domains/digitaaldossier/tmp/.bpel_janb_inout_1.0_f6908ccf864581b7265c362444e88075.tmp/twee.wsdl
    [ twee_ptt::twee(InputParameters,OutputParameters) ] - WSIF JCA Execute of
    operation 'twee' failed due to: Error while trying to prepare and execute
    an API.
    An error occurred while preparing and executing the
    JANB.PROC_WITH_CLOB_PARAMETER2 API. Cause: java.sql.SQLException: Parameter
    Type Conflict [Caused by: Parameter Type Conflict]
    ; nested exception is:
    ORABPEL-11811
    Error while trying to prepare and execute an API.
    An error occurred while preparing and executing the
    JANB.PROC_WITH_CLOB_INOUT_PARAMETER API. Cause: java.sql.SQLException: Parameter
    Type Conflict [Caused by: Parameter Type Conflict]
    Check to ensure that the API is defined in the database and that the
    parameters match the signature of the API. Contact oracle support if error
    is not fixable.
    </summary>
    </part>
    In BPEL 10.1.2.0 this isn't a problem. I tested it against a 10.2.0.1 and a 10.2.0.2 database and in both situations I get the error with BPEL 10.1.3.1 and no error with BPEL 10.1.2.0
    it appears to be a problem in the database adapter...
    anyone with the same problems and/or a solution?

    Not of any use to you, but we had exactly the same problem on Friday when we applied AS 10.1.2.2 Patchset on top of BPEL 10.1.2.0.2.
    The clob in our pl/sql proc wan't declared as in/out but for some reasons JDeveloper had created a clob on the Output Parameter type in the db partner link xsd. I removed this and it worked. This code had been untouched , and working fine, for months.
    I'll be raising an SR today.
    Rob J

  • Calling Oracle procedure with two OUT parameters

    Hi I am having an Oracle procedure which return ref cursor. I also want to result one more out parameter result. How Can I call the procedure in SQL. Below is the way I am calling my stored procedure with one parameter.
    proc_Test (p_resultset=> My_cursor)
    How can I call the procedure when I have one more OUT parameter. Second parameter returns 0 or 1.
    Thanks in adv

    Yes its possible to use multiple parameter as OUT type in procedure.
    SQL>set serveroutput on size 1000000;
    SQL>CREATE OR REPLACE PROCEDURE myproc(p_cv OUT SYS_REFCURSOR, p_num OUT NUMBER) AS
      2  BEGIN
      3    OPEN p_cv FOR SELECT 'Hello Oracle' sayhello FROM DUAL ;
      4    p_num := 1;
      5  END;
      6  /
    Procedure created.
    SQL>VAR cv REFCURSOR;
    SQL>VAR num NUMBER;
    SQL>EXEC myproc(:cv, :num);
    PL/SQL procedure successfully completed.
    SQL>PRINT cv;
    SAYHELLO
    Hello Oracle
    SQL>PRINT num;
           NUM
             1
    SQL>
    {code}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Reg:execute procedure with in out parameters

    hi,
    what is the code to execute a procedure with in out parameters.can anyone give me an example
    thanks

    872296 wrote:
    thanks for the reply.
    i am very much new to oracle database.i need this code to put in one of my informatica mapping.
    so can you just elaborate what does 'karthick' mean?is it the name of the procedure.No, karthick is the value of the variable that is being passed into the procedure called "P" in karthicks example, then if that procedure changes the value inside, the variable will have that new value passed back out of the procedure to it.
    PROCEDURE prc_mv (name VARCHAR2)
    IS
    BEGIN
    dbms_mview.refresh (mv_name);
    END prc_mv;
    PROCEDURE refresh (response IN OUT NUMBER)
    IS
    BEGIN
    dbms_mview.refresh('mv1','C');
    dbms_mview.refresh('mv2','C');
    response := 1;
    EXCEPTION
    WHEN OTHERS
    THEN
    response := 0;
    END refresh;
    can you give the code for this procedure.Yes.
    DECLARE
      v_response NUMBER;
    BEGIN
      refresh(v_response);
    END;Though your code is awful. There's no point in having the response parameter as an IN OUT if you're not going to pass IN a value and use that in the code anywhere. In your case it only needs to be an OUT parameter because you're just passing back OUT a value. You are also masking any exceptions that happen by using a WHEN OTHERS clause.
    Better code would be something like...
    FUNCTION refresh (mv_name) RETURN NUMBER IS
      v_response NUMBER := 0; -- default response value
      e_mv_not_exist EXCEPTION; -- exception variable
      PRAGMA EXCEPTION_INIT(e_mv_not_exist, -23401); -- connect exception name to internal oracle error number
    BEGIN
      dbms_mview.refresh(mv_name,'C');
      v_response := 1;
    EXCEPTION
      WHEN e_mv_not_exist THEN -- handle specific expected exception
        -- if the materialized view does not exist, handle it gracefully as we don't want to stop
        response := 0;
    END refresh;
    declare
      v_response NUMBER;
    begin
      v_response := refresh('mv1');
      if v_response = 0 then
        -- the materialized view did not exist
      else
        -- the materialized view refreshed ok
      end if;
    end;where your exception handler explicity checks for expected exceptions such as :
    ORA-23401: materialized view "SCOTT"."FRED" does not exist... and any other exceptions that you're not expecting will be raised for you to see.
    It's also better as a function because you don't need to pass in a response value, you just want to get a response value back.
    There's rarely a good need to use OUT or IN OUT parameters. (there's some cases, but it's not something to consider doing as part of your regular design)

  • Database procedure with IN/OUT parameters

    Hi,
    I have a procedure with multiple OUT parameters,
    but I do not know how to get the values of these out parameters in the calling procedure.
    What I mean is I can simply get the value of a function from a calling procedure as:-
    declare
    val1 number;
    begin
    val1 := func_get_num;
    end;
    How can I get the values of OUT parameters of a procedure in a similar way?

    like
    SQL> var ename_v varchar2(30);
    SQL> var empno_v number;
    SQL> create or replace procedure get_employee(empno out number, ename out varchar)
      2  as
      3  begin
      4     select empno, ename into empno, ename from emp where rownum <=1;
      5  end;
      6  /
    Procedure created.
    Elapsed: 00:00:00.51
    SQL> exec get_employee(:empno_v, :ename_v);
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:00.12
    SQL> print empno_v
       EMPNO_V
           666
    SQL> print ename_v;
    ENAME_V
    fdddfdf1
    SQL>

  • How to call a stored procedure which has out parameter value

    my code is
    public Connection createConnection() {
                   Connection conn = null;
                        try {
                             Class.forName(DRIVER);
                             conn = DriverManager.getConnection(URL,USER,PASS);
                        } catch (ClassNotFoundException cnfe) {
                             System.err.print("Class not found");
                        } catch (SQLException sqle) {
                             System.err.print("SQLException");
                   return conn;
         public static void main(String args[]){
              StroedProcedure stp = new StroedProcedure();
              Connection con = stp.createConnection();
              try {
                   CallableStatement stproc_stmt = con.prepareCall("{call Account_Summary(?,?,?,?,?,?,?,?)}");
                   stproc_stmt.setString(1, "123456");
                   stproc_stmt.setDate(2, null);
                   stproc_stmt.setString(3, null);
                   stproc_stmt.setString(4, null);
                   stproc_stmt.setString(5, null);
                   stproc_stmt.setString(6, null);
                   stproc_stmt.setDate(7, null);
                   stproc_stmt.setDate(8, null);
                   stproc_stmt.registerOutParameter(1,Types.CHAR);
                   stproc_stmt.registerOutParameter(2,Types.DATE);
                   stproc_stmt.registerOutParameter(3,Types.CHAR);
                   stproc_stmt.registerOutParameter(4,Types.CHAR);
                   stproc_stmt.registerOutParameter(5,Types.CHAR);
                   stproc_stmt.registerOutParameter(6,Types.CHAR);
                   stproc_stmt.registerOutParameter(7,Types.DATE);
                   stproc_stmt.registerOutParameter(8,Types.DATE);
                   stproc_stmt.execute();
                   System.out.println("test "+stproc_stmt.getString(1));
                   ResultSet rs = stproc_stmt.executeQuery();
                  while (rs.next()){
                       System.out.println("result "+rs.getString("ACCPK"));
              } catch (SQLException e) {
                        e.printStackTrace();
         }And the stored procedure is
    CREATE OR REPLACE
    procedure Account_Summary (accpk in out char, incdt out date, bcur out char, bmark out char, tarTE out char, numHold out char, stDt out date, AsDt out date)
    is
    begin
    select account_pk, inception_date, base_currency, benchmark  into accpk, incdt, bcur, bmark
    from account a
    where a.Account_pk=accpk;
    select target_te, number_holdings, start_date, as_date into tarTE, numHold, StDt, AsDt
    from acc_summary asum
    where asum.account_pk=accpk;
    end Account_Summary;but it gives a exception ORA-01460: unimplemented or unreasonable conversion requested
    ORA-06512: at "REPRO.ACCOUNT_SUMMARY", line 4
    ORA-06512: at line 1
    i want to execute a stored procedure which has in , inout or out parameter
    but it can not work

    ========================
    In some contects varchar2 variable limit is 32512 characters... October 16, 2003
    Reviewer: Piotr Jarmuz from Poznan, Poland
    Interesting to note is the fact that varchar2 variables as parameters to stored
    procedures (in in/out out) may be "only" 32512 bytes long.
    I've checked this in Java and Perl. 32512 is the last value that works, for any
    bigger it throws:
    Exception in thread "main" java.sql.SQLException: ORA-01460: unimplemented or
    unreasonable conversion requested
    But in PL/SQL as you said 32767
    Regards,
    Piotr
    =================================
    This i got it from ask tom, well it make sense.... try checking your input with small numbers and strings
    Have fun

  • Toplink support for stored procedure with 2 OUT  REF CURSOR ?

    Can Toplink StoredProcedureCall be used with Oracle PLSql procedure with 2 OUT parameters. Parameter type is Ref Cursor (Oracle PLSQL resulset)
    Regards

    In a TopLink StoredProcedureCall using an OUT CURSOR the cursor is assumed to map to the result set for the TopLink query.
    For example if you had a stored procedure READ_ALL_EMP that returned a out cursor of EMP rows, you could use that procedure in a TopLink mapped Employee class mapped to the EMP table and use the stored procedure in a ReadAllQuery for the Employee class.
    If the procedure does not return data that maps to objects, you can use a DataReadQuery to access the data. The out cursor would be returned as a Vector of DatabaseRows that contain the data from the cursor rows.
    If the procedures data is complex and does not map to objects, it may be better to access the procedure directly through JDBC.

  • Need help in modifying mapping parameters of out the box mapping

    Hi There,
    I am a new bee to dac.
    Need help in modifying mapping parameters of out the box mapping, which is invoked by DAC task.
    We got a requirement to edit mapping parameter. When I go and see parameter under mappings tab in a mapping, I could not see any values in it.
    But when I set any value, and validate it. It is successful.
    Is it right way to do it?
    What my concern is, When I initially go and see parameter values under maapings tab in a mapping, they are blank.
    Where is it storing these values?
    Thanks,
    Rag

    If you modify mapping then u have to create new task in dac and dac itself craete parameter file at run time. if you want to add more parameters then do it in dac system parameters tab.
    Thanks
    Jay.

  • Unused stored procedure parameters marked with a check mark in crystal reports

    Post Author: epowers0213
    CA Forum: General
    Hello,
    I have some Crystal Reports that currently use stored procedures as their datasources (I am in the process of modifying them to use datasets instead).  Some of the original reports have check marks next to stored procedure parameters which I cannot find as being used anywhere in the report.  Is this a legitimate possibility? (Some of them do not have check marks, however, so it is not consistent.)
    More Info:  I am using Crystal Reports within Visual Studio 2005.  I have looked through each report in every way I can think of to find if a parameter field is being used anywhere - I have checked all formula fields, the formatting formulas for sections and individual fields, the record and group selection formulas and the grouping and sorting experts, along with any subreports (although some of them have no subreports).
    (I have read on other forums that exporting a report definition file is another way to look for where fields or parameters are being used, but this does not appear possible within Visual Studio 2005.)
    In some cases, I have gone ahead and replaced the stored procedure datasource location with a dataset (generated based on the same stored procedure).  When I do this, Crystal automatically deletes the stored procedure parameters from the report, and I have still been able to run the modified report successfully - at least it looks ok and nothing is complaining.  So is it possible that these parameters were actually not being used anywhere on the report although they were marked with a check mark?
    Any help would be greatly appreciated!  I want to make sure I am not changing the function of these reports somehow without knowing it...
    Thank you!

    Are you referencing another database that Crystal can't see? Also, you can try and copy the SQL to a command object in Crystal to see if it behaves differently there.

  • No clearing procedures were carried out( f.13)

    Hi Friends,
    I am clearing GL account by ususing F.13, but at the last i am getting error " No clearing procedures were carried out".
    IN OB74:
    i have maintained 1. CHA, 2.acct type, 3.account ( 2 to 9999999999) 4.Criteria(ZUONR) 5.(BELNR)
    Could you please tell me is there any  settings are missing in my confiq or could you please guide me whare should i check the settings apart from OB74
    Appreciate your early response and would be a great help to me.
    Regards
    Jay.

    The above items will never clear against each other.  Keep in mind that the F.13 program "groups" line items in an account (A SINGLE ACCOUNT!!!) according to the criteria that you specify in OB74 and when the balance in local and foreign currency is zero for that group, all of the line items in that group are cleared.  If I change your example as under, they will clear against each other.
    4500123 100 DR
    4500123 100 CR
    (these two open line items will clear against each other)
    or
    4500125 100 DR
    4500125 100 CR
    (these two open line items will clear against each other)

  • ORA-30626: function/procedure parameters of remote object types not support

    Hello,
    I am trying to create a dynamic LOV.
    I have a table and package in a remote database, I am connecting to the database using dblink. When I access package I am getting error
    ORA-30626: function/procedure parameters of remote object types are not supported
    However I can access table with [email protected], not the package!
    How can I solve this problem?

    Did you ever get an answer/workaround to this? I'm having similar problems in 10g.

  • Is It Possible To define a size of the Procedure Parametere?

    In Oracle Is It Possible To define a size of the Procedure Parametere?
    If i have the procedure like
    Test_sp(no int,name varchar2)
    Is it possible to define a size
    Test_sp(no int(5),name varchar2(255))
    Thanks
    Rangan S

    As Anthony said - no, not in the parameter signature of a procedure or a function. Which could have unexpected run-time errors as one could wrongly assume that using a "derived" type will allow this.
    The following example illustrates:
    SQL> create table datatype(
    2 varchar2_5 varchar2(5),
    3 number1 number(1)
    4 );
    Table created.
    SQL>
    SQL>
    SQL> create or replace procedure fooProc( s datatype.varchar2_5%TYPE, n datatype.number1%TYPE ) is
    2 s1 datatype.varchar2_5%TYPE;
    3 n1 datatype.number1%TYPE;
    4 begin
    5 begin
    6 DBMS_OUTPUT.put_line( 'len='||length(s)||' value='||s );
    7 DBMS_OUTPUT.put_line( 'value='||to_char(n) );
    8 exception when OTHERS then
    9 DBMS_OUTPUT.put_line( 'parameter display failed with error '||SQLERRM(SQLCODE) );
    10 end;
    11
    12 begin
    13 s1 := s;
    14 DBMS_OUTPUT.put_line( 'string parameter assignment succeeded' );
    15 exception when OTHERS then
    16 DBMS_OUTPUT.put_line( 'string assignment failed with error '||SQLERRM(SQLCODE) );
    17 end;
    18
    19 begin
    20 n1 := n;
    21 DBMS_OUTPUT.put_line( 'number parameter assignment succeeded' );
    22 exception when OTHERS then
    23 DBMS_OUTPUT.put_line( 'number assighment failed with error '||SQLERRM(SQLCODE) );
    24 end;
    25 end;
    26 /
    Procedure created.
    SQL>
    SQL> exec fooProc( 'test1', 1 );
    len=5 value=test1
    value=1
    string parameter assignment succeeded
    number parameter assignment succeeded
    PL/SQL procedure successfully completed.
    SQL>
    SQL> exec fooProc( 'this should fail', 1 );
    len=16 value=this should fail
    value=1
    string assignment failed with error ORA-06502: PL/SQL: numeric or value error: character string buffer too small
    number parameter assignment succeeded
    PL/SQL procedure successfully completed.
    SQL>
    SQL> exec fooProc( 'test', 1234 );
    len=4 value=test
    value=1234
    string parameter assignment succeeded
    number parameter assignment succeeded
    PL/SQL procedure successfully completed.
    SQL>
    Note that only the string assignment fails. The string parameter works fine. And there is no impact at all on the number side, despite seemingly constraining it to a single digit.

  • How to set store procedure parameters

    Hello,
    To summarize our problem, we are not able to set store procedure parameters using JRC and without using a Viewer.
    Inside an rpt document we use a call to a store procedure that requires some input parameters.
    We attempted to pass the required parameters to the report (please see below) but it seems that those parameters are somehow ignored.
    In fact null values are always received by the store procedure.
    For your information, if the document doesnu2019t contain a call to a store proc but SQL clause parameters instead, then that works.
    Does that mean that sp parameters have to be set in a specific way?
    Please can you advise?
    Tanks a lot,
    Joseph
    This is how we set parameter values:
    private void handleParameters(ReportClientDocument pm_document, List pm_parameters) throws Exception
         ParameterFieldController pfc = pm_document.getDataDefController().getParameterFieldController();
         pfc.setCurrentValue(reportName, parameterFieldName, parameterValue);
    Then we export in a pdf file:
    private InputStream createInputStream(ReportClientDocument pm_document, String pm_reportName) throws Exception
         return (ByteArrayInputStream)pm_document.getPrintOutputController().export(ReportExportFormat.PDF);

    First question:
    Do you set the parameters before the database logon?
    Sincerely,
    Ted Ueda

  • Write a procedure to find out the data copy is happening or not.

    Good Day all,
    I have two databases called "*Report*" and "*Production*". I have a report database which copy a data from production database. I want to write a Stored procedure to compare the count of one table in both the databases. All the tables are same in both the databases.
    Please note :*
    1. We are writing the procedure to find out the data copy is happening or not and also report database is down or not.
    2. Not all times, the both the count is same, sometimes it take delay to copy the data in report database but report database is not down.
    Please see the query to compare
    _"Report"_
    Select count(*) from trx where date ='03-Oct-2010'
    *"Production"*
    Select count(*) from trx where date ='03-Oct-2010'
    I am suggesting to take a count for every 5 mins and keep in temp table and compare it.
    Thanks
    Nihar

    How are you replicating the data from the production database to the reporting database?
    Wouldn't it make more sense to monitor that replication process rather than counting every row in the table every 5 minutes? That's going to get rather expensive for non-trivial tables. If you are using something like Streams to replicate the data, it would make far more sense to monitor the Streams apply process, to determine when the reporting database it updated as of, than it would to monitor the underlying tables.
    Justin

  • Is there a procedure for printing out text messages received on my Lumina 822?

    I have attempted to research an appropriate procedure for printing out text messages received on a Lumina 822 without success.  Has anyone been successful in performing this type of task?  Thank you!

        Super_Dad_of_twins That's a great question. Many people are looking for ways to print text messages. What we can recommend is that you forward the text to your email account and print them that way. You can research third party applications for other options besides email. Please keep us posted.
    Sheritah_vzw
    Follow us on Twitter
    @VZWSupport

Maybe you are looking for