Bind Operator to Function with optional parameter

Hi,
as mentioned in the subject, I would like to create an operator which is bind to an function with an optional parameter:
CREATE OR REPLACE FUNCTION
          TS_Base_Func(iobject IN CIBase, format IN VARCHAR2 DEFAULT NULL) RETURN VARCHAR2 IS
BEGIN
     RETURN interval_object.IntervalToString(format);
END TS_Base_Func;
I can bind the operator with a VARCHAR2 as second parameter, but how can I bind an operator without the second parameter to this function?
Thanks!

What about using a "wrapper" function to implement what you would like to do? Here is a small sample:
SQL> CREATE OR REPLACE FUNCTION TEST
  2  (
  3          A       IN VARCHAR2
  4  ,       B       IN VARCHAR2     DEFAULT NULL
  5  )
  6  RETURN NUMBER
  7  AS
  8  BEGIN
  9          IF A = B THEN
10                  RETURN 1;
11          ELSE
12                  RETURN 0;
13          END IF;
14  END;
15  /
Function created.
SQL> CREATE OR REPLACE FUNCTION TEST_WRAPPER
  2  (
  3          A       IN VARCHAR2
  4  )
  5  RETURN NUMBER
  6  AS
  7  BEGIN
  8          RETURN TEST(A);
  9  END;
10  /
Function created.
SQL> CREATE OR REPLACE OPERATOR TestOperator
  2  BINDING (VARCHAR2)              RETURN NUMBER USING TEST_WRAPPER
  3  ,       (VARCHAR2, VARCHAR2)    RETURN NUMBER USING TEST;
Operator created.
SQL> SELECT  TestOperator(1) FROM DUAL;
TESTOPERATOR(1)
              0
SQL> SELECT  TestOperator(1,2) FROM DUAL;
TESTOPERATOR(1,2)
                0
SQL> SELECT  TestOperator(1,1) FROM DUAL;
TESTOPERATOR(1,1)
                1
SQL>The TEST_WRAPPER function has the signature you need for a one variable parameter. However, under the hood it calls the TEST function.

