Lexical Parameter in Reports 6i Program Unit

A report I'm writing requires me to use the lexical parameter in a program unit rather than a query in the data model. Lexical parameters in a query have always worked with the example "WHERE &my_parameter". But using "WHERE :my_parameter" or "WHERE &my_parameter" in a program unit gave me the error "expression is of wrong type" so the code wouldn't compile in the editor.
The parameter returns "segment1 = '8675309' AND segment2 = 'Jenny'I was able to resolve it by using the first column of the expression and the replace function on the parameter so the program unit editor thinks it's a valid expression and the resulting line is a valid predicate that gets the correct data. Here's my example:
WHERE segment1 = replace(:my_parameter, 'segment1 = ')The replace function strips off the "segment1 = " from the lexical parameter so the resulting line that gets passed to the server is:
WHERE segment1 = '8675309' AND segment2 = 'Jenny'This solution will not work where the parameter could return something other than "segment1 = " at the beginning of the parameter string like "segment1 BETWEEN " or a different column name to compare other than segment1. Anyway, this is working but if there are better ways to do it I'd like to try them. Using Reports 6i with EBS 11.5.10.2.

Hello,
You'll find explanations and examples here :
http://www.oracle.com/webapps/online-help/reports/10.1.2/topics/htmlhelp_rwbuild_hs/rwwhthow/whatare/dmobj/sq_a_lexical_references.htm
This documentation is for Reports 10.1.2 but is valid for Reports 6i too ...
Regards

