Use laxical parameter in cursor

Hi All,
PROCEDURE Get_Transfer_Order(p_and IN VARCHAR2,
p_tab OUT tab_Transfer_Order,
pb_check OUT BOOLEAN,
pn_ret_code OUT NUMBER,
pv_ret_mesg OUT VARCHAR2) IS
CURSOR c_tran_ord IS SELECT T.ORDER_NO,T.FROM_WHSE,T.TO_WHSE,T.REQUESTED_SHIPDATE
FROM SOM_ORDER_HDR T,SOM_APPR_ORDER B
WHERE T.ORDER_TYPE='TO'
AND T.ORDER_STATUS NOT IN (-1,20,23)
AND NVL(T.DELETE_IND,'N')<> 'Y'
AND T.ORDER_ID=B.ORDER_ID
AND B.APPR_STATUS='APPR'
&p_and; -- <<<<<--------------------
i NUMBER := 0;
BEGIN
OPEN c_tran_ord;
LOOP
FETCH c_tran_ord INTO A1,A2,A3,A4;
EXIT WHEN c_tran_ord%NOTFOUND;
END LOOP;
CLOSE c_tran_ord;
END Get_Transfer_Order;
Problem: when i will execute the procedure, in "p_and" i will pass the string like 'and a=1 and b=2 ......' and the cursor qurey will automaticaly modify according to 'p_and' ... but its throughing an error...
Please help me...
Regards
Uzair Hasan Nizami

are you using this, in the oracle reports...?...
you can use dynamic sql as suggested, or ref_cursor, to run your query as per your conditions...

