Passing parameter to Function in select clause BIP 11g

Hi,
I am developing a dataset where i ahave to pass Parameter to a function which retrives the cursor in BIP 11g
below is the SQL:
select cizcompfn(:P_USER_ID) COMPANY_INFO,
cizinstfn(:P_REPORT_CD, :P_USER_ID) CURRENCY_INFO,
sysdate AS PRINT_DATE_TIME_INFO,
cizlballfn(:P_REPORT_CD, :P_USER_ID) LABEL_INFO,
cipacsvpfn(:P_USER_ID, to_char(:P_FROM_DT,'yyyy-MM-dd') ,
to_char(:P_TO_DT, 'yyyy-MM-dd')) RETURN_CODE_INFO, rpt_option_val SERVER
FROM ci_rpt_option where rpt_opt_flg = 'RPSV'
I have created the 4 parameters :P_USER_ID, :P_REPORT_CD , :P_FROM_DT and :P_TO_DT
I am not getting the result generated.
If develop the dataset in BIP 10g, this working fine.
Please, let me know what needs to changed so that it works in BIP11g.
Regards,
Hemanth

I am getting the result like this:
<?xml version="1.0" encoding="UTF-8" ?>
- <!-- Generated by Oracle BI Publisher 11.1.1.5.0
-->
- <DATA_DS>
<P_TO_DT>2010-01-01T00:00:00.000-05:00</P_TO_DT>
<P_FROM_DT>2000-01-01T00:00:00.000-05:00</P_FROM_DT>
<P_REPORT_CD>CI_ACSVPR</P_REPORT_CD>
<P_USER_ID>CDX</P_USER_ID>
- <G_1>
<PRINT_DATE_TIME_INFO>2012-05-11T07:22:57.000-04:00</PRINT_DATE_TIME_INFO>
<SERVER>http://server-name:port-number</SERVER>
</G_1>
</DATA_DS>
Value for two columns:
sysdate AS PRINT_DATE_TIME_INFO
rpt_option_val SERVER
which are straight forward columns.
When i pass hardcoded values instaed of parameters I get the XML:
Below is the SQL:
select cizcompfn('CDX') COMPANY_INFO, cizinstfn('CI_ACSVPR', 'CDX') CURRENCY_INFO, sysdate AS PRINT_DATE_TIME_INFO,
cizlballfn('CI_ACSVPR', 'CDX') LABEL_INFO,
cipacsvpfn('cdx', to_char('05-may-1900') ,to_char( '05-may-2012')) RETURN_CODE_INFO,
rpt_option_val SERVER from ci_rpt_option where rpt_opt_flg = 'RPSV'
Edited by: 931007 on May 11, 2012 7:29 AM