Similar Messages

  • How to use lexical parameter in report

    i want to use lexical parameter in report and pass parameter from form how it is possible in detail
    A.R

    Hi,
    typically you fill your lexical paramter in the after-paramform-trigger out of the values of your bind-parameters (giving end users directly control over lexical parameters might not be a good idea). Inside PL/SQL a lexical parameter is referenced like bind parameters with ":". In the query it's referenced via "&" and represents a part of the query.
    A simple example.
    - p_deptno as bind parameter
    - p_where as lexical paramter
    - end user choose value for p_deptno (10,20,... or nothing)
    - Trigger: if :p_deptno is not null then
    :p_where := 'WHERE deptno = :p_deptno'
    else
    :p_where := null;
    end if;
    - Query select ... from emp &p_where
    Regards
    Rainer

  • Lexical Parameter in report 10g

    i want to call a report with few fields on my form. i create 2 user parameter which works fine. now i want to create a lexical parameter so that if null no problem report should appear with 2 user parameters but if has values then report should be called according to those parameter values.
    I use this in my form:
    SET_REPORT_OBJECT_PROPERTY(repid,REPORT_OTHER,'PBRANCHCODE='||:txtBranchCode||' PPERIOD='||:cmbPeriod||' CLASSCONDITION='||'cla_class_id between 1 and 2'||' paramform=no');
    CLASSCONDITION is a lexical parameter which is called in report sql:
    and periodic_branch_id = :pBranchCode
    and periodic_period_from = :pPeriod
    &ClassCondition
    it says unable to run report
    when i test using paramform=no then it shows in classcondition parameter only and and nothing after space assuming parameter list ended.
    Please help me in passing a lexical parameter to report
    Thanx in advance.

    I want to append the where condition of the report. if values inputed from Form in the class ids from and to text boxes appended as a where condition in the report query otherwise excluded
    Report Query
    select *
    from ...
    where
    and .....
    and ....
    &ClassCondition
    and i want to pass &classcondition parameter the below condition
    and class_id between :fromclass and :toclass
    Hope you understand.

  • How to reference Report level program unit in report query?

    I have created a report level function FREF13 which returns a VARCHAR2 variable. I am trying to reference this function in report SQL statement like:
    select * from wtr where file_ref = FREF13(:fref)
    I am getting error 'ORA-00904: Invalid column name' error. This is because it is unable to recognize FREF13 as local function.
    Is it possible to reference local program units in report query?
    Rgds,
    Manish

    No, it's not possible. The only things you can reference in a SQL query are columns and functions accessable in the database (since this is where the query is executed). You should create the function in the database.
    Regards,
    Danny

  • Passing where clause  to lexical parameter in report

    I have a requirement to send the values of lexical parameters in reports from Forms 6i , like i have written one query in report builder with lexical clause being where.Now i want to pass this where clause as a whole from forms 6i, for example.
    select asset_code,asset_name from fix_asset @p_status
    now i want to pass this p_status from forms 6i which has 1 radio group with 3 values , if i select value 1 then where nvl(at_status,'X') = 'X' ,if i select value 2 or radio button 2 then where nvl(at_status,'X')='Y' and if i select 3 then both x and y should come together.Edited by: 998476 on Jun 5, 2013 12:01 AM

    I have a Before trigger Function to which the parameters will be passed.
    Suppose if User selects multiple values for a parameter then how to pass these multiple Values to that parameter?
    eg:In first Workbook Before Trigger is fired and the paramters for the trigger are
    'par1','par2','par3' etc.
    If User selects multiple values for a parameter 'par1' from the list of values displayed then how to pass all these values to 'par1' in Function?
    After firing the trigger rows are inserted in a temp_table .My second Workbook will
    fetch the rows inserted in this Temp Table.
    I hope u understood what my requirement is...
    Thanks in advance

  • Calling report from form with lexical parameter

    hi
    DECLARE
         repid REPORT_OBJECT;
         v_rep VARCHAR2(1000);
         rep_status VARCHAR2(20);
    BEGIN
              repid := FIND_REPORT_OBJECT( 'REPORT34' );
              set_report_object_property(repid,report_other,'p_SEASON_YEAR='||:SALE_ORDER.SEASON_YEAR
              ||' &sort='||:sale_order.sort1);
              --set_report_object_property(repid,report_other,'p_g_id =20');
              v_rep := RUN_REPORT_OBJECT(repid);
              rep_status := REPORT_OBJECT_STATUS(v_rep);
    WHILE rep_status in ('RUNNING','OPENING_REPORT','ENQUEUED')
    LOOP
    rep_status := report_object_status(v_rep);
    END LOOP;
    IF rep_status = 'FINISHED' THEN
    --Display report in the browser
    WEB.SHOW_DOCUMENT('http://127.0.0.1:8889/reports/rwservlet/getjobid'||
    substr(v_rep,instr(v_rep,'_',-1)+1)||'?'||'server=repserver90','_blank');
    ELSE
    message('Error when running report');
    END IF;
    PAUSE;
    END;i had made a lexical parameter in reports the reports code is
    SELECT s.season_year,sd.prod_id,P.PROD_NAME,sum(sd.total_qty)
    FROM sale_order s,sale_order_detail sd,PRODUCT P,CUSTOMER_MASTER cm,CUSTOMER_DETAIL cd
    where s.id=sd.id and P.PROD_ID=SD.PROD_ID AND s.season_year = :p_season_year
    AND CD.CUST_ID=CM.CUST_ID AND CD.CUST_ID=S.CUST_ID AND CD.COUNTRY NOT LIKE 'SPA%' AND Sd.PROD_ID LIKE  'CA%'
    group by s.season_year,sd.prod_id,P.PROD_NAME
    &sortthanks and regards
    vikas

    Vikas,
    So, is your code producing an error when your report is called? Also, it would be helpful to know your Forms and Reports versions. Is ":p_season_year" set up as a USER_PARAMETER (UP) in your report or is it a true lexical parameter (meaning you should reference it with '&' instead of ':')? If it is a UP, the typical way to pass a value to this UP from Forms is to use a ParamList object instead of the REPORT_OTHER parameter of the Set_Report_Object_Property built-in. For example:
    DECLARE
       pl_id    ParamList;
       pl_name  VARCHAR2(10) := 'REPORT34';
       v_rep VARCHAR2(1000);
       rep_status VARCHAR2(20);
    BEGIN
       pl_id := Get_Parameter_List(pl_name);
       IF id_null(pl_id) THEN
          pl_id := Create_Parameter_List(pl_name);
       END IF;
       Add_Parameter(pl_id, 'P_SEASON_YEAR', TEXT_PARAMETER, :SALE_ORDER.SEASON_YEAR);
       repid := FIND_REPORT_OBJECT( 'REPORT34' );
       v_rep := RUN_REPORT_OBJECT(repid, pl_id);
       ...  rest of your code here  ...
    END;Hope this helps,
    Craig B-)
    If someone's response is helpful or correct, please mark it accordingly.

  • Lexical parameter in select statement showing null or column name in xml tag instead of value

    Hi,
    i am using lexical parameter in report select statement as
    Select &order value from oe_order_headers_all a where order_number ='7889'
    and setting  : order:='a.order_number';  in after parameter form trigger.
    lexical parameter intial value set to null
    when i run this report , its not showing order number in output ,its showing null or a.order_number as text.
    Please help.

    try this
    Select &order data_show
    from oe_order_headers_all
    where order_number ='7889'
    and setting  :order:='order_number';  in after parameter form trigger.
    Hope this helps
    Hamid

  • Pass column-name as a parameter to reports

    Hello,
    the code below calls a report. But now I want to sort the rows in the report. For example I have a text-item in my form-modul. If I type a column-name and press the button then the rows should be sorted in the report. Is it possible tp pass column-names as parameter to reports?
    DECLARE
    repid REPORT_OBJECT;
    v_rep VARCHAR2(100);
    rep_status VARCHAR2(20);
    BEGIN
    repid := find_report_object('STATIONSTOPOLOGIE');
    SET_REPORT_OBJECT_PROPERTY(repid,REPORT_EXECUTION_MODE,RUNTIME);
    SET_REPORT_OBJECT_PROPERTY(repid,REPORT_COMM_MODE,SYNCHRONOUS);
    SET_REPORT_OBJECT_PROPERTY(repid,REPORT_DESTYPE,CACHE);
    SET_REPORT_OBJECT_PROPERTY(repid,REPORT_DESFORMAT,'html');
    SET_REPORT_OBJECT_PROPERTY(repid,REPORT_SERVER,'rep_oracle-dev');
    -- SET_REPORT_OBJECT_PROPERTY(repid,REPORT_OTHER,'paramform=no pdeptno='||:dept.deptno);
    v_rep := RUN_REPORT_OBJECT(repid);
    rep_status := REPORT_OBJECT_STATUS(v_rep);
    WHILE rep_status in ('RUNNING','OPENING_REPORT','ENQUEUED')
    LOOP
    rep_status := report_object_status(v_rep);
    END LOOP;
    IF rep_status = 'FINISHED' THEN
    WEB.SHOW_DOCUMENT('http://oracle-dev:8888/reports/rwservlet/getjobid'||
    substr(v_rep,instr(v_rep,'_',-1)+1)||'?'||'server=rep_oracle-dev','_blank');
    ELSE
    message('Error when running report');
    END IF;
    END;

    Hi,
    the work has been done in reports. You can use a lexical parameter in reports to add a condition for sorting to the query like:
    select .. from .. where ... &p_order.
    Then add another parameter to the report (for example p_param). Fill p_param via your interface in forms (SET_REPORT_OBJECT_PROPERTY(repid,REPORT_OTHER, ....) with the column name. Then build a report trigger like:
    if :p_param is null
    then
    :p_order:= null;
    else
    :p_order:= 'order by '||:p_param;
    end if;
    But have a look, that p_param can only get correct values.
    Rainer

  • How to reference a user parameter in program unit

    I tried to define a user parameter in Oracle Report 6i and I could reference it (&p_where_clause) in the main query but I failed to reference it in one of the program units. Here is the logic:
    function CF_OTHER_COURSESFormula return Char is
    cnt           number;
    priority     number;
    class_code     varchar2(8);
    oc           varchar2(100) := null;
    cursor oc_cur is
    select class_code, branch_priority
    from nominations n, employments e
    where n.hkic_no = e.hkic_no
    and e.staff_status_code = 'EMP'
    and &p_where_clause --> contain "n.course_code in ('A','B','C')"
    and n.hkic_no = :hkic_no
    and n.class_code != :class_code;
    begin
    cnt := 1;
    open oc_cur;
    loop
    fetch oc_cur into class_code, priority;
    if oc_cur%notfound then
         exit;
    end if;
    if cnt = 1 then
    oc := oc||class_code||'('||priority||')';
    else
    oc := oc||', '||class_code||'('||priority||')';
    end if;
    cnt := cnt + 1;
    end loop;
    close oc_cur;
    return oc;
    exception
    when no_data_found then      
    return '';
    end;
    Does anyone tell me how to reference it in program unit? Does Oracle Reports 6i support this operation?

    There hasn't been any changes to the way lexicals and bind variables work in Reports between 2.5 and 6i. There are different versions of PL/SQL and you might be hitting some problem here.
    In your case, you shouldn't be using the query lexical "&p_where_clause" just the PL/SQL bind variable syntax ":p_where_clause". Since you're creating a PL/SQL cursor, you should probably use dynamic sql creation with a concatenation of the where clause to build up the SQL for the cursor. Check out the PL/SQL documentation for this.

  • Run Report with Pass Number and Varchar Lexical Parameter values

    Dear Sir/Madam
    Due to an urgent change required to a report I would most appreciate it if you can please advise me if it is possible to get this report working by either passing in multiple lexical parameters or one signle lexical parameter when calling the SRW.RUN_REPORT command with the following methods:
    Firstly: When calling report with a run_no and spr_cd passed in through one lexical:
    cmd_line: REPORT=D:\DEV\REMITTANCE.rdf BACKGROUND=YES BATCH=NO DESFORMAT=PDF DESTYPE=FILE DESNAME=D:\DEV\REMITTANCE.pdf
    CP_L_PARAM=RUN_NO=TO_NUMBER(28) AND SPR_CD=SUPP1
    Both with a TO_NUMBER and without, whereby I attempt to do a SUBSTR within the query of the called report to derive the RUN_NO Oracle Reports fails to accept the SUBSTR.
    Secondly: I am now trying to call the with passing two lexical parameters into the report as follows:
    cmd_line: REPORT=D:\DEV\REMITTANCE.rdf BACKGROUND=YES BATCH=NO DESFORMAT=PDF DESTYPE=FILE DESNAME=D:\DEV\REMITTANCE.pdf
    CP_L_RUN_NO=||TO_CHAR(lv_run_no)|| CP_L_SPR_CD=||lv_spr_cd;          
    NOTE: The above is an output of the actual command line and not what is passed into the command line, thus the quotes are missing. Please also note that the report is running fine with the only a hard coded RUN_NO value PASSED without the SPR_CD.
    Unfortunately this is also causing issues as the RUN_NO is a number and as you know you can only pass in strings.
    Your urgent help is required on this matter please as our client is expecting a solution this afternoon.
    Hope to hear form you soon.
    Kind regards
    Andrew Mason

    Dont Worry I've worked it out...

  • Generate txt output using a program unit in web report (OAS 10g)

    Hi Everyone.
    I have a c/s report (6i) which generates a txt file in a program unit using TEXT_IO package. I need to move this report to web (Reports 10g) and publishing it in OAS 10g. I've done that (without the text file generation), I can see the report on the browser in PDF Format and works fine... but, I still have a problem... when I use Text_io package, the c/s version of the report in 10g runs an generates the output.txt file but when I move it to web I got an error in the before report trigger (in which I invoke the program unit sp_generate_txt)
    I looked around for a solution and I just find the usage of webutil package, but as you know, webutil package is only usable in Forms.
    Any Ideas on how can I solve this problem?

    Hello,
    TEXT_IO can be used in Reports deployed on the web.
    The difference with Client /Server is the fact that the file create by TEXT_IO will be created on the "Middle Tier Server" and not on the Client.
    Regards

  • How to define Lexical Parameter in Oracle report.

    Dear all,
    I need to know that how i will define lexical parameter in query of report builder
    i have like this
    SELECT R.EXCEPTION_MESSAGE EXP_MESSAGE,
    ER.PROD_ID PRODUCT,
    ER.TNAME SEGMENT1 ,
    DECODE(R.STATUS,'Y','ROW',
    'L','TABLE',
    'Z','CIB LEVEL',
    NULL) STATUS,
    NVL(COUNT(*),0) CNT
    FROM EXCEPTION_RECORDS ER,CIB_PROC_TABLES_RULES R
    WHERE ER.TABLE_ID=R.CIB_TABLE_ID
    AND ER.EXP LIKE '%'||R.EXCEPTION_MESSAGE||'%'
    AND ER.BRWR=:v_brwr
    &v_where
    GROUP BY R.EXCEPTION_MESSAGE,ER.PROD_ID,ER.TNAME,R.STATUS
    ORDER BY 2
    It is giving an error

    V_WHERE should be defined same way as regular parameter. It should acquire certain value that makes the query syntaxically correct bofore the sql is run, usually in the After Param Form trigger, e.g.
    v_where := 'WHERE 1=1';
    ...

  • Lexical Parameter in Oracle Reports . . .

    Hi all,
    I am trying to pass a value to a query in oracle reports . . .
    the use of the parameter is to add 2 additional columns to an existing query, if a bind parameter is set to 'Yes' else the parameter carries a value NULL;
    Here is the code I have written in After Parameter Form:
    if :P_ROLL_DETAIL_PRN='Yes' then
    :P_CUSTOM_CODE:=NULL;
    :P_CUSTOM_CODE:=:P_CUSTOM_CODE||'wdd.LOT_NUMBER' ||','||'wdd.SUBLOT_NUMBER';
    else
    :P_CUSTOM_CODE:='';
    end if;
    P_Roll_detail is the bind parameter . . and P_CUSTOM_CODE is the Lexical Parameter . ..
    It works for value 'No' of P_ROLL_DETAIL .. . but for Value 'Yes' I get an error . . .
    REP-0499: Column '' selected by the query is incompatible with report defination
    Kindly help...
    Regards
    Jagan

    Lexical parameters can not be used to change the number of selected columns. Consider selecting max number of columns always, but populating last two columns with either NULL values or table columns based on the parameter. Also, manipulations can be done in the layout model using format triggers.

  • Lexical parameter in bi report

    Hi All,
    I have a requirement as below :
    I have a select query in my XML file which is returning two rows for a order
    ex: select email,fax,order_number from
    oe_order_headers_all
    hz_contact_points,
    My requirement is i need to pass 3 parameters such as order_number, email, fax to the report in that case it should take only the parameters what i am passing, and it should not take the hz_contact_points table from the query
    so i need to achieve this through lexical parameter, any one please help me on this.
    Thanks

    i think you didn't read that i'm mentioned
    in datatemplate
    <parameters>
    <parameter name="P_YOUR_PARAM" dataType = "number" defaultValue="0"></parameter>
    </parameters>
    <sqlStatement name="Q_DATA">
    <![CDATA[
    select &your_columns
    from  &your_tables
    where &your_where_clause
    ]]>
    </sqlStatement>
    </dataQuery>
    <dataTrigger name="beforeReportTrigger" source="XX_YOUR_PKG.BeforeReport"/>
    <dataStructure>
    ...in package
    FUNCTION BeforeReport RETURN BOOLEAN IS
    BEGIN
    IF P_YOUR_PARAM = 'some_value' THEN
      your_columns := 'column1, column2';
      your_tables := 'table1, table2';
      your_where_clause := 'table1.id = table2.id';
    ELSE
      your_columns := 'column3, column4';
      your_tables := 'table2, table3';
      your_where_clause := 'table2.id = table3.id';
    END IF;
    END;you can use another way - create your xml output by package like
    fnd_file.put_line(fnd_file.output, '<ROWSET>');
    fnd_file.put_line(fnd_file.output, '<ROW>');
    fnd_file.put_line(fnd_file.output, '<DAT>' || some_value || '</DAT>');
    fnd_file.put_line(fnd_file.output, '</ROW>');
    fnd_file.put_line(fnd_file.output, '</ROWSET>');in package you can use all that you want

  • Created below function (program units) in report builder

    hi all,
    I created below function (program units) in report builder and added two insert statements to know how much time it is taking to execute.Report is executing successfully but no rows inserted into tale testtime.
    Is there any other way to know the execution time of this function.
    Please help me
    function CF_TYPEFormula return Char is
    begin
         insert into testtime values(sysdate,1,'CF_TYPEFormula');
      IF(:CATG0=1)
           THEN RETURN ('MOVING STOCK');
           insert into testtime values(sysdate,1,'CF_TYPEFormula');
      ELSE RETURN('NON-MOVING STOCK');
      END IF;
      insert into testtime values(sysdate,1,'CF_TYPEFormula');
      commit;
    end;Edited by: maddy on 26 Dec, 2011 8:46 PM
    Edited by: maddy on 29 Dec, 2011 9:25 PM

    Shashank,
    Try,
    function CF_TYPEFormula return Char is
    Str_Ret_Val VARCHAR2(100);
    BEGIN
       INSERT INTO TESTTIME VALUES(SYSDATE, 1, 'CF_TYPEFormula');
       IF(:CATG0=1) THEN
          Str_Ret_Val := 'MOVING STOCK';
          INSERT INTO TESTTIME VALUES(SYSDATE, 1, 'CF_TYPEFormula');
       ELSE
          Str_Ret_Val := 'NON-MOVING STOCK';
       END IF;
       INSERT INTO TESTTIME VALUES(SYSDATE, 1, 'CF_TYPEFormula');
       COMMIT;
       RETURN Str_Ret_Val;
    END;Regards,
    Manu.

Maybe you are looking for

  • How can we copy table from one schema to other schema

    Hi, I have create one table in one schema and i want to copy it to other schema.How we can copy table from one schema to other schema

  • HT1386 How can I remove purchased songs from my iPhone?

    There are purcahsed songs on my iphone. However even after unsycning them from iTunes it does not remove them from my phone. I don't want to get ride of the songs out of iTunes but I want them off my phone. And another one. For one of my albums it sh

  • Help needed regarding the updation of "Relationships" in BP

    Hello Guys, This is to request you to kindly help me regarding the following. We have a scenario where all the employees assigned to an Organizational unit (in PPOMA_CRM) are not showing in the "Relationships" ("Has Employee")in the BP transaction of

  • Connecting a 35670A to labview signalexpress

    Hello all, I am rather new to using signal express, First problem I have is I will be using the LE version of signal express, will this program be sufficient to run a VI for the 35670A, Also it says you get a 30day trial which I have not for some rea

  • Mass Replication of Datasources in BW 3.5 system !!

    Hi Experts, Actually I want to do a mass replication of datasources in BW 3.5 system. I have searched through the programs and FM, but could not find any. Please provide me some details of how to write a program in ABAP to replicate and activate a lo