Passing where clause of cursor

my requirement is that i want to declare a cursor but the problem is that where clause of sql statement of cursor is dynamically generated according to user clicks........ e. g. number of conditions in where clause may change.....
so..... how can i declare the cursor...how do i pass where clause to any procedure if i write procedure or function......

u can use for-loop cursors like this,
for v_rec in 'select * from emp where' || ur_conditions ||'
see oracle documentation for further help and examples

Similar Messages

  • Passing where clause with spaces from forms to reports

    Hi,
    Has anybody passed where clause as lexical parameter with spaces from forms to preports..
    I have seen people mention that, we can replace the spaces with special characters and then replace it again in the before trigger report..does anyone have a working example of that??
    Thanks.

    i solved the issue..
    i had written the procedure in the before report
    trigger instead of writing it in the before parameter
    form trigger..
    it works perfecto now..
    Thanks.We had removed the spaces and used commas to delimit each item.
    So you are saying spaces are not a problem in 10g?

  • Where clause in cursor

    I often have a problem with cursors and after playing around they usually work. The problem is I don't really know what I'm doing as I'm relativly new to all this! Perhaps someone can help ;)
    I have the folling code to test my cursor:
    declare
    vcrn varchar2(8) := :module_choice.crn;
    vgroup_code varchar2(10) := :module_choice.group_code;
    vclass_type varchar2(10) := :module_choice.class_type;
    i int := 0;
    cursor att_cur is
    select student_id, attended, notes
    from attendance_register
    where crn = vcrn ;
    AND group_code = vgroup_code
    AND class_type = vclass_type;
    BEGIN
    for row in att_cur loop
         i := i + 1;
    end loop;
    message(i);
    END;
    the message shows i = 0, but I know it's not. When I comment out the where clause it works.
    I guess my real question would be how do you get a where clause to work like this??
    Thanks in Advance
    Mark

    This where clause will succeed if some of the variables are null:
    where ( crn = vcrn or vcrn is null )
      AND (group_code = vgroup_code or vgroup_code is null)
      AND (class_type = vclass_type or vclass_type is null)But I am very concerned about your Char datatypes. Those trailing spaces will give you nothing but lots of grief. Unless you have a compelling reason to keep them, they should be changed to varchar2.

  • 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

  • Dynamic where clause for cursor

    Hi Friends,
    I have a stored procedure with a single input parameter where in the input comes as
    a string of values (ex: EMPLOYEE NAMES) separated by commas. I use this parameter in my cursor query
    and my requirement is like when the parameter is NULL the query has to run for ALL the employees but if
    its not, it has to run for the EMPLOYEE NAMES passed as the input parameter.
    What are the possible and apt solutions for this requirement ?
    Should I go for dynamic sql or do I have any other optimal solutions?
    Please advice me.
    Thanks
    Zara

    Dear,
    I have a stored procedure with a single input parameter where in the input comes as
    a string of values (ex: *EMPLOYEE NAMES*) separated by commas. I use this parameter in my cursor query
    and my requirement is like when the parameter is NULL the query has to run for ALL the employees but if
    its not, it has to run for the EMPLOYEE NAMES passed as the input parameter.
    What are the possible and apt solutions for this requirement ?
    Should I go for dynamic sql or do I have any other optimal solutions?
    Please advice me.I would suggest you to let down this dynamic SQL and those concatenations that are going to introduce a threat of SQL injection and non shared code into your application.
    And, as far as you've opted for a stored procedure I want to suggest you to use
    (a) stored procedure in wich only static SQL is used
    (b) if point (a) is respected then you don't have to care about using litteral inside your stored procedure. All what you will do in this procedure will be 'auto-binded'; that is PL/SQL (static).
    (c) However, make sure to call your stored procedure using bind variables; otherwise your shared pool (v$sql) will be full of hundred and thousands of calls to your stored procedure.
    Best Regards
    Mohamed Houri

  • How to pass where clause in lov's

    Dear all
    i have creation page in that three lov's are there
    1.customername
    2,person name
    3.address
    my requirement is person name and adress will come based on customername(companyid) and also orgid
    in my case i taken 3 lov vo's for lov's
    whet should i do
    my lov query is
    1.SELECT comp_companyid, comp_name
    FROM xxcrm_company_t
    2.SELECT pers_companyid, pers_personid, pers_firstname, pers_lastname
    FROM xxcrm_person_t
    3.SELECT comp_companyid, addr_addressid,
    addr_address1
    || ' '
    || DECODE (addr_address2,
    NULL, COALESCE (addr_address3, addr_address4),
    addr_address2
    || ' '
    || DECODE (addr_address3,
    NULL, COALESCE (addr_address4, addr_country),
    addr_address3
    || ' '
    || NVL (addr_address4, addr_country)
    || ' '
    || DECODE (addr_address4, NULL, NULL, addr_country) address
    FROM xxcrm_company_address_t
    except first query remaining 2 queries orgid is there i need to compare orgid as well as first query companyid
    i hope u understand my question
    Regards
    Sreekanth

    You can use dependent lov concept for this. Go through the development guide for the same.

  • Passing where cluase as parameter for cursor

    I want to pass where clause of cursor as parameter.... how can I do that?
    say I want cursor as,
    cursor c1 is select fname, mname from person where :param;
    where :param is a value I want to pass in declare section

    I want to pass where clause of cursor as parameter.... how can I do that?Yes.
    cursor c1 is select fname, mname from person where :param;
    where :param is a value I want to pass in declare sectionYou can also shoot yourself in the foot using a 357 Magnum.
    Neither is recommended - unless you are a professional idiot. Which I doubt as these are typically your Darwin Award Winners.
    Why is it bad to to have "+WHERE :param+"?
    Bind variables. If the WHERE clause is passed as a dynamic string. this will usually be implemented in the following fashion:
    SQL> create or replace procedure smellyFoo( filterClause varchar2, refCur in out sys_refcursor ) is
      2  begin
      3          open refCur for
      4          'select owner, object_id, object_name from all_objects where owner != ''SYS'' and '||filterClause||' order by 1,2';
      5  end;
      6  /
    Procedure created.
    SQL>
    SQL> var c refcursor
    SQL> exec smellyFoo( 'object_type=''TABLE'' and rownum <11', :c );
    PL/SQL procedure successfully completed.
    SQL>
    SQL> print c
    OWNER       OBJECT_ID OBJECT_NAME
    OUTLN             452 OL$
    OUTLN             453 OL$HINTS
    OUTLN             456 OL$NODES
    SYSTEM           3621 MVIEW$_ADV_WORKLOAD
    SYSTEM           3624 MVIEW$_ADV_BASETABLE
    SYSTEM           3626 MVIEW$_ADV_SQLDEPEND
    SYSTEM           3628 MVIEW$_ADV_PRETTY
    SYSTEM           3630 MVIEW$_ADV_TEMP
    SYSTEM           3632 MVIEW$_ADV_FILTER
    SYSTEM           3634 MVIEW$_ADV_LOG
    10 rows selected.
    SQL>What's wrong with this? The filter clause contains literals. Not bind variables. Which means that non-sharable SQL will be created. This means more cursors (for same SQLs with different literal values) in the shared pool. Different sizes SQLs that leads to fragmentation of the shared pool memory. More hard parsing. Bigger delay in parsing as there are more cursors to scan in the shared pool (useless exercise) as there are no existing cursors that are sharable and can be re-used.
    So what would the correct way be? The client passing a filter clause as a proper bind variable string, and also passing (separately) the values for those bind variables. But this is not easy to code, especially when dealing with filter clauses that may contain no bind variables. or a 100 bind variables.
    Also, the call interface the client needs to use will become a lot more complex as the client now not only needs to build a proper string containing bind variables, it also need to make sure it pass the values for those variables in the correct order.
    So why? Why do any of this? What is the requirement that lead you to this "solution" where the client can dynamically decide on what the filter criteria is?
    Surely, there must be a reason to this madness of the client wanting to throw any filter clause at a SQL cursor... and surely, that is what needs to be identified and analysed and resolved - instead of wanting to create hacks like the above. Causing performance issues. Not to mention opening a security hole that is ideal for SQL injection.

  • Passing where and group by clause to cursor

    I am working on a procedure that builds a where clause and needs a group by clause to return the correct results. I am trying to pass both the where and group by variables into the cursor.
    The variables are getting populated correctly, but when the cursor gets created, the variables are not in the cursor.
    Here is the code I'm working with. It is a part of a package, but makes no calls to other parts of the package.
    PROCEDURE createFollowUpTask_Exposure( psUppgkedjetyp IN tis.tial.uppgkedjetyp%TYPE default NULL,
    psAlarmtyp IN tis.tial.alarmtyp%TYPE default NULL,
    psSubtyp IN tis.tial.subtyp%TYPE default NULL,
    pnDays IN NUMBER default NULL,
    psKampkod IN tis.tiin.kampkod%TYPE default NULL,
    psKatnr IN tis.tiin.katnr%TYPE default NULL,
    psUtgava IN tis.tiin.utgava%TYPE default NULL,
    psKatslag IN tis.tikg.katslag%TYPE default NULL,
    psProdsyst IN tis.tikg.prodsyst%TYPE default NULL,
    psUppgtyp IN tis.tiin.uppgtyp%TYPE default NULL,
    psProdkod IN tis.tiin.prodkod%TYPE default NULL,
    psStatus IN tis.tiin.status%TYPE default NULL
    ) AS
    cTIAL tis.tial%ROWTYPE;
    vLopnr tis.tial.lopnr%TYPE;
    vSqlWhere VARCHAR2(4000);
    vGroupBy VARCHAR2(1000) := ' tiin.kampkod, tiin.abnr, tiko.fordsalj';
    cSelectCursor SYS_REFCURSOR;
    vSqlSelect VARCHAR2(4000);
    psDays VARCHAR2(50);
    cRec T_TIAL_REC;
    nCount number := 0;
    CURSOR cSqlSelect( SqlWhere IN VARCHAR2, GroupBy IN VARCHAR2) IS
    SELECT tiin.kampkod, tiin.abnr, tiko.fordsalj, MAX(tici.regdat) ALARMDATE
    FROM tis.tiin
    JOIN tis.tiko ON tiin.kampkod = tiko.kampkod AND tiin.abnr = tiko.abnr
    JOIN core.tici ON tiin.kampkod = tici.kampkod AND tiin.abnr = tici.abnr AND tici.inplnr = tiin.inplnr
    WHERE 1=1 || SqlWhere
    GROUP BY GroupBy;
    BEGIN
    -- If these parameters are null, raise error
    IF psUppgkedjetyp IS NULL and psSubtyp IS NULL THEN
    raise_application_error(-20001,
    'Either Event Chain or Starting Event must be assigned');
    END IF;
    -- Populate TIAL values
    IF psUppgkedjetyp IS NOT NULL THEN
    cTIAL.Uppgkedjetyp := psUppgkedjetyp;
    END IF;
    IF psAlarmtyp IS NOT NULL THEN
    cTIAL.Alarmtyp := psAlarmtyp;
    END IF;
    cTIAL.Handklass := 'T';
    cTIAL.Blobid := 0;
    IF pnDays IS NOT NULL THEN
    psDays := '+ '||pnDays;
    END IF;
    IF psSubtyp IS NOT NULL THEN
    cTIAL.Subtyp := psSubtyp;
    END IF;
    -- Create Where clause for cursor
    vSqlWhere := '';
    IF psKampkod IS NOT NULL THEN
    vSqlWhere := vSqlWhere||' AND tiin.kampkod = '''|| psKampkod||'''';
    END IF;
    IF psKatnr IS NOT NULL THEN
    vSqlWhere := vSqlWhere||' AND tiin.katnr = '''||psKatnr||'''';
    END IF;
    IF psUtgava IS NOT NULL THEN
    vSqlWhere := vSqlWhere||' AND tiin.utgava = '''||psUtgava||'''' ;
    END IF;
    IF psKatslag IS NOT NULL THEN
    vSqlWhere := vSqlWhere||' AND tikg.katslag = '''||psKatslag||'''';
    END IF;
    IF psProdsyst IS NOT NULL THEN
    vSqlWhere := vSqlWhere||' AND tikg.prodsyst = '''||psProdsyst||'''';
    END IF;
    IF psUppgtyp IS NOT NULL THEN
    vSqlWhere := vSqlWhere||' AND tiin.uppgtyp = '''||psUppgtyp||'''';
    END IF;
    IF psProdkod IS NOT NULL THEN
    vSqlWhere := vSqlWhere||' AND tiin.prodkod = '''||psProdkod||'''';
    END IF;
    IF psStatus IS NOT NULL THEN
    vSqlWhere := vSqlWhere||' AND tiin.status = '''||psStatus||'''';
    END IF;
    -- Loop through all records meeting input parameters and set required TIAL values.
    FOR i IN cSqlSelect(vSqlWhere, vGroupBy)
    LOOP
    --FETCH cSelectCursor INTO cRec;             
    cTIAL.Kampkod := '';
    cTIAL.Abnr := '';
    cTIAL.Sign := '';
    cTIAL.Alarmdate := '';
    cTIAL.Kampkod := i.Kampkod;
    cTIAL.Abnr := i.Abnr;
    cTIAL.Sign := i.fordsalj;
    cTIAL.Alarmdate := i.alarmdate;
    nCount := nCount + 1;
    IF vLopnr = -1 THEN
    raise_application_error(-20002,
    'Error Creating task for: '||cTIAL.Kampkod||' '||cTIAL.Abnr||' Sales Rep: '||cTIAL.Alarmdate);
    END IF;
    END LOOP;
    DBMS_OUTPUT.PUT_LINE('I created '||nCount||' records.');
    END createFollowUpTask_Exposure;
    Thanks in advance for any help.

    Hi,
    Welcome to the forum!
    Try this (not tested) as an example:
    PROCEDURE createFollowUpTask_Exposure(psUppgkedjetyp IN tis.tial.uppgkedjetyp%TYPE DEFAULT NULL,
                                          psAlarmtyp     IN tis.tial.alarmtyp%TYPE DEFAULT NULL,
                                          psSubtyp       IN tis.tial.subtyp%TYPE DEFAULT NULL,
                                          pnDays         IN NUMBER DEFAULT NULL,
                                          psKampkod      IN tis.tiin.kampkod%TYPE DEFAULT NULL,
                                          psKatnr        IN tis.tiin.katnr%TYPE DEFAULT NULL,
                                          psUtgava       IN tis.tiin.utgava%TYPE DEFAULT NULL,
                                          psKatslag      IN tis.tikg.katslag%TYPE DEFAULT NULL,
                                          psProdsyst     IN tis.tikg.prodsyst%TYPE DEFAULT NULL,
                                          psUppgtyp      IN tis.tiin.uppgtyp%TYPE DEFAULT NULL,
                                          psProdkod      IN tis.tiin.prodkod%TYPE DEFAULT NULL,
                                          psStatus       IN tis.tiin.status%TYPE DEFAULT NULL) AS
       cTIAL         tis.tial%ROWTYPE;
       vLopnr        tis.tial.lopnr%TYPE;
       vSqlWhere     VARCHAR2(4000);
       vGroupBy      VARCHAR2(1000) := ' tiin.kampkod, tiin.abnr, tiko.fordsalj';
       cSelectCursor SYS_REFCURSOR;
       vSqlSelect    VARCHAR2(4000);
       psDays        VARCHAR2(50);
       cRec          T_TIAL_REC;
       nCount        NUMBER := 0;
       FUNCTION fnc_cSqlSelect(SqlWhere IN VARCHAR2,
                               GroupBy  IN VARCHAR2) RETURN VARCHAR2 IS
       BEGIN
          RETURN 'SELECT tiin.kampkod,
                 tiin.abnr,
                 tiko.fordsalj,
                 MAX(tici.regdat) ALARMDATE
            FROM tis.tiin
            JOIN tis.tiko ON tiin.kampkod = tiko.kampkod
                         AND tiin.abnr = tiko.abnr
            JOIN core.tici ON tiin.kampkod = tici.kampkod
                          AND tiin.abnr = tici.abnr
                          AND tici.inplnr = tiin.inplnr
           WHERE 1 = 1 ' || SqlWhere || ' GROUP BY ' || GroupBy;
       END fnc_cSqlSelect;
    BEGIN
       -- If these parameters are null, raise error
       IF psUppgkedjetyp IS NULL AND psSubtyp IS NULL THEN
          raise_application_error(-20001,
                                  'Either Event Chain or Starting Event must be assigned');
       END IF;
       -- Populate TIAL values
       IF psUppgkedjetyp IS NOT NULL THEN
          cTIAL.Uppgkedjetyp := psUppgkedjetyp;
       END IF;
       IF psAlarmtyp IS NOT NULL THEN
          cTIAL.Alarmtyp := psAlarmtyp;
       END IF;
       cTIAL.Handklass := 'T';
       cTIAL.Blobid    := 0;
       IF pnDays IS NOT NULL THEN
          psDays := '+ ' || pnDays;
       END IF;
       IF psSubtyp IS NOT NULL THEN
          cTIAL.Subtyp := psSubtyp;
       END IF;
       -- Create Where clause for cursor
       vSqlWhere := '';
       IF psKampkod IS NOT NULL THEN
          vSqlWhere := vSqlWhere || ' AND tiin.kampkod = ''' || psKampkod || '''';
       END IF;
       IF psKatnr IS NOT NULL THEN
          vSqlWhere := vSqlWhere || ' AND tiin.katnr = ''' || psKatnr || '''';
       END IF;
       IF psUtgava IS NOT NULL THEN
          vSqlWhere := vSqlWhere || ' AND tiin.utgava = ''' || psUtgava || '''';
       END IF;
       IF psKatslag IS NOT NULL THEN
          vSqlWhere := vSqlWhere || ' AND tikg.katslag = ''' || psKatslag || '''';
       END IF;
       IF psProdsyst IS NOT NULL THEN
          vSqlWhere := vSqlWhere || ' AND tikg.prodsyst = ''' || psProdsyst || '''';
       END IF;
       IF psUppgtyp IS NOT NULL THEN
          vSqlWhere := vSqlWhere || ' AND tiin.uppgtyp = ''' || psUppgtyp || '''';
       END IF;
       IF psProdkod IS NOT NULL THEN
          vSqlWhere := vSqlWhere || ' AND tiin.prodkod = ''' || psProdkod || '''';
       END IF;
       IF psStatus IS NOT NULL THEN
          vSqlWhere := vSqlWhere || ' AND tiin.status = ''' || psStatus || '''';
       END IF;ç
       -- Loop through all records meeting input parameters and set required TIAL values.
       OPEN cSelectCursor FOR fnc_cSqlSelect(vSqlWhere,
                                             vGroupBy);
       LOOP
          FETCH cSelectCursor
             INTO v; -- You must define a variable 'v' to hold the data of cursor
          EXIT WHEN cSelectCursor%NOTFOUND;
          --FETCH cSelectCursor INTO cRec;
          cTIAL.Kampkod   := '';
          cTIAL.Abnr      := '';
          cTIAL.Sign      := '';
          cTIAL.Alarmdate := '';
          cTIAL.Kampkod   := i.Kampkod;
          cTIAL.Abnr      := i.Abnr;
          cTIAL.Sign      := i.fordsalj;
          cTIAL.Alarmdate := i.alarmdate;
          nCount := nCount + 1;
          IF vLopnr = -1 THEN
             raise_application_error(-20002,
                                     'Error Creating task for: ' || cTIAL.Kampkod || ' ' ||
                                     cTIAL.Abnr || ' Sales Rep: ' || cTIAL.Alarmdate);
          END IF;
       END LOOP;
       CLOSE cSelectCursor;
       DBMS_OUTPUT.PUT_LINE('I created ' || nCount || ' records.');
    END createFollowUpTask_Exposure;
    /Regards,

  • 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;

  • Where clause is not being passed to the report

    I just upgraded my crystal reports from 10.0 to 11 R2. Reports were working fine in 10.0 version,
    Reports are called from vb.net (vissual studio 2005). When I was running this reports using crystal 10.0 and visual studio 2005, it was working fine, After the upgrade report runs but I am noticing that where clause is not being passed to the reports.It generates report as there is no where clause and produces multiple pages report.

    I believe you are encountering an issue documented in [this|https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/oss_notes_boj/sdn_oss_boj_bip/sap(bD1lbiZjPTAwMQ==)/bc/bsp/spn/scn_bosap/notes.do] note.
    Ludek

  • Passing check box values to WHERE clause

    Hi,
    I have created a Data block - 'CONTACTS' (Database data block)
    and has database item - 'Code', 'Descr'
    The number of records displayed is set to 5.
    Value When checked - 'Y'
    Value When Unchecked - 'N'
    Check box mapping of other values - 'unchecked'
    I am writing the code inside 'WHEN BUTTON PRESSED'. My main objective is to return the count of records based
    based on several conditions and one among them is CODE which is can be single or multiple based on the check box checked.
    The requirement is when i check one or multiple checkboxes, i should pass the 'Code' item values to the WHERE clause.
    Right now whenver i am trying to do so, only the current record value is copied to the WHERE clause.
    I have tried using basic loop but things havnt worked.
    Logic tried with basic LOOP
    BEGIN
    GO_BLOCK('CONTACT');
    IF :contact.cb = 'Y' THEN
    LOOP
    IF p_where is null then
    p_where := :contact.code;
    else
    p_where := p_where ||','||:contact.code;
    end if;
    exit when :system.last_record = 'TRUE';
    next_record;
    END LOOP;
    end if;
    MESSAGE ( 'p_where :'||p_where);
    MESSAGE (' ');
    END;
    And Even if i write the LOOP before the first IF, it return me the current record value and move to the last record.
    please guide me where am i wrong.
    Regards.
    Anoop.

    Try something like this:
    FIRST_RECORD;
    LOOP
      IF :contact.cb = 'Y' THEN
        IF p_where is null then
           p_where := :contact.code;
         else
           p_where := p_where ||','||:contact.code;
         end if;
       END IF;
      exit when :system.last_record = 'TRUE';
      next_record;
    END LOOP;
    -- END LOOP;
    MESSAGE ( 'p_where :'||p_where);
    MESSAGE (' ');
    END;

  • How can I pass multiple condition in where clause with the join table?

    Hi:
    I need to collect several inputs at run time, and query the record according to the input.
    How can I pass multiple conditions in where clause with the join table?
    Thanks in advance for any help.
    Regards,
    TD

    If you are using SQL-Plus or Reports you can use lexical parameters like:
    SELECT * FROM emp &condition;
    When you run the query it will ask for value of condition and you can enter what every you want. Here is a really fun query:
    SELECT &columns FROM &tables &condition;
    But if you are using Forms. Then you have to change the condition by SET_BLOCK_PROPERTY.
    Best of luck!

  • Passing a value to Inline View  WHERE clause through JDev...

    Hi ,
    I need to pass a value to inline view which is mentioned in below VIEW query.
    That view is created inside a view using jDev. Note that there are two WHERE clauses one in the Main query and the other in the Inline view.
    How to set the value for the innerView.
    //copied the code from Java
    view.volAlertsHistroyView.setWhereClauseParam(1, new Integer(clientId));
    Gives an error Missing IN or OUT parameter at index:: 1
    SELECT Alerts.SEND_TIME,
         Alerts.STATUS,
         Alerts.TEXT ,
         Groups.NAME,
              VolRoles.ROLE_NAME,
                   VolRoles.ID as vid,
                   Groups.ID as gid
         FROM ALERTS Alerts, ALERTS_GROUPS AlertsGroups, GROUPS Groups, VOL_ROLES VolRoles,
    --Inline view starts
    (SELECT GRP_ID, VRL_ID FROM vol_groups WHERE cli_id = :1) user_group_role
    --Inline view ends
    --Actual WHERE clause starts
         WHERE ((Alerts.ID = AlertsGroups.ALT_ID)AND (AlertsGroups.GRP_ID = Groups.ID))AND (AlertsGroups.VRL_ID = VolRoles.ID)
         AND AlertsGroups.VRL_ID = user_group_role.VRL_ID AND AlertsGroups.GRP_ID = user_group_role.GRP_ID
    Please get back to me .
    Regards
    Mohan
    [email protected]

    What happens when you change your Java code to:
    view.volAlertsHistroyView.setWhereClauseParam(0, new Integer(clientId));
    The ":1" does not directly relate to the where clause param index you use in Java. In your query you could also use a ":2" for example. In BC4J you still use "0" for the first param.
    Sascha

  • Pass values dynamically to the WHERE clause in SFAPI

    Hi there
    We have a requirement to pass values dynamically (in the run-time of the interface) to the WHERE condition to our SFAPI query.
    Eg -
    SELECT person, personal_information, address_information, phone_information, email_information, employment_information, job_information, compensation_information, paycompensation_recurring, paycompensation_non_recurring, job_relation, accompanying_dependent,         global_assignment_information, direct_deposit, national_id_card, person_relation
              FROM CompoundEmployee
              WHERE last_modified_on &gt;= to_date('LAST_RUN_DATE')  AND
                           last_modified_on &lt;= to_date('CURRENT_RUN_TIME') 
    LAST_RUN_DATE is stored in a custom entity for which we execute another OData query. The custom entity is updated with the CURRENT_RUN_TIME once the interface has been executed successfully. So the next time the interface is run it picks up the LAST_RUN_DATE from the custom OData entity.
    SAP PO has the functionality to run a dynamic query for OData adapters. Refer to Note 2051137 - PI Successfactors adapter : Dynamic odata query and single synchronous sfapi query
    Eg - select fields from position (this is what you state in OData query path in the comms channel; this is static); and you have an advanced tab in comms channel where you mention dynamicquery and set it to true (this points to a XSD which has the keyword TOP, SKIP & FILTER in it).
    This gets the filter values passed from the BPM from another query (from a OData cust_table).
    So the whole query is - select fields from position filter field a = x field b = y etc. Field a field b are fields in position that are you passing values x and y in run time of the interface.
    SAP PO also has the advanced tab feature for SFAPI for dynamic query.
    Question is -
    how to use it?
    has anyone implemented this before?
    What does XSD will look like?
    How do we pass values to the fields to the Where clause for SFAPI.
    Any ideas are welcome!
    Regards
    Arijit Das

    After you have added a new where clause on the detail VO, try re-executing VO's query by DetailVO.executeQuery()
    If it doesn't work try re-executing the MasterVO's query after you have added the where clause on the detail

  • How to pass the parameter in the where clause of the select statement

    Hi All,
    Iam getting one of the value from the Input otd and using this value i need to query one of the tables in oracle database and selected the table using the oracle eway otd like shown below .
    otdRISKBLOCK_1.getRISKBLOCK().select() .
    where clause in side the select takes a string parameter as Iam getting the string parameter from the input otd and passing this to where clause by creating a string literal after deployment it is giving an error saying "ORA-00920: invalid relational operator".
    can any one throw some input on this .
    Thanks in Advance
    Srikanth

    You will see this error if the search condition was entered with an invalid or missing relational operator.
    You need to include a valid relational operator such as
      =, !=, ^=, <>, >, <, >=, <=, ALL, ANY, [NOT] BETWEEN, EXISTS, [NOT] IN, IS [NOT] NULL, or [NOT] LIKE in the condition. in the sql statement.
    Can you throw some more light on how are you designing your project?

Maybe you are looking for

  • How do I completely crop a PDF so that the cropped data is removed and the file size is reduced?

    How do I completely crop a PDF so that the cropped data is removed and the total file size is reduced? When I use the "Crop" function, the cropped data still remains in the file and there is no reduction in file size. I need a way to truly crop a PDF

  • IMac not going to standby or screensaver.

    My iMac doesn't seem to want to go into standby or screensaver, I've set it to go to screensaver after 5 mins of no use yet I've left it way over an hour and still nothing, restarting has no effect, it still goes to sleep but only if I tell it too. W

  • Working with local xml file

    Hi, I would like to work with a local xml file, but I don't want to point to a strict location as I would like my application to run on a few different machines. Is there a special place within Netbeans project structure that I can place such files?

  • Error Code 16

    I reinstalled my photoshop cs6 .exe multiple times, and I keep getting error code 16. PLEASE tell me how to fix this. Email me at (removed) for a solution. Message was edited by: PECourtejoie

  • New Time Machine keeps forgetting Wi-Fi Password

    I have reset the brand new Time Machine about 10 times. I reset it to factory, put in passwords, and it might work for a day, but then will not take the password I set. Sometimes, it quits working as fast as a few minutes after I set it up. I've even