Similar Messages

  • How to pass parameter in Function by using select statement?

    Hi,
    I got a problem. I cant pass in parameter to function by using select statement. But it can pass in parameter by using 'hardcode' method. How can I solve this problem?
    Eg,
    select * from table (SplitFunction('HS750020,HS750021')) <<< this work.
    but
    select * from table (SplitFunction(select LOT_NO from TRACER_SEARCH_SCHEDULE where JOB_ID = '36')) <<< do not work.
    Thanks for who try to help. Thanks.

    skymonster84 wrote:
    I have try this before. But it not work.here is an example
    create or replace type stringlist as table of varchar2(100)
    create or replace function splitstring(pstring in varchar2) return stringlist
    as
      lstringlist stringlist;
    begin
      select regexp_substr(pstring,'[^,]+',1, level) bulk collect into lstringlist
        from dual
      connect by level <= length(pstring)-length(replace(pstring,','))+1;
      return lstringlist;
    end;
    select * from table(select splitstring('xx,yy,zz') from dual)
    create table t(str varchar2(100))
    insert into t values('x,y,z')
    insert into t values('a,b,c')
    select * from table(select splitstring(str) from t where rownum<2)
    /If you supply multiple values then it will fail.
    select * from table(select splitstring(str) from t)
    /

  • How to pass parameters to function in  where clause....

    I have a select statement like this
    SELECT XX_AIR_TICKET_EMP_BAL(:P2) from dual
    is it possible to pass to variable p2 from where clause
    like
    SELECT XX_AIR_TICKET_EMP_BAL(:P2) from dual
    where :p2 = :p1
    user can enter only in p1 so that p2 should get passed.
    Reson for this wierd requirement:In Oracle apps i cant use bind variable in select clause value set..? please ignore this reason if u are not in oracle apps...
    Tell me the solution..
    Is there any way...
    setting some env variavle aor anything

    [email protected] wrote:
    I have a select statement like this
    SELECT XX_AIR_TICKET_EMP_BAL(:P2) from dualWhy a SELECT statement? This calls the SQL engine. The function is PL/SQL. This now needs the SQL engine to context switch to the PL engine. The PL engine runs and returns a value (across memory boundaries) to the SQL engine. The SQL engine now needs to return that value as part of the output from a SQL cursor.
    Why do all this? Surely it is a lot easier and better for performance to call the PL engine directly using an anonymous PL block. E.g.
    begin
      :P3 := XX_AIR_TICKET_EMP_BAL(:P2);
    end;
    is it possible to pass to variable p2 from where clause
    like
    SELECT XX_AIR_TICKET_EMP_BAL(:P2) from dual
    where :p2 = :p1Why?
    This can be done as part of the PL block as follows:
    begin
      if :P2 = :P1 then
        :P3 :=  XX_AIR_TICKET_EMP_BAL(:P2);
      end if;
    end;But then why construct conditional statements dynamically?
    It would be a lot easier to have a new function that does the condition, e.g.
    create or replace function getAirTicket( p1 number, p2 number ) return number is
    begin
      if p1 = p2 then
        return( XX_AIR_TICKET_EMP_BAL(p2) );
      else
       return( null );
      end if;
    end;

  • Passing parameter in function module

    hi friends,
    I have created one function module in which i need to pass PO/SO number from standard EKKO/VBAK tables through the select option parameter S_POSONO. Inside the function module I have a select query which fetches the records from a Z-table which has a field called 'REFERENCE' which is 16-char long. Hence the length mismatches with PO/SO no which is 10-char long. the first 10-char from 'REFERENCE' is PO/SO number, next 3-char is line-item num, and the last three char is schedule item num. It is required to match only first 10-char with the parameter passed i.e, S_POSONO and display only those datas.
    The function module is as follows.....
    Function :
    CALL FUNCTION 'YFIIN_RETRIEVE_SOURCE_DATA'
    EXPORTING
       LT_RANGE_BUKRS          = S_BUKRS[]
       LT_RANGE_DOCNO          = S_POSONO[]
       LT_RANGE_DOCDATE        = S_DATUM[]
       LT_RANGE_CURRENCY       = S_FCURR[]
      TABLES
        IT_TEMEXPOSU            = LT_TEMEXPOSU
    EXCEPTIONS
       INVALID_SELECTION       = 1
       OTHERS                  = 2.
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    Source code inside function module:
      SELECT * FROM ZFIGL_TEMEXPOSU INTO  TABLE IT_TEMEXPOSU
                                     WHERE   COMPANY_CODE IN LT_RANGE_BUKRS
                                     AND  currency in LT_RANGE_CURRENCY
                                     and  REFERENCE in LT_RANGE_DOCNO
                                     and  doc_date in LT_RANGE_docdate.
    IF SY-SUBRC = 0.
    SELECT COMPANY_CODE ATTRIBUTE_01 REFERENCE CREATION_DATE FOREIGN_CURR                                                               
               FROM TEMT_RAWEXPOS APPENDING CORRESPONDING FIELDS OF
                   TABLE IT_TEMEXPOSU WHERE COMPANY_CODE IN  LT_RANGE_BUKRS
                                     AND REFERENCE in LT_RANGE_DOCNO
                                     AND CREATION_DATE IN  LT_RANGE_DOCDATE
                                     AND FOREIGN_CURR IN LT_RANGE_CURRENCY.
       ENDIF.
    Import Parameter of Function Modules :
    LT_RANGE_BUKRS   - type - BUKRS
    LT_RANGE_DOCNO  - type - EBELN
    LT_RANGE_DOCDATE - type - DOKDATS
    LT_RANGE_CURRENCY - type - WAERS
    please help me to solve this problem..

    Hi Ram Tej,
    Try this.
    First Read all the records without Checking REFERENCE field with LT_RANGE_DOCNO into an internal Tbale.
    Then looping at that internal table delete records from the same internal table where REFERENCE(10) <> LT_RANGE_DOCNO.
    Hope this may help ur requirement.
    Award points if useful.

  • How to use a function in select clause

    hi gems...good evening...
    I want to write a select clause from a function. The scenario is like below:
    function parameters
    CREATE OR REPLACE FUNCTION FUNCTION_DEMO(p_pid IN NUMBER,
    p_bankerNum IN NUMBER,
    p_banker_name IN VARCHAR2,
    p_business_num IN NUMBER,
    p_businesses IN table_typ_businesses)
    return table_typ_bankers
    as .......
    global object and table types
    CREATE OR REPLACE TYPE obj_typ_businesses AS OBJECT (businesses NUMBER);
    CREATE OR REPLACE TYPE table_typ_businesses AS TABLE OF obj_typ_businesses;
    CREATE OR REPLACE TYPE obj_typ_bankers AS OBJECT (banker_num NUMBER(10,0));
    CREATE OR REPLACE TYPE table_typ_bankers IS TABLE OF obj_typ_bankers;
    The select query
    select * from
    table(cast(FUNCTION_DEMO(1,
    2,
    'ALEX',
    2,
    table(cast(select businesses_id from reference_businesses) as table_typ_businesses) as table_typ_bankers)But it is giving error with Missing expression.
    My function is compiled successfully. I just want to make the select query to view the output given by the function i.e the table type "table_typ_bankers".
    Please help...thanks in advance..

    Hi ,
    You can check this and change your code by taking this as an example. I just noted down with simple one input and return as collection type
    and how to use/call it in select statement.
    SQL> CREATE OR REPLACE TYPE obj_typ_businesses AS OBJECT (businesses NUMBER)
      2  /
    Type created.
    SQL> CREATE OR REPLACE TYPE table_typ_businesses AS TABLE OF obj_typ_businesses
      2  /
    Type created.
    SQL> CREATE OR REPLACE TYPE obj_typ_bankers AS OBJECT (banker_num NUMBER(10,2))
      2  /
    Type created.
    SQL> CREATE OR REPLACE TYPE table_typ_bankers IS TABLE OF obj_typ_bankers
      2  /
    Type created.
    /* Now creating a demo function and just focusing on your one input as collection type  */
    SQL> create or replace function f11 ( tab_rec  IN table_typ_businesses)
      2  return table_typ_bankers
      3  is
      4  t_val table_typ_bankers:= table_typ_bankers();
      5  begin
      6        dbms_output.put_line('tab_rec count -'||tab_rec.count);
      7
      8  for i in 1..tab_rec.count
      9              loop
    10               dbms_output.put_line ('tab_rec value ('||i||')'||tab_rec(i).businesses);
    11                       t_val.EXTEND;
    12                    t_val(i) := obj_typ_bankers(tab_rec(i).businesses * 12.50);
    13              end loop;
    14              return t_val;
    15  end;
    16  /
    Function created.
    /* To run your function by a select statement */
    SQL> SELECT * FROM TABLE(f11(table_typ_businesses(obj_typ_businesses(5),
      2                          obj_typ_businesses(12),
      3                                         obj_typ_businesses(18))
      4                                             ) )
      5  /
    BANKER_NUM
          62.5
           150
           225
    tab_rec count -3
    tab_rec value (1)5
    tab_rec value (2)12
    tab_rec value (3)18Hope this will help you... :)
    Thanks!
    Ashutosh

  • Passing parameter to function

    Hi All
    I created a custom folder in a business area through discoverer administrator. In this folder one column is returned by
    the funtion.
    I am passing three parameters parameter1, parameter2, parameter3 to this funtion these 3 parameters are used
    in an sql where clause in the function.
    I would like to pass the 4th parameter to the function this parameter is input by the user while running the discoverer
    report from discoverer desktop. Is there any way that I can pass the user parameter value to the function, or any
    alternative solution for this problem.
    Thanks in advance
    Regards
    Ali

    Hi Ali
    You create the function in teh database and then grant the appropriate Discoverer roles or account execute permission over the function. You also need to make sure that the Discoverer Administrator has this privilege too.
    With the function created you bring it into Discoverer. Here's a workflow:
    1. Log in as the administrator to Discoverer Administrator
    2. Select Tools | Register PL/SQL Functions to open the PL/SQL Functions dialog box
    3. With the dialog box open, click the Import button
    4. In the Import PL/SQL Functions box, type the name name of the user that owns the function and then click the Go button - Discoverer will now display a list of the functions.
    5. Highlight the one you want and then click the OK button.
    6. Back in the main box, click the Validate button to make sure Discoverer is able to use it
    7. Once validated, click the OK button to complete the import and close the box
    With the function imported it will now appear in Plus in the Database folder of funxtions when creating a calculation.
    Best wishes
    Michael

  • How pass parameter to function

    I have created function name is 'Funsepratecolumvaue'
    and I took one parameter, I want to pass this parameter out put of below variable, how can i do
    declare @para varchar(500);
    set @para='select rawRow from sepratecolumvaue'
    I tried like this  
    select * from Funsepratecolumvaue (@para)
    but directly passed select query

    Is this something you are looking for?
    Yes, you can with the help of apply clause.
    CREATE FUNCTION dbo.fnSplit(
    @sInputList VARCHAR(8000) -- List of delimited items
    , @sDelimiter VARCHAR(8000) = ' ' -- delimiter that separates items
    ) RETURNS @List TABLE (item VARCHAR(8000))
    BEGIN
    DECLARE @sItem VARCHAR(8000)
    --declare @sDelimiter varchar(8000) = ' '
    WHILE CHARINDEX(@sDelimiter,@sInputList,0) <> 0
    BEGIN
    SELECT
    @sItem=RTRIM(LTRIM(SUBSTRING(@sInputList,1,CHARINDEX(@sDelimiter,@sInputList,0)-1))),
    @sInputList=RTRIM(LTRIM(SUBSTRING(@sInputList,CHARINDEX(@sDelimiter,@sInputList,0)+LEN(@sDelimiter),LEN(@sInputList))))
    IF LEN(@sItem) > 0
    INSERT INTO @List SELECT @sItem
    END
    IF LEN(@sInputList) > 0
    INSERT INTO @List SELECT @sInputList -- Put the last item in
    RETURN
    END
    GO
    create table table1
    id int,
    name char(10),
    dept varchar(20))
    insert into table1 values(1,'aa','1,2,3,4,5')
    insert into table1 values(3,'bb','1,2,3')
    select * from table1
    OUTER APPLY dbo.fnSplit(dept,',') p
    --Prashanth

  • Passing Parameter to Function - ORA-00904

    Hi - I wonder if anyone can help with this problem please?
    I have developed a function, which works fine, returning a collection as a table. It takes a single parameter, the numeric userid. I've put a report on the page, and hardcoded the userid during testing:
    SELECT rec_id, period_id, proj_id, proj_name, hrs_last_week, hrs_this_week
    FROM TABLE (SELECT tr_return_user_times(364) AS TR_USERTIMES_TAB
    FROM DUAL)
    This works great, and shows the data perfectly. So the next step, was to set up a variable to hold the userid of the person within the application. I've an application item named F155_USERID. If I display this on the page, I am happy that the value is as expected. However, when I put the variable into the function call, it won't parse:
    SELECT rec_id, period_id, proj_id, proj_name, hrs_last_week, hrs_this_week
    FROM TABLE (SELECT tr_return_user_times(:F155_USERID) AS TR_USERTIMES_TAB FROM DUAL)
    now gets the error:
    Query cannot be parsed within the Builder. If you believe your query is syntactically correct, check the ''generic columns'' checkbox below the region source to proceed without parsing.
    If I switch to use generic columns, and run the debug, the item does substitute ok, (i.e. 0.04: binding: ":F155_USERID"="F155_USERID" value="364")
    but I get
    report error: ORA-00904: "TR_RETURN_USER_TIMES": invalid identifier
    If I run the command in TOAD, and put in the same value (364) when prompted for the variable substitution, again, it works fine. This has to be something really simple, but it's cost me a few hours now - I am tearing my hair out (and at my age there's no guarantee it will grow back). Any help appreciated!

    Found it!
    Denes Kubicek is a god. Found a note on his blog. (http://www.deneskubicek.blogspot.com/)
    The answer is
    v('F155_USERID')

  • On selection A I5Grid Row initiate I5Grid B by passing parameter column 3 of selected Row

    Dear Guru,
               I want to initiate I5Grid B on selection of I5Grid A Row hard code value of column 3.
    Which function I has to use for button I can use press function but on I5Grid click which function or code will be applicable.
    Thanks
    Muhammad Ashfaq

    You can find out about all the i5Grid's events and methods here: i5Grid - SAP Library
    Regards,
    Christian

  • Passing parameter to function on stage from symbol

    I have a symbol on the stage: symbol1
    Inside symbol1 I have an image: symbol1_image1
    I have another symbol on the stage: symbol2
    Inside symbol2 I have an image: symbol2_image2
    in composition.ready I have an action on the mouseout for symbol1:
    var theTarget = sym.getComposition().getStage().getSymbol('symbol2').$('symbol2_image2');
    sym.getComposition().getStage().doMouseoutGS(theTarget);
    In composition.ready i have the following function defined
    sym.doMouseout = function (colorTile){
    sym.$(colorTile.show());
    I cannot get this to work and I am not understanding why.
    If I do an alert on the mouseout function for
    alert($(colorTile).attr("id"));
    I get the correct referenc to the element I want to show but it does not actually  happen

    Hi Marlene,
    As I already mentionned in a preceding reply in another of your threads, you should use the event object e that gives you access to the target (e.target), without the need to explicitly build a theTarget variable.
    For example, say you want to factorize in a symbol (stage) function the rollover behavior shared by a certain number of buttons :
    • btn<i>.mouseover
    sym.getComposition().getStage().globalFunction( e);
    • document.compositionReady
    sym.globalFunction = function( eBtn)
      console.log( eBtn.target.getAttribute(“id“));
    Then, using Firebug or Chrome dev. tools, you'll see in the console the id of each of the buttons you hover over.
    Gil

  • How to pass parameter to function when confirm(Alert.show) closed?

    <![CDATA[
    import mx.controls.*;
    import mx.events.*;
    private function deleteItem(guid:String):void
    Alert.show("Are sure you want to delete?", "Confirm Delete", Alert.YES|Alert.NO, this, alertClicked);
    private function alertClicked(event:CloseEvent) {
    if(event.detail == Alert.YES) {
      Alert.show("yes "+guid); //<-- here I want to get guid
    else if (event.detail == Alert.NO){
      Alert.show("no ");
      return;
    ]]>
    Thanks.

    Hi Itambs,
    You can do the following:
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="deleteItem('Dummy GUID VALUE')">
    <mx:Script>
      <![CDATA[
       import mx.controls.*;
       import mx.events.*;
       private var myAlert:Alert;
       private function deleteItem(guid:String):void
        myAlert = Alert.show("Are sure you want to delete?", "Confirm Delete", Alert.YES|Alert.NO, this, alertClicked);
        myAlert.data = guid;
        myAlert.height = 150;
                    myAlert.width = 300;
       private function alertClicked(event:CloseEvent):void{
        if(event.detail == Alert.YES) {
           //Alert.show("yes "+guid); //<-- here I want to get guid
           Alert.show("yes "+ myAlert.data);
        else if (event.detail == Alert.NO){
           Alert.show("no ");
           return;
      ]]>
    </mx:Script>
    </mx:Application>
    Note: you can also do this in another way by decalring a global variable guid as ...... private var _guid:String="";
    set _guid = guid; in deleteItem() function and then in alertClicked() function you can access the value as _guid again...which holds the saved value...
    If this post answers your question or helps, please kindly mark it as such.
    Thanks,
    Bhasker Chari

  • Passing parameter into select statement by using function in discoverer

    I have created two functions in database named Period_in and Period_out and a global variable  g_period_name
    I have called Period_out function in VIEW(Select statement where condition).
    I have registered Period_in function in discoverer admin then created calculation (called Period_in(:input parameter))in discoverer plus.
    My expectation is user will enter period name and that will hit Period_in function and returns 1 and stores entered period name in g_period_name at runtime. then VIEW will executed and fetches data.
    But i am getting no data found.
    Problem is 2 functions running at the same time in select statement. Please help me to overcome this. Thanks in advance
    FUNCTION period_in (p_period VARCHAR2)
          RETURN NUMBER
       AS
       BEGIN
          g_period_name := p_period;
          RETURN 1;
       END period_in;
       FUNCTION period_out
          RETURN VARCHAR2
       AS
       BEGIN
          RETURN g_period_name;
       END period_out;

    You can use this code: 
    WITH cte
    AS ( SELECT EmpID ,
    EmpName ,
    [dbo].[udf_testFunction](EmpID) AS testfunctionvalue
    FROM #Temp
    SELECT EmpID ,
    EmpName ,
    testfunctionvalue ,
    testfunctionvalue * EmpID ,
    testfunctionvalue + 2
    FROM cte
    But using scalar functions in select clause can hurt the performance. Please see this link: 
    SQL Server Scalar User Defined Function Performance
    T-SQL Articles
    T-SQL e-book by TechNet Wiki Community
    T-SQL blog

  • Using function in select statement

    Hi,
    CREATE FUNCTION [dbo].[udf_testFunction] 
    @value int
    RETURNS int
    AS
    BEGIN
    -- Declare the return variable here
    declare @returnValue int
    set @returnValue = @value*2;
    return @returnValue;
    END
    GO
    create table #Temp
        EmpID int, 
        EmpName Varchar(50)
    insert into #Temp(EmpID,EmpName) values(1,'Name1');
    insert into #Temp(EmpID,EmpName) values(2,'Name2');
    insert into #Temp(EmpID,EmpName) values(3,'Name3');
    insert into #Temp(EmpID,EmpName) values(4,'Name4');
    insert into #Temp(EmpID,EmpName) values(5,'Name5');
    select EmpID,EmpName, [dbo].[udf_testFunction](EmpID), [dbo].[udf_testFunction](EmpID)*EmpID,[dbo].[udf_testFunction](EmpID)+2 from #Temp
    In the above select statement i used [dbo].[udf_testFunction]() function 3 times. But i want to use only once and reuse it.
    Something like 
    select EmpID,EmpName, testfunctionvalue,testfunctionvalue*EmpID,testfunctionvalue+2 from #Temp
    Please advise me.... Thanks in Advance...

    You can use this code: 
    WITH cte
    AS ( SELECT EmpID ,
    EmpName ,
    [dbo].[udf_testFunction](EmpID) AS testfunctionvalue
    FROM #Temp
    SELECT EmpID ,
    EmpName ,
    testfunctionvalue ,
    testfunctionvalue * EmpID ,
    testfunctionvalue + 2
    FROM cte
    But using scalar functions in select clause can hurt the performance. Please see this link: 
    SQL Server Scalar User Defined Function Performance
    T-SQL Articles
    T-SQL e-book by TechNet Wiki Community
    T-SQL blog

  • Is passing parameter to ORDER BY clause possible?

    I'm using a function to return a ref cursor and currently pass a parameter without any problems. I would like to change the sort on the fly by passing a parameter to the order by clause, but Oracle ignores it.
    CREATE OR REPLACE PACKAGE pkg_agent_appt_status AS
    TYPE rcur IS REF CURSOR;
    FUNCTION f_agent_appt_status (ssn IN VARCHAR2, sort_str IN VARCHAR2) RETURN rcur;
    END pkg_agent_appt_status;
    CREATE OR REPLACE PACKAGE BODY pkg_agent_appt_status AS
    FUNCTION f_agent_appt_status (ssn IN VARCHAR2, sort_str IN VARCHAR2)
    RETURN rcur
    IS
    retval rcur;
    BEGIN
    OPEN retval FOR
    SELECT agncy.CORPORATE_NAME "Agency Name",
    agnt_state.APPT_STATE "State",
    agnt.AGENT_STATUS "Appt Status",
    TO_CHAR(agnt_state.APPT_STATE_EFF_DT,'mm/dd/yyyy') "Effective Date",
    agnt.AGENT_NUMBER "Agent ID",
    agnt.AGENT_STATUS "Agent Status",
    STATE.STATE_NAME
    FROM AGNT_APPT_STAT_PRDCR_WRK agnt,
    AGNT_APPT_STAT_WRK agncy,
    AGNT_APPT_STATE_STAT_PRDCR_WRK agnt_state,
    STATE
    WHERE agnt.AGENT_TAX_ID = ssn
    AND agnt.COMPANY_CODE = agncy.COMPANY_CODE
    AND agnt.PARENT_AGENT_AGENCY_ID = agncy.AGENT_NUMBER
    AND agnt.COMPANY_CODE = agnt_state.COMPANY_CODE
    AND agnt.AGENT_AGENCY_ID = agnt_state.AGENT_AGENCY_ID
    AND agnt.AGENT_NUMBER = agnt_state.AGENT_NUMBER
    AND agnt_state.APPT_STATE = STATE.STATE_CODE
    ORDER BY
    sort_str;
    RETURN retval;
    END f_agent_appt_status;
    END pkg_agent_appt_status;

    This is quite easy, as you are already using a REF CURSOR. Instead of
    OPEN retval FOR
    SELECT ...
    ORDER BY sort_str;we can code this:
    OPEN retval FOR
    'SELECT ...
    ORDER BY '|| sort_str;Watch out for the single quotes in your query e.g. the date format mask: you need to wrap these in an additional set of single quotes i.e. 'mm/dd/yyyy' becomes ''mm/dd/yyyy''.
    Cheers, APC

  • Pass table name as a parameter to function

    Is there a way to pass table name as a parameter to functions? Then update the table in the function.
    Thanks a lot.
    Jiaxin

    Hi, Harm,
    Thank you very much for your suggestion and example. But to get my program work, i need to realise code like follows:
    CREATE OR REPLACE FUNCTION delstu_func(stuno char) RETURN NUMBER AS
    BEGIN
    EXECUTE IMMEDIATE 'DELETE FROM student s' ||
    'WHERE' || 's.student_number' || '=' || stuno;
    LOOP
    DBMS_OUTPUT.PUT_LINE('record deleted');
    END LOOP;
    END;
    SELECT delstu_func('s11') FROM STUDENT;
    The intention is to check if such a function can perform operations such as update, delete and insert on occurence of certain values. When executing the above statement, the system returns an error message:
    ERROR at line 1:
    ORA-00933: SQL command not properly ended
    ORA-06512: at "SCMJD1.DELSTU_FUNC", line 3
    Could you tell me where is wrong?
    Jiaxin

Maybe you are looking for

  • How to send a message with Send-MailMessage cmdLet powershell exchange which uses a html file as a parameter

    Before the mailboxes migration E2003 toward E2010 SP2, I have to send a mail which body already exists as a html file. Here the powershell I currently use : import-csv d:\path\TestLot.csv  | foreach {Send-MailMessage -To $_.PrimarySmtpAddress -From [

  • Can we rename an exisiting target in Grid Control

    Hello Gurus We are upgrading a database from 10.2.0.5.0 to 11.2.0.2.0 and we are going to change the SID of the environment. I wanted to know if it was possible to change the target name (so that we can keep all historical data of the previous databa

  • Is there any way to forcibly/manually upgrade to Mavericks?

    Header 1 I have an early 2007 iMac (check the specs in the picture). I was ecstatic when I heard Mavericks was coming out but when I saw that I could not upgrade because it required a Mid 2007 iMac I freaked out. I am only off by a few months; I am s

  • How do I send a fax with OSX?

    Up until now I have been using FXStff, and a modem. With changes on my dedicated fax phone line, I can only use 120 minutes a month of prepaid service. If I use the next plan, they will detect my faxing, and kick me off the plan. So much for helping

  • Complex algorithm - improve performance

    HI, I have a complex algorithm which takes almost 900 milliseconds per line to process this . I have to calculate the probability for hundreds of thousand lines. Just imagine if have to calculate this for some 500000 lines which is not feasilble at a