pl/sql is it possible to put the cursor in where clause?

Hello

I have this stored proc that works very well when it is passed a single ID... now he must pass a list of IDS as in
function (cursor (select id from table))...


its definition is like this:
RETURN ACTIV_PKG.tADR_ACTIV PIPELINED IS function ADR_ACTIV (pi_NO_SEQ IN sys_refcursor)
CURSOR c1 (p_NOSEQ IN sys_refcursor) IS
WITH Lateststate AS
(SELECT RESUM_ETA.NO_SEQ_CLE_PRIM NO_SEQ_ADR,
ADR.NO_SEQ,
RESUM_ETA. COD_ETA
OF RESUM_ETA
JOIN INTERNAL ADR
ON ADR.NO_SEQ_ADR = RESUM_ETA.NO_SEQ_CLE_PRIM
WHERE RESUM_ETA. COD_TBL = "ADR1".

and IN ADR.NO_SEQ (p_NOSEQODS)


)...

You see that 'and ADR.NO_SEQ IN (p_NOSEQODS)' lines using only those on the list filters...

the idea is to use the cursor c1 like this:
BEGIN
FOR rec1 IN c1 (pi_NO_SEQ)
LOOP
...

Except that I get an error with (p_NOSEQODS) because it is not supported...

y at - there a trick to this?

Should I use table instead of cursor in where clause IN (...)?


I have not in a list of IDS and put it in where clause of my cursor c1... How to get there?

Thanks for the advice/links

See you soon!

the idea is to use the cursor c1 like this:
FOR rec1 IN c1 (pi_NO_SEQ)

Don't know if it's really less awkward that solution regexp, but we here are:

   cur   sys_refcursor;

   cursor c2 (cur sys_refcursor)
   is
      select   *
        from   emp
       where   empno in (select   trim (t.column_value.extract ('//text()'))
                           from   table (xmlsequence (cur)) t);
begin
   open cur for
      select   7788 from dual
      union all
      select   7900 empno from dual;

   for c in c2 (cur)
   loop
      dbms_output.put_line (c.ename);
   end loop;
end;
/
SCOTT
JAMES
PL/SQL procedure successfully completed.

Tags: Database