Similar Messages

  • Dynamic table in Oracle report data model using laxical parameter is giving error Ora-00936: missing expression

    Hi ,
    I am using Oracle report 10G
    And trying to create report with dynamic table
    SELECT &COL1, &COL2
    FROM &TAB
    If I put this on data model it gives below error
    ORA-00936: missing expression
    ==> from
    Can anybody advise to solve this issue.
    Regards,
    Brajesh

    Look in the Reports Builder Help:
    If you want to use lexical references in your SELECT clause, you should create a separate lexical reference for each column you will substitute. In addition, you should assign an alias to each lexical reference.
    Does adding the column alias solve the problem?

  • Report are not working using lexical parameter

    Hi !
    i am using oracle 10g and i my query i have laxical parameter as follow
    &to_date
    in after paramform we have
    IF :P_DATE_TO IS NOT NULL THEN
         :TO_DATE := 'AND to_date(head.updated_date,'||chr(39)||'DD/MM/RRRR'||chr(39)||') between TO_DATE(t2.term_start_date,'||chr(39)||'DD/MM/RRRR'||chr(39)||') AND TO_DATE('||CHR(39)||:P_DATE_TO||CHR(39)||','||chr(39)||'DD/MM/RRRR'||chr(39)||')';
    --ELSE
         --:TO_DATE := NULL;
    END IF;
    after compile this report when i run this report then i have following error
    REP-304: '&' in SELECT statement was not followed by a valid lexical parameter.
    any body can tell me how can i resove it.

    What denis is trying to say that change the TO_DATE parameter to any other name because TO_DATE is actually reserve word. So instead of TO_DATE try for example P_TO_DATE or any other name.
    -Ammad

  • Can use aggregate functions inside cursor

    Hi
    Can i use aggergate functiions inside cursors because i was getting the below error message when try to execute the below procedure.
    I need following thins to implement procedure ,When pass 100 through parameter ,that will check the total count on the table if matches delete the records from table .
    create or replace procedure p12(p_count number) is
    cnt number :=0;
    tot number :=0;
    cursor c1 is select count(1),c2,rowid from t1 where
    group by c2,rowid;
    begin
    for y in c1
    loop
    delete from t1 where row_id=y.rowid;
    cnt:=y.cnt+1;
    tot:=y.tot+1;
    if mod(y.cnt,100)=0
    then
    dbms_output.put_line(y.tot||'total records deleted');
    end if;
    end loop;
    end;
    4/14 PL/SQL: SQL Statement ignored
    4/55 PL/SQL: ORA-00936: missing expression
    Thanksinadvance
    MR

    I was still getting the error
    create or replace procedure p12(p_count number) is
    cnt number :=0;
    tot number :=0;
    cursor c1 is select count(1),c2,rowid from t1
    where c2=100
    group by c2,rowid;
    begin
    for y in c1
    loop
    delete from t1 where rowid=y.rowid;
    cnt:=y.cnt+1;
    tot:=y.tot+1;
    if mod(y.cnt,100)=0
    then
    dbms_output.put_line(y.tot||'total records');
    end if;
    end loop;
    end;
    LINE/COL ERROR
    11/1 PL/SQL: Statement ignored
    11/8 PLS-00302: component 'CNT' must be declared
    12/1 PL/SQL: Statement ignored
    12/8 PLS-00302: component 'TOT' must be declared
    13/1 PL/SQL: Statement ignored

  • 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

  • How to use import parameter to be instead of SQL where sub-sentence ?

    I wrote a RFC to read data from SAP table. To fetch data flexibility, I want to use import parameter xx instead of where sub-sentence in SQL sentence.
       For example, "SELECT * FROM T WHERE XXX",  and "XXX" is a importing parameter.
       How can I use it.
       Thanks a lot.
       Frank.

    FUNCTION ZRFC_04.
    *"*"Local Interface:
    *"  IMPORTING
    *"     VALUE(TARGETTABLE) LIKE  MAKT-MAKTX
    *"     VALUE(TWHERE) LIKE  MAKT-MAKTX
    *"  EXPORTING
    *"     VALUE(ZRETURN) LIKE  MAKT-MAKTX
    *"  TABLES
    *"      TMP_TEST1 STRUCTURE  ZTEST1
      DATA:
      TRANSACTION_ID LIKE ARFCTID,
      V_VAILD(1) TYPE C,
      scond(80) TYPE c.
      V_VAILD = 'X'.
    GET PARAMETER twhere fields scond.
    The error " 'LATE FIELDS' expected, not 'TWHERE FIELDS' " generated.

  • Want to use one parameter of first command into second parameter.

    Hi, Experts,
    Please help me out I am stuck in a crystal report. Actually i have written two commands in crystal report.
    first one is as follows:-
    Select * from oinv T0 inner join inv1 T1 on T0.DocEntry = T1.DocEntry Where T0.DocNum = {?Invoice No}
    Second One is as follows:-
    Select * from ibt1_Link Where BaseNum = {?Invoice No}
    What i want is I am passing Parameter in both Command Which took Invoice no as an input, So i don't want to input ttwo parameter both for invoice no. can i use first parameter in my second command or not. If Yes then please tell me.How can i do the same.
    Regards
    Hanes

    Have you tried joining your commands on the basenum = docnum fields? That should filter the second command?

  • How to use a parameter field value as a substring in a "like" statement?

    Hi all,
    I'm trying to use a parameter field in a Record selection formula where the parameter field value would be a substring of the data stored in the field.
    My parameter field (SlctResearcher) is constructed as follows:
    Type: string
    List of Values: static
    Value Field: (Reports) RptAuthors
    (in Value Options) Allow custom values?: True
    {Reports.PubDate} in DateTime (2009, 04, 01, 00, 00, 00) to DateTime (2010, 03, 31, 23, 59, 59) and
    {Reports.RptAuthors} like "*{?SlctResearcher}*"
    When I hit F5 to generate the data, I get no results (and the parameter prompt field does not even come up...)
    If I modify the formula to put a hard-coded string, like
    "*Jones*"
    after the 'like', I get results (all the reports where "Jones" is a substring in the RptAuthors string.) If I modify the formula to just use the parameter field without the quotes/stars like:
    {Reports.PubDate} in DateTime (2009, 04, 01, 00, 00, 00) to DateTime (2010, 03, 31, 23, 59, 59) and
    {Reports.RptAuthors} like {?SlctResearcher}
    I do get the parameter prompt field, but still no results even if I put in a valid substring value (since it is not searching for a substring anymore...)
    How can I do this?
    Thanks,
    Will

    1st thing... Make a copy of your report before doing anything!!!
    To use a SQL Command, you'll want to open the Database Expert and look at the Current Connections. Expand the data source and the 1st option you see is the Add Command option.
    To find the SQL That CR is currently using, choose Database from the menu bar and select Show SQL Query...
    You can copy this and paste it directly into the command window. (If you you can write your own SQL you don't need copy CR's, it's just an option.)
    You'll also want to take not of any parameters that you have, you'll need to add them the the Parameter List of the command as well... be sure to spell them EXACTLY as they are in the design pane.
    Anyway, once the SQL statement is in the Command window you'll be able to alter the WHERE clause to use the wild cards.
    For future reference... What type of database are you reporting against???
    Jason

  • HR ABAP: Issue with using 'nocommit' parameter on FM HR_INFOTYPE_OPERATION

    Issue with using nocommit parameter on FM HR_INFOTYPE_OPERATION:
    My client has a requirement to create the following 4 infotypes in sequence in a LUW, i.e either all are created or none is created.
    9045   (custom infotype)
    0045
    0078
    0015
    I tried to use the nocommit parameter on FM HR_INFOTYPE_OPERATION to insert the 4 infotypes
    in a nocoomit mode and then at the end I have issued
    'Commit Work', but to my surprise only I/T 0015 is created in the database and the first three (9045, 0045 and 0078) did not make it to database.
    I searched many threads on SDN but could not find a solution.
    Please let me know if there could be any solution to implement the LUW.
    YOur inputs will be appreciated.

    Hi ,
    i think u can also try with this FM HR_MAINTAIN_MASTERDATA , see its documentations.
    no commit works like a simulation mode , what u can do is  ,
    call FM for all Infotypes and collect all error msgs if any , then finally call FM for all infotypes again without passing nocommit work ( i.e space).
    regards
    prabhu

  • Use of parameter sets with prepared INSERTS via Oracle's ODBC driver 8.1.6.4

    Oracles ODBC driver, version 8.1.6.4, allows for driver configuration of three different batch auto commit modes. If I select COMMIT ALL SUCCESSFUL STATEMENTS and cause my app to execute a prepared and parameterized INSERT statement that makes use of parameter value sets, all records up to the first record that causes an error are committed. What is happening? The driver returns only one diagnostic record, with SQLGetDiagField returning the index of the bad record through the [SQL_DIAG_ROW_COUNT] field. Regardless of whether SQLExecute executed successfully or not, the [SQL_ATTR_PARAM_OPERATION_PTR]/ [SQL_ATTR_PARAM_STATUS_PTR] buffers are not initialized by the driver. Even more so, the drive returns SQL_PARC_NO_BATCH for SQLGetInfo when [SQL_PARAM_ARRAY_ROW_COUNTS] is passed. Does anyone know if the driver fully or partially or does not support use of parameter value sets. If it is only partial implementation, ignoring the parameter operation and status buffers, in my opinion, greatly diminishes any real use of parameter value sets. Does anyone known if the above problems disappear with use of Oracles ODBC driver, version 8.1.7.3.0?
    All help is greatly appreciated,
    Chris Simms
    null

    <BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by Justin Cave ([email protected]):
    What version of the database do you have on the back end?
    Justin<HR></BLOCKQUOTE>
    Oracle8i version 8.1.6. Looking at the specs that come with the ODBC driver upgrades, version 8.1.7.3.0 [which requires Oracle*i version 8.1.7] and 8.1.6.4, it seems that similar enhancements/fixes were made to both. I honestly do not know if what I am attempting is possible with either of the ODBC drivers. I really would prefer not to have to drop down to programming using OCI.
    Chris
    null

  • Problem in using String in Implicit Cursor

    Hi,
    I am facing problem in using String in Implicit Cursor:
    I have initialise
    DECLARE
    v_grant varchar2(4000);
    begin
    v_grant:='SELECT TABLE_NAME FROM DUMP_USER_TABLES WHERE TABLE_NAME LIKE ';
    FOR obj IN (SELECT v_grant||'''BS%''' FROM dual) LOOP
    V_REVOKE:='REVOKE ALL ON ' || 'obj.TABLE_NAME' || ' FROM ' || '''TEST''';
    DBMS_OUTPUT.PUT_LINE('THE REVOKE STATEMENT IS'||V_REVOKE);
    num := num + 1;
    END LOOP;
    END;
    I am not getting the value from obj.TABLE_NAME its coming as 'obj.TABLE_NAME'
    Kindly anyhelp will be needful for me

    Besides from what Sybrand already pointed out clearly:
    Your example doesn't run at all:
    MHO%xe> DECLARE
      2  v_grant varchar2(4000);
      3  begin
      4  v_grant:='SELECT TABLE_NAME FROM DUMP_USER_TABLES WHERE TABLE_NAME LIKE ';
      5  FOR obj IN (SELECT v_grant||'''BS%''' FROM dual) LOOP
      6  V_REVOKE:='REVOKE ALL ON ' || 'obj.TABLE_NAME' || ' FROM ' || '''TEST''';
      7  DBMS_OUTPUT.PUT_LINE('THE REVOKE STATEMENT IS'||V_REVOKE);
      8  num := num + 1;
      9  END LOOP;
    10  END;
    11  /
    V_REVOKE:='REVOKE ALL ON ' || 'obj.TABLE_NAME' || ' FROM ' || '''TEST''';
    FOUT in regel 6:
    .ORA-06550: line 6, column 1:
    PLS-00201: identifier 'V_REVOKE' must be declared
    ORA-06550: line 6, column 1:
    PL/SQL: Statement ignored
    ORA-06550: line 7, column 49:
    PLS-00201: identifier 'V_REVOKE' must be declared
    ORA-06550: line 7, column 1:
    PL/SQL: Statement ignored
    ORA-06550: line 8, column 1:
    PLS-00201: identifier 'NUM' must be declared
    ORA-06550: line 8, column 1:
    PL/SQL: Statement ignoredI guess you need to read up on quoting strings properly and probably also dynamic SQL.
    But:
    WHAT are you trying to do anyway?
    I cannot parse your code at all...so what is your requirement in human language?

  • Getting error when using the "/parameter" switch in command line run

    Has anyone experienced this problem before?
    My report queries over 100,000 records from a view. When the report is run from the command line every thing works fine.
    But when I add a condition using a "parameter", although the report still runs fine from the destop, when launched from the command line it errs.
    "Oracle Discoverer Desktop has encountered a problem and needs to close. ..."
    "The instruction at "0x0044397c" referenced memory at "0x0000004e". The memory cound not be "read"...."
    I'm guessing its a memory issue with my PC. I've tested using a parameter with other reports using fewer records and it doesn't err from the command line.
    I can work around the issue by not using a parameter but then I have 20 versions of the same report each with a different condition.
    Any suggestions would be appreciated.
    Lise McGillis

    Hi Michael,
    I'm using an DELL Intel Pentium 4 CPU 3.00 GHz with 1 GB of RAM. We use Microsoft Windows XP Prof version 2002.
    As for Discoverer we are using 10G, Desktop Client 10.1.2.48.18 - 1047500 KB available memory , 2099744 KB Free disk space.
    I'm not sure I have acess to a computer with more RAM but I'm looking into it.
    What I'm frustrated by is the fact that the parameter works fine when run directly from the desktop but when passed from the command line it bombs... but only when dealing with mega records.
    Lise.

  • How to use a parameter  of a report program from selection screen in a dialog program

    how to use a parameter value(entered ) of a report program from a selection screen in a dialog program.
    I have to fetch the value entered in the parameter of report program and display it in a dialog program

    Hi Aasim,
    Just mention like below in your ABAP report.
       PARAMETERS: p_aufnr TYPE aufnr MEMORY ID ord.
    and mention the same memory ID name in the module pool screen property it automatically populates the value to and fro

  • How to use a parameter of a report program in a dialog program

    how to use a parameter of a report program in a dialog program.
    I have to fetch the value entered in the parameter of report program and display it in a dialog program

    Hi Aasim,
    Just mention like below in your ABAP report.
       PARAMETERS: p_aufnr TYPE aufnr MEMORY ID ord.
    and mention the same memory ID name in the module pool screen property it automatically populates the value to and fro

  • Bug while using string parameter values in postgresql query

    Hi,
    I have the following query for the postgresql database:
    Code:
    <queryString><![CDATA[SELECT
    evt_src_mgr_rpt_v."evt_src_mgr_name" AS esm_name,
    evt_src_collector_rpt_v."evt_src_collector_name" AS collector_name,
    evt_src_grp_rpt_v."evt_src_grp_name" AS grp_name,
    evt_src_grp_rpt_v."state_ind" AS state_ind,
    evt_src_rpt_v."evt_src_name" AS src_name,
    evt_src_rpt_v."date_modified" AS date_modified,
    evt_src_rpt_v."date_created" AS date_created,
    CASE WHEN $P{mysortfield} = 'evt_src_mgr_name' THEN evt_src_mgr_name
    WHEN $P{mysortfield} = 'evt_src_collector_name' THEN evt_src_collector_name
    WHEN $P{mysortfield} = 'evt_src_grp_name' THEN evt_src_grp_name
    ELSE evt_src_name END as sort
    FROM
    "evt_src_mgr_rpt_v" evt_src_mgr_rpt_v
    LEFT JOIN
    "evt_src_collector_rpt_v" evt_src_collector_rpt_v
    ON EVT_SRC_MGR_RPT_V."evt_src_mgr_id" = evt_src_collector_rpt_v."evt_src_mgr_id"
    LEFT JOIN
    "evt_src_grp_rpt_v" evt_src_grp_rpt_v
    ON evt_src_collector_rpt_v."evt_src_collector_id" = evt_src_grp_rpt_v."evt_src_collector_id"
    LEFT JOIN
    "evt_src_rpt_v" evt_src_rpt_v
    ON evt_src_grp_rpt_v."evt_src_grp_id" = evt_src_rpt_v."evt_src_grp_id"
    LEFT JOIN
    "evt_src_offset_rpt_v" evt_src_offset_rpt_v
    ON evt_src_rpt_v."evt_src_id" = evt_src_offset_rpt_v."evt_src_id"
    WHERE
    $P!{mysortfield} LIKE '$P!{searchvalue}' || '%']]></queryString>
    That is I try to select only the records where the field which is
    selected by user as report parameter ($P{mysortfield}) contains data
    starting with the text entered by user as a report parameter
    ($P{searchvalue}).
    When I try to run the report in iReport with active connection to the
    database the report is generated as expected.
    But when I try to run the report from Sentinel Log Manager I get the
    following error: "java.lang.String cannot be cast to
    net.sf.jasperreports.engine.JRValueParameter".
    After several detailed debug sessions I finally came into a conclusion
    that this error is related to the use of parameter values (
    $P!{mysortfield} and $P!{searchvalue} ).
    I even tried using the following WHERE clause (which emulates the
    queries as used in standart reports (especially at VendorProduct related
    SQL queries ) with no success:
    Code:
    WHERE
    ($P{mysortfield} = 'evt_src_mgr_name' AND evt_src_mgr_name LIKE ($P{searchvalue} || '%')) OR
    ($P{mysortfield} = 'evt_src_collector_name' AND evt_src_collector_name LIKE ($P{searchvalue} || '%')) OR
    ($P{mysortfield} = 'evt_src_grp_name' AND evt_src_grp_name LIKE ($P{searchvalue} || '%')) OR
    ($P{mysortfield} = 'evt_src_name' AND evt_src_name LIKE ($P{searchvalue} || '%'))
    Any suggestions?
    hkalyoncu
    hkalyoncu's Profile: http://forums.novell.com/member.php?userid=63527
    View this thread: http://forums.novell.com/showthread.php?t=450687

    bweiner12345;2167651 Wrote:
    > I'm not 100% sure the $P! (instead of just $P) is needed in that WHERE
    > portion of your SQL statement.
    >
    > What I would suggest doing is building the WHERE portion of your query
    > up again step by step. That is, instead of using any parameters in your
    > WHERE:
    >
    > $P!{mysortfield} LIKE '$P!{searchvalue}' || '%'
    >
    > ... take a step back and literally hard-code some values in there, such
    > as:
    >
    > evt_src_mgr_name LIKE '%' || '%'
    >
    > ... and run it on your box to make sure it works fine.
    >
    > If it works fine, start substituting the parameters one by one:
    >
    > $P{mysortfield} LIKE '%' || '%'
    >
    > .... test on the box.
    >
    > $P{mysortfield} LIKE '$P{searchvalue}' || '%'
    >
    > .... test on the box.
    >
    > It may be a little tedious, but at least you'll find out where the
    > problem is occurring... and may be quicker in the long run.
    >
    > (Note: In my above example steps I didn't use the ! in with the
    > parameters, as I don't think they are needed in the WHERE clause... but
    > I could be wrong... and by following the above step-by-step technique
    > should answer that for sure.)
    Thank you for the suggestions:
    While trying to implement your suggestions I realized that there was a
    error at the parameter name I used inside the where clause (it should be
    $P{searchfield}).
    Here are my results:
    Code:
    vt_src_mgr_name LIKE '%' || '%'
    worked as expected.
    Code:
    $P{searchfield} LIKE '%' || '%'
    produced PDF but wrong output.
    Code:
    $P!{searchfield} LIKE '%' || '%'
    resulted with the error "java.lang.String cannot be cast to
    net.sf.jasperreports.engine.JRValueParameter" and no PDF.
    Then I tried the following where clause which resulted in exactly as
    expected PDF:
    Code:
    WHERE
    ($P{searchfield} = 'evt_src_mgr_name' AND evt_src_mgr_name LIKE ($P{searchvalue} || '%')) OR
    ($P{searchfield} = 'evt_src_collector_name' AND evt_src_collector_name LIKE ($P{searchvalue} || '%')) OR
    ($P{searchfield} = 'evt_src_grp_name' AND evt_src_grp_name LIKE ($P{searchvalue} || '%')) OR
    ($P{searchfield} = 'evt_src_name' AND evt_src_name LIKE ($P{searchvalue} || '%'))
    As a summary:
    * The query which works in iRepord do not work in Sentinel Log
    Manager.
    * I found a workaround for my case.
    * I did not checked, but the reports provided in Sentinel RD which use
    the same technique for VendorProduct parameter (i.e. the reports with
    query string containing
    Code:
    LIKE ($P{VendorProduct} || '%')
    will most probably not work as expected IF Sentinel RD uses the same
    code as Sentinel Log Manager.
    hkalyoncu
    hkalyoncu's Profile: http://forums.novell.com/member.php?userid=63527
    View this thread: http://forums.novell.com/showthread.php?t=450687

Maybe you are looking for

  • How do I install a Lion Recovery Partition

    I recently installed a new Hard Drive in my Early 2011 Macbook Pro, and I was wondering if there was any way I could out the Lion Recovery Partion on it. Thanks In Advance

  • Java JDK Installation Problem - Need Help!

    Below is my program Access.java which resides in c:\java. It generates a "NoSuchMethodError" when I run it on my Windows 2000 computer at work. When my friend here at work runs the SAME program on his Windows 2000 computer, it runs fine. I have No id

  • Can we do versioning of cube??

    Hi all, I have modifyed one existing cube in development box. because of some reason i need to rever my changes and move that cube to production urgently. after this is done i need to redo changes in cube in dev box. is there any way by which i can s

  • How to play avi and mkv file

    how to play avi and mkv file in ipad 4 using camera connection kit. please help me. and how to play directly any format ipad 4

  • Email messages is gone

    I'm using 6233 with firmware 5.60 and latest PC-Suite. I can't activate email settings, when I try to select Menu > Messaging > Message settings > Email messages. Email messages is gone. I have run Nokia Software Updater Setup and reinstall firmware