Similar Messages

  • How to use INVOKE function with INT parameter types

    Can you tell me how to use invoke function with int parameter type ?

    Pass the int as an Integer.

  • Activating explanation function with application parameter

    Hello,
    I found in documentation that it's possible to activate explanation function (mouse over) with url parameter sap-explanation=X. Is it also possible to activate explanations with application parameter, application configuration or GLOBAL_SETTINGS?
    Thanks and regards
    Marc

    I remember that JSF provides no support for accessing the indexed values as I right understand you.

  • Ago function with offset parameter dynamic

    Hi,
    I need to calculate a measure in rpd or answer that simulate the behavior of ago function with the offset parameter dynamic.
    i.e.
    ago(total_quantity, month, offset), where offset is a number provided by a logical column.
    Is it possible?
    Thanks.

    Hi,
    The problem is that I only know the offset values at row level, i.e., when I run my answer report some records use a certain offset value (offset1) while others use another offset value (offset2)
    The offset value can be determinate by a logical column.
    Is it possible?
    Thanks.

  • Hyperlinks with optional parameter in BO XI3.1

    Hi All,
    Can anyone please guide me how can i create a hyperlink which takes care of optional parameter and uses the same when there is a value or drop it otherwise from URL.
    I am not sure how no_value used to work, please guide me in that direction too.
    Thanks a lot in advance
    Regards,
    Honed Ali

    Hi,
    try with this formulas.
    1. If you want to pass a single value to a prompt in child report
    http://<servername>:<port>/OpenDocument/opendoc/<platformSpecific>sType=wid&sDocName=SalesReport&iDocID=2010&lsSSelectaCity=Paris
    2.  If you want to pass a range of values to a prompt in child report
    http://<servername>:<port>/OpenDocument/opendoc/<platformSpecific>?sType=rpt&sDocName=SalesReport&lsMSelect+Cities=[Paris],[London]
    Cheers,
    Suresh Babu Aluri.

  • Odi os call with option parameter from odi procedure

    Hi.
    I am calling a shell script from ODI as below inside an ODI procedure P1. The os command below is in 'Command on Target' side.I have defined v_in_param as an 'option' inside procedure P1
    OdiOSCommand sample.sh v_in_param
    i am getting error as 'OS command returned 1'.
    Is it the right syntax to pass an 'option' parameter to an OS call?
    thanks

    you can try OdiOSCommand sh sample.sh <%=odiRef.getOption("v_in_param")%> or even call OS Command in ODI Package and paste the above code.

  • Rfc function with table parameter

    Hey,
    im trying to call a RFC function from Webdynpro where i have to give a table as parameter.  When creating the table i following exception:
    java.lang.IllegalArgumentException: model object must not be null
         at com.sap.tc.webdynpro.progmodel.context.ModelNodeElement.<init>(ModelNodeElement.java:66)
         at be.vrt.wdp.IPublicPlanning_Validation$IP_Update_TableElement.<init>(IPublicPlanning_Validation.java:3667)
         at be.vrt.wdp.IPublicPlanning_Validation$IContextNode.doCreateElement(IPublicPlanning_Validation.java:87)
         at com.sap.tc.webdynpro.progmodel.context.NodeInfo.createElement(NodeInfo.java:854)
         at com.sap.tc.webdynpro.progmodel.context.Node.createElementInternal(Node.java:1346)
         at com.sap.tc.webdynpro.progmodel.context.Node.createElement(Node.java:1365)
         at be.vrt.Planning_Validation.executeRFC_Z_Whatson_Sap_Update_Transmissio_Input(Planning_Validation.java:265)
    The code from Planning_Validation (controller class)
      public void executeRFC_Z_Whatson_Sap_Update_Transmissio_Input( java.util.Vector nodes, java.lang.String display_value )
        //@@begin executeRFC_Z_Whatson_Sap_Update_Transmissio_Input()
         Z_Whatson_Sap_Update_Transmiss_Input transmiss = new Z_Whatson_Sap_Update_Transmiss_Input();
         //transmiss.addP_Update_Table(new Zmm_S_Update_Status_Table());
         wdContext.nodeZ_WHATSON_SAP_UPDATE_TRANSMIS().bind(transmiss);
         //wdContext.createP_Update_TableElement(new Zmm_S_Update_Status_Table());
         for (int i = 0; i < nodes.size(); i++){
              String [] node = (String[])nodes.get(i);
              IWDNodeElement el = wdContext.nodeP_Update_Table().createElement();
              el.setAttributeValue("Won_Id", node[0]);
              el.setAttributeValue("Won_Status", node[1]);
              el.setAttributeValue("Display_Status", display_value);
         try {
              // Call remote function          
              wdContext.currentZ_WHATSON_SAP_UPDATE_TRANSMISElement().modelObject().execute();
              // synchronise data in context with data in model
              wdContext.nodeOutput().invalidate();
         } catch (WDDynamicRFCExecuteException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
    Line 265 is where i call wdContext.nodeP_Update_Table().createElement();
    Any ideas ?
    grtz,
    Hannes

    Hey, thanks .. i managed to solve it
    this is the code: 
    //@@begin javadoc:executeRFC_Z_Whatson_Sap_Update_Transmissio_Input()
      /** Declared method. */
      //@@end
      public void executeRFC_Z_Whatson_Sap_Update_Transmissio_Input( java.util.Vector nodes, java.lang.String display_value )
        //@@begin executeRFC_Z_Whatson_Sap_Update_Transmissio_Input()
         Z_Whatson_Sap_Update_Transmiss_Input transmiss = new Z_Whatson_Sap_Update_Transmiss_Input();     
         wdContext.nodeZ_WHATSON_SAP_UPDATE_TRANSMIS().bind(transmiss);
         for (int i = 0; i < nodes.size() ; i++){
              String [] node = (String[])nodes.get(i);          
              Zmm_S_Update_Status_Table updEl = new Zmm_S_Update_Status_Table();
              updEl.setWon_Id(node[0]);
              updEl.setWon_Status(node[1]);
              updEl.setDisplay_Status(display_value);
              transmiss.addP_Update_Table(updEl);                    
         wdComponentAPI.getMessageManager().reportSuccess("wohoo!");
         try {
              // Call remote function          
              wdContext.currentZ_WHATSON_SAP_UPDATE_TRANSMISElement().modelObject().execute();
              // synchronise data in context with data in model
              wdContext.nodeOutput().invalidate();
         } catch (WDDynamicRFCExecuteException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
        //@@end

  • Fit functions with optionally fixed parameters?

    How can I fit functions ranging from a basic linear fit to any
    user-defined function to a set of x-y data with the option of keeping
    single fit parameters fixed (e.g. a known slope in a linear fit)? One
    possibility would be creating an according formula for the
    Levenberg-Marquard-algorithm each time a parameter is set to be fixed
    but that seems to be a bit inconvenient. Is there a simple approach to
    this problem, I guess I'm not the first to try it? Thanks a lot,
    Daniel

    dtroendle wrote:
    How can I fit functions ranging from a basic linear fit to any user-defined function to a set of x-y data with the option of keeping single fit parameters fixed (e.g. a known slope in a linear fit)? Is there a simple approach to this problem, I guess I'm not the first to try it?
    Daniel,
    I have modified the Lev-Mar routines long ago to allow the runtime selection of which paramters should be fixed and which should be held constant. It is not very difficult to implement. I use it to fit EPR spectra where the model can have up to ~30 parameters, but typically only less than 10 are fit while the rest are kept constant.
    Basically, I added a boolean array as input to Lev-Mar which has the same number of elements as the number of paramters of the model function. For each element, a TRUE means that the corresponding parameter should be fit while a FALSE means that the corresponding parameter should be held fixed at the value of the initial estimate.
    You just need to seperate out the reduced problem for the fitting part, but carry all parameters along for the model calculation.
    It works great!
    I am currently traveling in Japan and don't have access to my VIs. Please contact me next week by private e-mail (You can find my e-mail address on the FP of some of my examples posted here, e.g. HERE.
    LabVIEW Champion . Do more with less code and in less time .

  • How to execute a function with date parameter as an input?

    HI
    I have a function named fun1(v_fun in date), with date as an input parameter and it returns a number. I have created the function successfully. But i couldnt execute this function in sqlplus. How to pass the dates? Can any one help me in this regard.

    Hi,
    V11081985 wrote:
    HI
    I have a function named fun1(v_fun in date), with date as an input parameter and it returns a number. I have created the function successfully. But i couldnt execute this function in sqlplus. It's hard for me to say what you're doing wrong when I don't know what you're doing. Post a complete test script that people can run to re-create the problem and test their ideas. Include a function definition, CREATE TABLE and INSERT statements for any of your own tables (if necessary), and the results you want to get from that data, as well as your query.
    How to pass the dates? Can any one help me in this regard.You can call the function like this:
    SELECT  fun1 (hiredate)  AS fun1_results
    FROM    scott.emp
    ;

  • How to call a Stored Function with OUT parameter of %rowType from Java

    Hi everyone,
    I'm getting crazy trying to make this work.
    I have a function (not developed by me) in Oracle 10g declared in this way:
    type tab_RLSSP is table of TB_RLSSP_STOSTPRPAR_CL%ROWTYPE index by binary_integer;
    FUNCTION DBF_PERL_LISTA_PRATICHE (
    p_id_va IN NUMBER,
    p_seq_partita IN NUMBER,
    p_trattamento IN CHAR,
    lrec_RLSSP OUT tab_RLSSP ) RETURN NUMBER;
    And here is the code snipplet of my java method:
    sql="{? = call "+SCHEMA+PACKAGE+"."+FUNCTION_LIST+"(?,?,?,?)}";
    cs=connection.prepareCall(sql);
    cs.registerOutParameter(1, OracleTypes.NUMBER);
    cs.setLong(2,idVATitolare);
    cs.setLong(3,seqPartita);
    cs.setString(4,trattamento);// Caso Decesso
    cs.registerOutParameter(5, OracleTypes.OTHER);
    cs.executeQuery();
    result = (ResultSet) cs.getObject(5);
    if (result.next())
    listaPratiche.add(readPraticaPartita(result));
    The result (exception thrown at executeQuery with statement generated as
    SQL : {? = call PEDBA.DBK_PERL_RATEI_SUPPLETIVI.DBF_PERL_LISTA_PRATICHE(?,?,?,?)}:
    java.sql.SQLException: ORA-06550: line 1, column 13:
    PLS-00306: wrong number or types of arguments in call to 'DBF_PERL_LISTA_PRATICHE'
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored
    Changing to :
    sql="{call ? := "+SCHEMA+PACKAGE+"."+FUNCTION_LISTA+"(?,?,?,?)}";
    leading to
    SQL : {call ? := call PEDBA.DBK_PERL_RATEI_SUPPLETIVI.DBF_PERL_LISTA_PRATICHE(?,?,?,?)}
    don't change anything.
    What's wrong? Any suggestion?
    Edited by: 957158 on 5-set-2012 9.06

    >
    Taking for granted that it works, I wonder what's different, probably the output is defined as Cursor...
    >
    You mean because of this line?
    cs.registerOutParameter(5,OracleTypes.CURSOR);You can either use a cursor or use a function that returns a SQL type instead of the PL/SQL type.
    Here is sample code using a cursor
    CREATE OR REPLACE TYPE SCOTT.local_type IS OBJECT (
        empno   NUMBER(4),
        ename   VARCHAR2(10));
    CREATE OR REPLACE TYPE SCOTT.local_tab_type IS TABLE OF local_type;
    CREATE OR REPLACE PACKAGE SCOTT.test_refcursor_pkg
    AS
        TYPE my_ref_cursor IS REF CURSOR;
         -- add more cursors as OUT parameters
         PROCEDURE   test_proc(p_ref_cur_out OUT test_refcursor_pkg.my_ref_cursor);
    END test_refcursor_pkg;
    CREATE OR REPLACE PACKAGE BODY SCOTT.test_refcursor_pkg
    AS
         PROCEDURE  test_proc(p_ref_cur_out OUT test_refcursor_pkg.my_ref_cursor)
         AS
            l_recs local_tab_type;
         BEGIN
             -- Get the records to modify individually.
             SELECT local_type(empno, ename) BULK COLLECT INTO l_recs
             FROM EMP;
             -- Perform some complex calculation for each row.
             FOR i IN l_recs.FIRST .. l_recs.LAST
             LOOP
                 DBMS_OUTPUT.PUT_LINE(l_recs(i).ename);
             END LOOP;
             -- Put the modified records back into the ref cursor for output.  
             OPEN p_ref_cur_out FOR
             SELECT * from TABLE(l_recs);      
             -- open more ref cursors here before returning
         END test_proc;
    END;
    SET SERVEROUTPUT ON SIZE 1000000
    DECLARE
      l_cursor  test_refcursor_pkg.my_ref_cursor;
      l_ename   emp.ename%TYPE;
      l_empno   emp.empno%TYPE;
    BEGIN
      test_refcursor_pkg.test_proc (l_cursor);
      LOOP
        FETCH l_cursor
        INTO  l_empno, l_ename;
        EXIT WHEN l_cursor%NOTFOUND;
        DBMS_OUTPUT.PUT_LINE(l_ename || ' | ' || l_empno);
      END LOOP;
      CLOSE l_cursor;
    END;
    /

  • How to use LIKE function with a parameter in Oracle REPORT builder??

    how could i use parameter inside a LIKE function in Oracle reports builder?
    it works in SQL plus, but not in report builder!!
    Example:
    select code,desc from item_master where desc
    like '%&give_desc%'; ---works in SQL
    like '%:give_desc%' ---doesn't work in report builder!!

    Hi Renil,
    You will need to use the wildcard character (%) and the concatenation character (||) to join to your user parameter.
    i.e. like '%'||:give_desc||'%'
    Regards,
    John

  • Stored function with OUT parameter

    Hi there,
    anyone knows wether a stored function may have an OUT parameter other than a returning value and/or IN parameter.
    I think not but I've a doubt about it.
    Thanks
    Paolo Paolucci
    Oracle Consulting

    Mi h capitato sovente di utilizzare funzioni del tipo:
    Function PROVA
    ( param1 IN datatype,
    param2 OUT datatype DEFAULT default_value,
    param3 IN OUT datatype DEFAULT default_value)
    RETURN datatype IS.......
    Spero di aver interpretato bene la domanda, ciao
    null

  • How to make a customize form with optional parameter and left join

    Hi,
    I am trying to make a report with a left join. I also want ot have optional parameters in it.
    I am using the Create Reports From SQL Query method:
    SQL is :
    select ename, sal
    from scott.emp left join scott.dept
    on scott.emp.deptno = scott.dept.deptno
    where sal >= :lower_sal
    and sal <= :higher_sal;
    However, if I do it this way, I those 2 parameters are not optional.... How can I make them optional?
    If I use the Create Reports From Query Wizard method, I can make the parameters optional, but then I cannot do the left join...
    Thanks,
    Wilson

    hi,
    to catch null values on both sides I use:
    where nvl(sal,0) >= nvl(:lower_sal,nvl(sal,0))
    and nvl(sal,0) <= nvl(:higher_sal,9999999999)
    otherwise there will be no rows in the report where the value of sal is null, even if there are no selection criteria entered.
    regards Michael

  • How to create a function/procedure which can take optional parameter?

    Hi,
    I want to create a function or a procedure which can take optional parameters. For example, I want to create fun1() or fun1(param1) like this. Only one function will act differently when different number of parameters are passed to it. Something like the substr() function in oracle. It can be called with 2 parameters, as well as three parameters.
    Thanks in advance,
    Kiran

    There are two ways of doing this. The regular way would be to add a DEFAULT clause to your function declaration:
      -- Function can be called with 1 or 2 parameters
      FUNCTION xxxx
        ( param_one  NUMBER
        , param_two  VARCHAR2  DEFAULT NULL )
      RETURN VARCHAR2;Or, if your functions are declared in a package you can do some over-loading:
      PACKAGE yyyy
      IS
        -- Function with 1 parameter
        FUNCTION xxxx
          ( param_one  NUMBER )
        RETURN VARCHAR2;
        -- Function with 2 parameters
        FUNCTION xxxx
          ( param_one  NUMBER
          , param_two  VARCHAR2 )
        RETURN VARCHAR2;
      END;If you are calling server-side functions from client-side tools (like OracleForms) you may need to use this second method.

  • Optional Parameter - Oracle Package Throws an Error

    Hi there,
    I have an Oracle Package & it has a stored procedure with optional parameter. The calling code is in ColdFusion.
    When I run my webpage the Oracle throws below error.
    " [Macromedia][Oracle JDBC Driver][Oracle]ORA-06550: line 1, column 7: PLS-00306: wrong number or types of arguments in call to 'GET_CONTRACT_BY_DYN_SQL' ORA-06550: line 1, column 7: PL/SQL: Statement ignored "
    Calling Code (ColdFusion)
    <cfstoredproc procedure="CONTRACTS_PKG.GET_CONTRACT_BY_DYN_SQL" datasource="#REQUEST.dsn#">
         <cfprocparam cfsqltype="CF_SQL_INTEGER" type="in" value="1" variable="P_CONTRACTID">     
         <cfprocresult name="qDataDynSQL" resultset="1">
    </cfstoredproc>
    <br>Dynamic SQL Query:
    <cfdump var="#qDataDynSQL#" label="Dynamic SQL Query">
    Oracle Package
    create or replace
    PACKAGE CONTRACTS_PKG AS
    TYPE T_CURSOR IS REF CURSOR;
    PROCEDURE GET_CONTRACT_BY_DYN_SQL(P_CONTRACTID IN NUMBER, P_COLS IN VARCHAR2 DEFAULT '*', IO_CURSOR IN OUT T_CURSOR);
    END CONTRACTS_PKG;
    create or replace
    PACKAGE BODY CONTRACTS_PKG AS
    -- Get Contract Using Dynamic SQL
    PROCEDURE GET_CONTRACT_BY_DYN_SQL(P_CONTRACTID IN NUMBER, P_COLS IN VARCHAR2 DEFAULT '*', IO_CURSOR IN OUT T_CURSOR)
    IS
    V_CURSOR T_CURSOR;
    V_SQL VARCHAR2(200);
    BEGIN
    IF p_contractid > 0 THEN
    V_SQL := 'SELECT '|| P_COLS || ' FROM CONTRACTS WHERE contract_id = ' || P_CONTRACTID ;
    ELSE
    V_SQL := 'SELECT '|| P_COLS || ' FROM CONTRACTS';
    END IF;
    OPEN V_CURSOR FOR V_SQL;
    IO_CURSOR := V_CURSOR;
    END GET_CONTRACT_BY_DYN_SQL;
    END CONTRACTS_PKG;
    Does anyone knows why it throws an error? As you can see in the package header & body the parameter P_COLS has the default value as '*'.
    Looking forward to hear from someone.
    Thanks,
    Hitesh Patel

    931198 wrote:
    I have an Oracle Package & it has a stored procedure with optional parameter. The calling code is in ColdFusion.
    When I run my webpage the Oracle throws below error.Never mind the error - your approach is most definitely a candidate for Oracle WTF.
    Nothing sane about this approach. Especially the decision not to use bind variables and slowing down cursor processing significantly by burning a lot more CPU cycles on hard parsing and fragmenting the SQL Shared Pool in the process.
    Why not used MS Access instead? It is far more suited as a mickey mouse database for a goofy application?
    Why am I badmouthing your approach to Oracle? Because that is exactly the primary cause, the #1 reason, for poor Oracle performance and run-time problems dealing with Shared Pool fragmentation. It is something that many Oracle experts blog about, talk about, write about. It is addressed in numerous books, Oracle documentation, and even Oracle Support Notes.
    And despite the amount of information available on how to get the basics rights in using Oracle... this approach you are pursuing still refuses to die. So it deserves to be beaten with a lead pipe when it rears its ugly head here in this forum..

Maybe you are looking for

  • Insert statement not work for Excel file

    Hi, In my JDBC application, I have a "INSERT ..." statement to add a new recode to a Excel file. When I run this application, the statement is executed successfully(no Exception), however the excel file doesnot change at all. I am still able to run "

  • My InDesign file keeps failing to export to PDF

    I can't understand why my file won't export as a PDF.  My printer needs my file to be a PDF.

  • How to get and replace a key on Satellite A100-522?

    Hey Toshiba. I have a Toshiba Satellite A100-522 Model no. PSAA2E-01C01EED and one of my shift keys has broken down under, so i cant use it (The small plastic bar to balance the key is broken so the key "hangs". I can send it to repair under the guar

  • Why does Lion open everything each time I start my MacBook?

    Every time I turn on my MacBook, Lion opens my calendar, email, my virtual computer, etc.  Each time I shutdown, I uncheck "Reopen windows when logging back in".  The next time I startup, all is well, but then the next time I shutdown, the "Reopen wi

  • How to export saved passwords to chrome10

    ''Duplicate post, continue here - [http://support.mozilla.com/en-US/questions/810624]'' how do i export saved passwords from ff4 to chrome10