Similar Questions

  • What is the significance of the CURSOR WITH HOLD clause in a cursor declaration?

    What is the significance of the CURSOR WITH HOLD clause in a cursor declaration?

    A cursor that has been declared with the clause WITH HOLD, after the word CURSOR remains open after a COMMIT or a ROLLBACK. The following example shows how to use the following clause:

         EXEC SQL          DECLARE C1 CURSOR WITH HOLD          FOR SELECT ENAME FROM EMP          WHERE EMPNO BETWEEN 7600 AND 7700      END-EXEC.
    

    The cursor must not be declared for the UPDATE. The WITH HOLD clause is used in DB2 to override the default, which is to close all cursors on validation. Pro * COBOL provides this clause in order to facilitate the migration of applications to DB2 to Oracle. When MODE = ANSI, use Oracle DB2 default, but all host variables must be declared in a declare Section.

    Reference:

    Oracle documentation!
    http://docs.Oracle.com/CD/B10501_01/AppDev.920/a96109/pco03dbc.htm

  • dynamice where the Cursor For loop clause

    Hi all

    I have a cursor based as logic:

    FOR temp IN (SELECT colname FROM WHERE whereconditions mytablename)
    loop
    .
    .
    .
    end loop;

    Is there anyway that I can do the whole dynamic WHERE clause?

    My where clause should exist only when a certain condition is met. Please help me.

    Thank you
    Chaitanya

    No, it wouldn't. Performance of:

    open temp for 'select clause'
    loop
    fetch into..
    exit when (temp%notfound);
    merge logic....
    end loop;
    

    would be no different from:

    for rec in cur loop
    merge logic....
    end loop;
    

    SY.

  • Is it possible to put the files in drive J on the C drive?

    By transferring data from XP again Windows 7, provided about my Outlook seems not to have been transferred using the Easy Transfer Wizard, so I downloaded the missing data on a disc of J.  In order to put in my Office Outlook, he needs on the C drive in my new computer, it's a .pst file.  Is it possible to transfer the info from the j to the portion of the C drive that has other transferred Office Outlook .pst files?  If so, how?

    Thank you.

    Open Outlook
    Click on the file tab
    Click on Open & Export
    In the main window, click on Import/Export
    In the wizard import / export , click import from another program or file
    Click Next
    Click Outlook Data File (.pst)
    Find and select the file .pst on your drive J
    Select one of the options three import
    Click Next
    Click Archive Folders
    Check include subfolders
    Select one of the places two import
    Click Finish
    You have completed

  • Is it possible to put the results of a query in a variable to use in the bean class?

    Hello, I am using JDeveloper 12.1.2.0.0

    I like to keep the result of my queries (the method that I created in the AppModule) in a richeTableau or another type of variable, so I can get results and I don't have to make unnecessary after queries. I don't think that the query is the problem but keeping the results.

    I tried to do in using this:

    public String testVFactSales (String conditions) {}

    PreparedStatement query = getDBTransaction () .createPreparedStatement ("" + "select * from v_fact_sales"+ conditions, 0 ");

    ResultSet rs;

    Outcome of the result set;

    Result of the richeTableau;

    String result = null;

    try {}

    query.setString (1, conditions);

    Query.Execute ();

    Query.Execute ();

    result = query.getGeneratedKeys ();

    Query.Close ();

    System.out.println ("result:" + result.toString ());

    return result.toString ();

    } catch (SQLException e) {}

    e.printStackTrace ();

    }

    Return ' ';

    }

    As you can see, I have already tried a few solutions, but so far I have only errors (cannot convert or null exception, when I try to put the result in a richeTableau in my bean class)

    Any ideas?

    It is very important for me, because it would improve the performance of my project a lot.

    Kind regards

    Frederico.

    Although the issue is not 100% responded, I used the idea that Shay told me, where you can create a method in your AppModule to set your where clause!

    Good luck to everyone who has the same problem.

    As an attack similar to what I wanted in the first place, you can check this:

    https://community.Oracle.com/thread/2619669

    Kind regards

    Frederico.

  • Automatically put the cursor in the text box to start

    Hi guys

    On the picture below you can see a small piece of my FP. It is a part of a bigger FP for a pretty huge electronics test. Each PCB got its own series number of barcode. I have a drive that is connected to my keyboard. Then when I read the code bar, numbers will appear in the text box on my FP, IF i first click on the text box. Then the user must only press START to do the test. My problem, or wish, if you like, is that when the program starts, or a test has completed, the cursor/marker is placed in the text box, so I just have to read bar codes.

    Currently, the user must click in the text box before you read the code bar. Is it possible that this can be done by Labview?

    I n node property checked yet, because I'm busy to something else right now at work. Just write in my break.

    Thanks for any help!

    PS I would have found the answer in the forum, but I am from Norway, and not all of the language of the computer is easy to translate since I use windows Norwegians. I belive that it is called cursor or marker however.

    Kind regards

    Even

    Hello

    The property node "KeyFocus" attached here brings the cursor automatically in the text box.  Set the "Val (Sgnl)" blank to trigger the event associated with this area of text (if necessary).

    I hope this helps.

  • problem with the CURSOR and WITH clause

    Hi guys,.

    I have never created a package before. I try to run it, but I get:
    ORA-06550: line 8, column 16:
    PLS-00382: expression is of the wrong type
    ORA-06550: line 8, column 3:
    PL/SQL: Statement ignored

    I know that my problem is in the next section

    OPEN FOR V_io_cursor

    with GOT_R_NUM like)


    Is the above correct?

    When I copy paste the "heart" of the query, it works very well. I really have a problem with the CURSOR and the declaration.

    Here's the code in its entirety. I know that the code is much more then he returned, but ignore this overload that was to do some tests to make sure that I can achieve any query request.

    CREATE OR REPLACE
    PKG_SPF_NATIONALREPORTS PACKAGE BODY IS

    PROCEDURE GET_NATIONAL_TOTAL_RESULTS (P_SelectFields IN varchar2, P_SUMFields IN varchar2, io_cursor IN OUT C_RESULTS)
    IS
    v_io_cursor C_RESULTS;

    BEGIN

    OPEN FOR V_io_cursor

    with GOT_R_NUM like)
    SELECT
    -START P_SelectFields
    r.cli_served,
    r.EIER,
    -END P_SelectFields
    r.RC,
    r.Year_ID,
    r.period_id,
    r.agreement_type_ind,
    CONTRACT_NUMBER. CONTRACT_NUMBER_TEXT,
    YEARS.year_desc,
    RC_CODE.rc_code_id,
    RC_CODE.rc_code,
    AHRDA HOLDERS. AHRDA_ID,
    AHRDA HOLDERS. REGION_ID,
    AHRDA HOLDERS. PROVINCE_ID,
    AGREEMENT_TYPE. AGREEMENT_TYPE_ID,
    AGREEMENT_TYPE. AGREEMENT_TYPE_DESC_EN,
    ROW_NUMBER() over (partition R.YEAR_ID, R.CONTRACT_Number_Text
    order by
    P.PERIOD_desc
    (/ / DESC NULLS LAST) AS r_num
    RESULT r
    JOIN period p ON r.period_id = p.period_id
    JOIN CONTRACT_NUMBER ON r.contract_number_text = CONTRACT_NUMBER. CONTRACT_NUMBER_TEXT
    JOIN RC_CODE ON contract_number.rc_code_id = rc_code.rc_code_id
    JOIN AHRDA holders ON ahrda.ahrda_id = rc_code.ahrda_id
    JOIN AGREEMENT_TYPE WE AHRDAS. AGREEMENT_TYPE_ID = AGREEMENT_TYPE. AGREEMENT_TYPE_id
    JOIN the YEARS WE r.year_id = YEARS.year_id
    )
    SELECT year_desc
    -START P_SUMFields
    SUM (cli_served) AS sum_cli_served
    The SUM (eier) AS sum_eier
    -END P_SUMFields
    OF got_r_num
    GROUP BY year_desc
    ORDER BY year_desc
    ;

    io_cursor: = v_io_cursor;

    END GET_NATIONAL_TOTAL_RESULTS;

    Agree - all this talk of loops FOR is completely irrelvant.
    A refcursor is usually the exact mechanism to return a result set.

    What is C_RESULTS?

    Just use SYS_REFCURSOR.

    No need for local variable.

    OUT why? Not just walk OUT?

    PROCEDURE GET_NATIONAL_TOTAL_RESULTS
    (P_SelectFields IN varchar2, P_SUMFields IN varchar2, io_cursor OUT SYS_REFCURSOR)
    IS
    BEGIN
     OPEN io_cursor FOR ...
    END;
    
  • function defined by the user in where clause

    Hello

    Please let me know how to use user-defined in the where clause. I need to use the function that returns the date for dateid.
    It generates the error...
    SELECT To_char(fnc_get_date_for_dateid(a.postdateid),'DD-MON-YYYY') transaction_date,
           SUM(A.points) POINTS_OR_MILES_CREDITED,
           SUM(CASE WHEN a.points is null THEN a.transactionamount ELSE a.points END),              
    FROM   accrual a
    JOIN   datecal dc ON dc.dateid = a.postdateid  
    join   MemberALL m on m.memberid = a.memberid
    WHERE a.awardnumber IS NULL
      AND a.accrualtype = 'B'
    GROUP BY To_char(fnc_get_date_for_dateid(a.postdateid),'DD-MON-YYYY')
    ORDER BY a.postdateid;
    Error
    ORA-00979: not a GROUP BY expression
    00979. 00000 -  "not a GROUP BY expression"
    Thank you
    Sandy

    Hi Sandy,

    Have you tried like
    ===========================

    SELECT To_char (fnc_get_date_for_dateid (a.postdateid), 'DD-MON-YYYY') transaction_date,.
    Sum (A.points) POINTS_OR_MILES_CREDITED,
    SUM (CASE WHERE the a.points is null THEN a.transactionamount ELSE a.points END),
    The ACCRUAL one
    JOIN dc datecal ON dc.dateid = a.postdateid
    Join MemberALL m on m.memberid = a.memberid
    WHERE a.awardnumber IS NULL
    AND a.accrualtype = 'B '.
    GROUP BY a.postdateid - To_char (fnc_get_date_for_dateid (a.postdateid), 'DD-MON-YYYY')
    ORDER BY a.postdateid;
    ==========================

    Thank you
    Slokam

  • Is it possible to put the property inside the loop node?

    I created three nodes of separation of property (color graphics) for my 3 XY graphs.

    Is it possible to have a property node, put this tag inside the loop where I ranges from 1 to N, and say plot_color_i

    where plot_color_1 would update 1 XY graph, plot_color_2 update XY Graph 2, etc. ?

    See the attached VI.

    Yes.  Create an array of references to the XY graphs and have this auto-index in the property node in the loop For

  • Is it still possible to put the URL bar on the front?

    Before the most recent change on my windows machines, I have had the firefox toolbar url and tabs button all on a single bar inside the "aero" windows style window decoration.

    Is it still possible to do? For the moment, I can't move the toolbar URL or menu options out of the toolbar and in the window decoration. If this is not possible can be done with an add-on? This change has doubled real estate display should read these.

    1. Classic restaurateur theme installation and restart Firefox when prompted.
    2. Open the modules (Ctrl + Shift + A Manager; Mac: Command + shift + A), then the Extensions category.
    3. Beside the classical restaurant theme, click on the Options button.
    4. On the main tab, make sure 'Mobile back-forward button' is checked. You can also check "Hide urlbars stop & reload buttons" and "combine stop & reload buttons. Close the options window when finished.
    5. Right-click on a zone empty of the tab bar and select Customize.
    6. Drag the front/rear, address bar, and any other key that you want in the toolbar and navigation on the tab bar.
    7. Drag all the unwanted items off the coast of the toolbar and navigation on the range of customization.
    8. Click the Customize the output at the bottom right button when finished.
    9. In modules, Extensions category, beside the classical Restorer theme Manager, click the Options button.
    10. On the main tab, under general UI, check "hide navigation bar. Close the options window when finished.
  • Is it possible to put the speakers as the default output for the sounds of Windows and the headset as default device for music?

    Hello

    Is it possible to have all the sounds through the speakers, including music from WMP and WMP music in my headphones? Headset is USB (but I also have a Jack) and my speakers are with 3 Sockets at the back of my pc.
    Thank you.
    Friend,
    Zoenvisje
     
    Original title: all sounds through loudspeakers and music through headphones

    Hi zoenvisje,

    Thanks for posting your query in the Microsoft Community.

    Want to know if it is possible to play any sound on the computer with the headset. It can be difficult when something that is important to you does not work as expected.

    Method-

    It is not possible to make these changes on the computer.

    You can set a default speakers and use a different music player that supports select the default output as the headset device.

    We know if you need help. We will be happy to help you. We, at tender Microsoft to excellence.

    Thank you.

  • [Advanced] Is it possible to put the IP Address of the default gateway for a vmnet NAT?

    I am trying to duplicate a computer lab on my Mac environment, and I need the bridge will be located at one address other than VMWare wants to implement.  I know how to create a static IP address for a virtual machine, but I need adjust the routers option in Library/Preferences/VMWare Fusion/vmnet2/dhcpd.conf.  Will there be a networking Library/Preferences/VMWare Fusion/to allow this?  Is there something I can put before or after the "DON'T CHANGE" section dhcpd.conf that replace the parameters in this section?

    Except that, is there a way to prevent the re-writing of the dhcpd.conf file after I made a change to VMWare?  I tried it wrong in various ways, including the re - generate the hash SHA1 of the networking file and reset the modification time of the dhcpd.conf to the original time, without success.

    Here are my current settings:

    subnet 10.10.0.0 255.255.0.0 subnet mask}

    range 10.10.128.0 10.10.255.254;

    option broadcast-address 10.10.255.255;

    option domain-name-servers 10.10.0.2.

    option domain-name localdomain.

    by default-lease-time 1800;                # default is 30 minutes

    Max-lease-time 7200;                    # default is 2 hours

    option netbios-name-servers 10.10.0.2.

    routers option 10.10.0.2.

    }

    host vmnet2 {}

    Hardware ethernet 00:50:56:C0:00:02;

    fixed-address 10.10.0.1;

    option domain-name-servers 0.0.0.0.

    option domain-name ";

    routers option 0.0.0.0.

    }

    And I'm changing the gateway to 10.10.0.2 to 10.10.1.250.  Maybe VMWare requires that the first IP address as the host and the second either the entry door and rewritten if not?

    Thanks in advance,

    Dave

    I found a way to do this.  Not sure if it's official, or if it will continue to work in the future.  In addition changes nat.conf, if you simply duplicate the part of the section "DON'T CHANGE" dhcpd.conf below, then the second version of the settings will cancel and replace the first.  Here is my solution:

    # Configuration file for ISC 2.0 vmnet-dhcpd operating on vmnet2.

    #

    # This file was generated automatically by Setup of VMware.

    # See Instructions below if you want to change.

    #

    # Define us domain-name-servers to satisfy some DHCP clients

    # (dhclient such as configured in SuSE, TurboLinux, etc..).

    # We also provide a domain name to the pump (Red Hat 6.x) happy.

    #

    # VMNET DHCP Configuration. Beginning of "DO NOT EDIT ARTICLE" #.

    # Instructions change: this section of the configuration file contains

    # News generated by the Setup program. Do not change it

    # section.

    # You are free to change to everything else. In addition, this section must start

    # on a new line

    # This file will get saved under a different name in the same directory

    # If this section is edited and you try to set up DHCP again.

    # Written on the: 04/11/2015-21:15:15

    allow unknown-clients;

    by default-lease-time 1800;                # default is 30 minutes

    Max-lease-time 7200;                    # default is 2 hours

    subnet 10.10.0.0 255.255.0.0 subnet mask}

    range 10.10.128.0 10.10.255.254;

    option broadcast-address 10.10.255.255;

    option domain-name-servers 10.10.0.2.

    option domain-name localdomain.

    by default-lease-time 1800;                # default is 30 minutes

    Max-lease-time 7200;                    # default is 2 hours

    option netbios-name-servers 10.10.0.2.

    routers option 10.10.0.2.

    }

    host vmnet2 {}

    Hardware ethernet 00:50:56:C0:00:02;

    fixed-address 10.10.0.1;

    option domain-name-servers 0.0.0.0.

    option domain-name ";

    routers option 0.0.0.0.

    }

    # VMNET DHCP Configuration. End of "DO NOT EDIT ARTICLE" #.

    subnet 10.10.0.0 255.255.0.0 subnet mask}

    range 10.10.128.0 10.10.255.254;

    option broadcast-address 10.10.255.255;

    option domain-name-servers 10.10.1.200.

    by default-lease-time 1800;                # default is 30 minutes

    Max-lease-time 7200;                    # default is 2 hours

    option netbios-name-servers 10.10.1.250.

    routers option 10.10.1.250;

    }

    -Dave

  • Is it possible to put the words in bold or underline things in email in thunderbird?

    When you send a note with the name of the books for example, I would like to highlight the name of the book which is the right thing to do, but I can't find anywhere in Thunderbird where I can use this option. Also, I can't find how to use italics or bold to emphasize something. Please notify. Thank you. Billie Matelski

    Perhaps you composed in HTML.

    Right-click on the account, in the folders pane, select settings and in composition and correct select compose in HTML.

  • Is Lenovo ThinkPad X220t 4294-CTO, possible to put the backlit keyboard in this machine?

    Hi once again, everything

    My question is the same as the topic

    Best regards.

    No, sorry.

    backlit keyboards come as an option on the T/X/W x 30 models. What are the 6 precision keyboards ranks Island-style and are not backward compatible models the x2x.

    HTH to clarify.

  • Is it possible to change the default location where Firefox stores its profiles and browsing history

    Normally the profiles and browsing history stores in %APPDATA%\Mozilla\Firefox

    Now, I want to change the location somewhere ("like in the office"), even during installation or after the installation of Firefox.

    Can someone help me...

    Thanks in advance...

    Mickael Kuramala.

    Hello Michael, you can use the Profile Manager to create a new profile in a custom location. more information is available to use the Profile Manager to create and delete profiles Firefox.

Maybe you are looking for

  • Software instruments are mixed

    Hello I use MainStage 3.2.4 on OS X 10.11.5, and I noticed that in the past few months (since it updates recent, I don't know if it was the last or previous), sometimes, when I opened a concert, a lot of settings for software instruments have swapped

  • Energy saver settings missing from the Profile Manager

    I'm under Server.app 5.1 on a MacPro El Capitan (10.11.4) running. I am trying to create a fake profile in the Profile Manager to distribute to my class to illustrate patterns of school boards and want to create one for the energy-saving settings. Un

  • Worspace and button in case of failure

    Alll three buttons on the mat glows. By pressing the button for the carpet will cause the button blinks several times, but nothing happens. Trying to open the Workspace germs; It opens the window of the lauch, then goes back to the desktop view. I us

  • Soak the test in India

    Soak test is out for US and the bike can you give updates when impregnation testing will begin for the India?

  • I would like to know how I could get a copy of the discussion, I had a contact in MSN

    I would like to know how I could get a copy of the discussion, I had a contact in MSN I didn't save them and need. My msn address is * address email is removed from the privacy *. I need the discussion, I had with * address email is removed from the