Handling multiple cursors with column of date datatype  issue reg

Dear all,
i am using three cursors in one pl/sql block each of this three cursor will fetch data based on column of date data type.i believe due to each condition relate to same table,contradiction may arise i.e
1> when code will execute , cursor c1 will do the job perfectly but c2 & c3 here may not be able to solve the purpose since the job has already been done by cursor c1 which i am not sure.my doubts i need all cursor to work based on each condition.
any suggestion from your side could sort out this issues.
Thanks n regards
Laxman
begin
for c1 in(select reqid from request where lastmoddate<sysdate - 8/24 and statuscode=1 and assigned_personid is not null)loop
update srequest set status=open where reqid=c1.reqid;
commit;
end loop;
for c2 in(select reqid from request where lastmoddate<sysdate - 1 and statuscode=1 and assigned_personid is null)loop
update srequest set status=open where reqid=c2.reqid;
commit;
end loop;
for c3 in(select reqid from request where lastmoddate<sysdate - 14 and statuscode=1 and assigned_personid is null)loop
update srequest set status=open where reqid=c3.reqid;
commit;
end loop;

If you look, your third cursor has already been included in your second cursor (sysdate - 14 < sysdate - 1), so there's only two conditions that you need to run.
You're also doing row-by-row aka slow-by-slow processing. It would be much, much better (*) if you converted this to one SQL statement - I've rewritten it to be a MERGE statement:
merge into srequest sreq
using (select reqid
       from   request
       where  statuscode = 1
       and    ((lastmoddate < sysdate - 8/24
                and assigned_person_id is not null)
               or
               (last_moddate < sysdate - 1
                and assigned_person_id is null))) req
  on (sreq.reqid = req.reqid)
when matched then
  update
    set status = 'OPEN';(*) more performant, easier to read, debug and maintain.

Similar Messages

  • How to handle multiple clients with DatagramSocket

    I am trying to handle multiple clients with 1 datagramSocket bind to one port (basically I have only one port to use, and I can not use TCP or any other ports). At the server side I have two threads one for receiving packets and buffering them, another for processing the packets in the buffer and sending replies.
    I can have multiple clients sending datagramPackets to me and I will have to process the packets and send them to DIFFERENT clients. Ex. Client 1 sends datagramPacket to Server which sends the processed packet to Client 2. Also Client 2 sends a datagramPacket to Server which again processes the packet and sends it to Client1. May have Client 3 and 4 doing the same thing at the same time... and so on...
    My root class is creating the datagramSocket(somePort) and two threads (receiver and sender). How can I use the socket that I created in these two threads??
    I have done the following and I am getting "java.net.bindexception". When I am sending stuff from Client1 to Client2 everything is fine but when I start sending something from Client2 to Client 1, I get the bindexception... Client 1 is using port 3000, Client 2 is using port 4000.
    I really don't have a lot of experience in socket programming so I am not sure if there is a much simpler way to do this. I appreciate all the tips and help that I can get...
    Thanks...
    class UDP_serv
         static DatagramSocket udpSocket;
         final static int SERVER_PORT     = 2000;
         public static void main(String[] args) throws SocketException
              udpSocket= new DatagramSocket(SERVER_PORT);
              new DataReceiver().start ();
              new DataSender().start ();
         static class DataReceiver extends Thread
              DataReceiver()
                   Thread.currentThread().setName("DataReceiver");
              public void run()
                   while (true)
                        byte pckt[] = new byte [MaxMsgSize];          
                        DatagramPacket dp = new DatagramPacket (pckt, pckt.length);
                        try
                             udpSocket.receive (dp);
                             //PUSH TO RECEIVE BUFFER
                        catch(Exception e)
                             e.printStackTrace();
         static class DataSender extends Thread
              DataSender()
                   Thread.currentThread().setName("DataSender");
              public void run()
                   while (true)
                        processDataMsg();
          static void processDataMsg() 
             DatagramPacket op;
             InetAddress DA = null;
             int DP = 0;
             byte [] outPacket = null;
             // POP FROM RECEIVE BUFFER
             // SOME PROCESSING HERE     
             // Set Destination Address (DA)
             // Set Destination Port (DP)
             // DA and DP are the forwarding IP and Port addresses
             // not the addresses original packet was sent from.
             try
              op = new DatagramPacket (outPacket, outPacket.length,DA, DP);
              udpSocket.send(op);
             catch (IOException e)
              e.printStackTrace();
    }Also for development and testing purposes, I am running the two clients and the server on the same machine (windows xp-32b) so all of the Destination IP Addresses are 127.0.0.1. and as I said Ports that I am using are 2000, 3000, 4000 (Server, Client1, Client2).

    Hmm I have minimized the code and it seems to be working now.
    I think I have an error in the header portion of the data I am sending, where I am storing the source IP/Port and destination IP/Port. I think the server in the middle is messing these values up while sending them to the destination Client. Because the destination client actually receives the stuff and sends the reply back to the server, but the reply packet's headers has 0/0 as the dest IP / Port...
    Server is giving me java.net.BindException: Cannot assign requested address error when it tries to forward the reply it received from the client2 as the address it is trying to send is 0!
    I guess it doesnt just give this error when you try to open two sockets to the same port...
    Paul, Thanks for the direction on how to proceed... took me a while get the minimized code but at least figured out the problem. Well still have to make sure that is THE problem though :)
    As far as the statics goes how can I change those to non static ones? Where do I make an instance of the top level class that creates the threads? and how do I pass the DatagramSocket to the threads/ if I dont need to pass how do I call or use the datagramSocket I created in the top level class? I mean do I still kinda have it like a global variable on the top?? A very simple example would be much appreciated...
    I think these might be really basic questions but I am having a rough time with the hierarchy in java...

  • Web dynpro screen with multiple rows with columns that can be edited

    Web dynpro screen with multiple rows with columns that can be edited individually:
    Hi
    I am busy creating a screen in web dynpro for ABAP which we would like to make available via Portal ESS (Portal 7).
    I need to add 'n type of table (or almost something like Excel) or something in which someone can type a few paycode numbers (there should be lets say 10 blank rows in which info can be typed in and if I click on a button or so, more rows must be added if necessary.  Then in the other colums stuff like amounts must be entered which one should also be able to edit then and there.
    Can anyone assist in what I can use for this?  There does not seem to be some existing element that I can use.
    Help will be appreciated.
    Regards
    Debbie

    Hi Debbie,
    Whiel Creating table you need to be care full that use chose INPUT FIELD as the CELL EDITOR. Just guessing that if ur table is not editable u might have choosen TextView as default cell editor type.
    check link for details on TABLE UI
    [http://help.sap.com/saphelp_erp2005/helpdata/EN/b5/ac884118aa1709e10000000a155106/frameset.htm]
    easy way is to first add UI ELEMENT TABLE to your VIEW, then right click over it & select create binding from context. After you have a pop up where you can select what columns you want what should be its cell editor etc.
    Greetings
    Prashant

  • Handling multiple database with 10g CONSOLE

    Hello list,
    How do we handle multiple databases with 10g Enterprise Console?
    We are running Oracle 10.1.0.2.0 on Windows 2003 server. I have one database setup but I need to install more databases and am having difficulty accessing and managing the second database. thanks for your input.

    may be you can try the following:
    1) create a file named new_target.xml with the following:
    <Target TYPE="oracle_database" NAME="DBAPV9.WORLD" DISPLAY_NAME="DBAPV9">
    <Property NAME="OracleHome" VALUE="/opt/oracle/app/oraadm9i/product/9.2.0.4"/>
    <Property NAME="UserName" VALUE="sys" ENCRYPTED="FALSE"/>
    <Property NAME="password" VALUE="thepassword" ENCRYPTED="FALSE"/>
    <Property NAME="Role" VALUE="sysdba"/>
    <Property NAME="MachineName" VALUE="machine.domain"/>
    <Property NAME="Port" VALUE="1521"/>
    <Property NAME="SID" VALUE="DBAPV9"/>
    </Target>
    replace as appropriate
    2) Execute emctl config agent addtarget new_target.xml
    3) Execute emctl stop dbconsole
    4) Execute emctl start dbconsole

  • Solution: multiple diags with name efa.dat found

    This is a solution to a problem I hit. When I tried to run a diag on the model it would throw the error:
    sims: locating diag efa.dat
    sims: Looking for diag under $SIMS_LAUNCH_DIR
    sims: Caught a SIGDIE. multiple diags with name efa.dat found at /import/dtg-data20/jj155244/OpenSPARCT2/tools/src/sims,1.272 line 4581.
    Solution: do not run in the $DV_ROOT directory. Create a subdirectory for the run or run elsewhere.
    A efa.dat file is created in the run directory by sims. There is also an efa.dat in $DV_ROOT/verif/diag/assembly/include/efa.dat. sims looks for the efa.dat file starting in the run directory. It finds both the files and complains about finding multiple files.

    1. Use the index with the lower fragmentation to identify the newly rebuilt index (as it almost always will have lower fragmentation)
    2. To reproduce, block the online index rebuild process by trying to alter the table's definition in a transaction (and don't commit, which will place schema lock on the table)
    Satish Kartan http://www.sqlfood.com/

  • What is the best approach to handle multiple FK with single table.

    If two tables are joined with each other with more than one ways, for example
    MAIN table is (col1, col2,....coln, person_creator_id, person_modifier_id)
    PERSON table is (person_id, name, address,........ phone) etc
    At database level PERSON_CREATOR_FK and PERSON_MODIFIER_FK are defined.
    Objective is to create a report that shows
    col1, col2...coln, person creator name, person modifier name
    If above two objects are imported with FKs in a EUL and discoverer plus is used to create above report. On first inclusion of person name discoverer plus will ask you to pick the join (provided the checkbox to disable this feature is not checked). Once you pick 'person creator' join it will never allow you to pick person modifier name.
    One solution is two create a custom folder with query like
    select col1, col2,...coln,
    pc.name, pc.address,.... pc.phone
    pm.name, pm.address,.... pm.phone
    from main m,
    person pc,
    person pm
    where m.person_id_creator = pc.person_id
    and m.person_id_modifier = pm.person_id
    Second solution is to import the PERSON folder twice in EUL (optionally named one as perosn_creator and other as person_modifier) and manually define one join per table. i.e. join MAIN with PERSON_CREATOR on person_creator_fk and join MAIN with PERSON_MODIFIER table using person_modifier_fk.
    Now discoverer plus will let you drag Name from each person folder without needing to resolve multiple joins.
    Question is, what approach is better OR is there a better way?
    With solution 1 you will not be able to use functions on folder items.
    With solution 2 there is a EUL design overhead of including same object multiple times and then manually defining all join (or deleting unwanted joins), and this could be a problem when you have person_modifier and person_creator in nearly all tables. It could be more complicated if person table is further linked other tables and users want to see that information too. (for instance, if person address is stored in LOCATION table joined with location_id and user want to see both creator address and modifier address....now you will have to create multiple LOCATION folders).
    A third solution could be to register a function in discoverer that return person name when person_id is passed. This will work perfectly for above requirement but a down side is the report will run slower if they need filters on person names (then function will be used in where clause). Also, this solution is very specific to above scenario, it will not work if you want the report developer the freedom to pick any attribute from person table (lets say, person table contain 50 attributes then its not a good idea to register 50 functions).
    Any comments/suggestion will be appreciated.
    thanks

    Hi
    In a roundabout way you have really answered your own question :-)
    In my opinion, the best approach, although by all means not the only approach - see below) would be to have the object loaded as two folders with one join going to the first folder and the second join to the other folder. You would of course name the folders appropriately.
    Here's a workflow that I use all of the time and one that I teach when I'm giving Discoverer Administrator training. It might help you:
    1. Bring in the PERSON folder to begin with
    2. Make all necessary adjustments to bring it up to deployment standard. These adjustments would be: folder name (E.g PERSON_CREATOR), item names, item placement, default positions, default aggregation and so on.
    3. Create or assign the required lists of values
    4. Create any required calculations
    5. Create any required conditions
    6. Create the first join from this folder to MAIN.
    7. Click on the heading for the folder and press CTRL-C.
    8. Click on the heading for the business area and press CTRL-V. A second copy of the folder, complete with all of the adjustments you made earlier will be inserted into the business area.
    Note: joins are not copied, everything else is.
    9. Rename this folder to say PERSON_MODIFIED
    10. Rename the items as appropriate
    11. Add a join from this folder to MAIN - you're done
    Other ideas that I have used and work well would be to use a database view or create a complex folder. Either will work, In both cases you would need to join on some other column other than the ones you referred earlier.
    I hope this helps
    Best wishes
    Michael

  • Cannot enter data into table with column named DATE

    I have a table as follows:
    CREATE TABLE PACKINGLINE (
    SNO VARCHAR2(13),
    "DATE" DATE DEFAULT SYSDATE,
    PRDORDNO VARCHAR2(12),
    NOW DATE DEFAULT SYSDATE,
    CONSTRAINT PACKINGLINE_PK PRIMARY KEY ("SNO", "DATE"));
    Note the "cleaverly" named DATE and NOW columns (yes, that is the name of the column... our company was bessed with a very clear SQL server DBA in the past)
    This SQL statement works:
    INSERT INTO PACKINGLINE (SNO, PRDORDNO) VALUES ('1000808972', '100080897');
    However when I try use SQL Developer as follows I cannot enter data:
    1. Open SQL Developer
    2. Click on "Tables" then on my table named PACKINGLINE
    3. Click the "Data" tab
    4. Click the [+] "Insert Row" Icon
    5. Enter the same data as above
    6. Click Commit
    7. The following error is shown in the log window and I cannot commit the data change.
    Error message
    ==================
    INSERT INTO "DBO"."PACKINGLINE" (SNO, PRDORDNO) VALUES ('1000808971', '100080897')
    One error saving changes to table "DBO"."PACKINGLINE":
    Row 5: ORA-06550: Row 1、Column 25:
    PL/SQL: ORA-06552: PL/SQL: Compilation unit analysis terminated
    ORA-06553: PLS-320: the declaration of the type of this expression is incomplete or malformed
    ORA-06550: Row 1、Column 7:
    PL/SQL: SQL Statement ignored
    ==================
    I can copy and paste the above query into a normal SQL statement window and the data commits fine.

    Its so flaky there really must be something wrong Mr Adobe support person....
    If I load a PDF, do nothing, gently save it, reopen and then waiting for my trial dialogue to wake up so that I can click on continue trial... then save as extended reader blah.... then close. I have finally saved one that works!!!! but how difficult is that????
    WHAT IS WRONG ADOBE??

  • ECATT questions regarding handling multiple line items in test data conatin

    Hi all,
    We are using  ECATT for automation.
    We do have a query .
    The Question is
    When we have
    Ist   level   Header information     [One entry per header]    
    IInd  level  Item Level information [Per Header Multiple item entries is possible]
    For eg.
    Header
    Sales ordno Customer
    S001           C001
    Item
    Salesordno itemNo Material
    S001          001         M001
    S001          002         M002
    We need  to call an API for creating the salesorder using ECATT .We want to achieve the same with test data container.
    How we can approach this?
    Reg,
    Ganesh
    Message was edited by:
            GaneshKumar P

    hi,
    you can do that by using ABAP...ENDABAP statement.
    By using this command you can write any ABAP login in between.
    and u can also call RFC's, BAPI in between.
    all you need to do is wirte your ABAP code in se38 and make sure that its working fine. then copy ur code to ecatt tool and pleace that in between ABAP...ENDABAP statements.
    hope this helps.
    >>reward if this helps.
    regards,
    kvr

  • How to handle multiple repositories with 11g

    Hi all,
    this question probably is easy but is right that the only way to manage multiple repositories is to have multiple BIEE 11g installation?
    With old 10g with OC4J having multiple installation was quite simple, but here with all weblogic environment is becoming more complex.
    I have two branches in my organisation, each one has 3 different environments: test, preproduction and production with a different repository for each one of course.
    As I have to meet also High Availabilty requirements I have deployed a two different 2nodes cluster. One cluster has 4 envs and the other one just 2 prods.
    All is installed but I still trying to understand or to find a way just to share some resources as for example weblogic server... may a single weblogic installation manage more BI domains?
    Thanks
    Stefano

    Did you ever find a solution to this issue? I come from a BusinessObjects background where you can have as many universes (metadata layers) as you want on your server. I'm trying to figure out a way to replicate that scenario with OBIEE. We have some databases that are so completely unrelated that it doesn't make sense to me to have them all in one big repository, but I don't want to have multiple servers either.

  • How to handle multiple reports with single hyperlink parameter

    Please suggest in my drill down report
    i have two reports linked with one hyperlink
    parameter, how to handle this?
    please suggest for popup window with sample solution.
    for example
    report A--->B--->Chosse Report c or D
    based on parameter hyperlink at report B.
    Thanks in advance
    Raj

    Yes U R correct, that
    I'm using srw.set_hyperlink in plsql format trigger
    to open other reports , now the problem is
    how to carry over the hyperlink parameter to popup window
    and allow user to choose any reports based on the
    parameter value.
    for example
    report A (Sales person summmary report)
    |
    | (choose sales person drilled to orders report B)
    |
    B (report has the hyperlink on order no)
    |
    |
    C,D,E (many reports based on order no
    customer,order details,pending items
    to be shipped)
    Now how to handle the situation from b to c,d,e
    I suggest use hyperlink at B to open popup to show
    reports C,D,E with the order no has parameter.
    please suggest for javascript to open popup window
    for reports c,d,e.
    Thanks
    Raj

  • Multiple Backups with Same Time/Date

    I did a complete backup, reset and restore for my iPad 2 this morning (to ensure maximum performance with IOS 8.1). It worked like a charm, but now I have two seemingly identical backups in iTunes - one with a date in the title and the other without. I have the same situation with my iPhone 5. To make this even more puzzling, I performed the backup and restore using iCloud, but the backups are on my PC. Can anyone explain what is going on? I'd like to remove redundant backups, if possible, but I'm not sure which ones to get rid of (if any).

    there is no way to do this automatically but you can switch designated TM drives periodically in system preferences->Time machine. another idea would be to use a different backup solution for your secondary backup. make a bootable clone on the second drive using CCCloner or Superduper. both of those utilities let you schedule backups automatically. and this way you won't rely on a single backup program, plus you'll get extra benefits of bootable clone backups which TM does not offer. that's what many people (myself included) do.

  • Handling multiple exceptions with a single catch block

    In the following code:
    try{
    catch (NumberFormatException a) {
    catch (UserDefinedException b) {
    The code for both catch blocks are identical. Is there no way I can combine these into one block?
    For example, could I not do:
    catch ( (NumberFormatException a) || (UserDefinedException b) ){
    or anything similar?
    I did think of:
    try{
    try{
    catch (NumberFormatException a) {
    throw new UserDefinedException("");
    catch (UserDefinedException b){
    but this just seems to be a waste of code. Any ideas?

    I would use the fundamental way to combine identical sections of code--put the code in a new method:
        try {
        catch (NumberFormatException a) {
          myExceptionHandlingMethod(a);
        catch (UserDefinedException b) {
          myExceptionHandlingMethod(b);
      private void myExceptionHandlingMethod(Throwable t) {
      }

  • How to handle multiple connection with ssh using JSCH Client?

    Hi,
    Can anybody help me regarding the topic said above?
    Thanks in advance.

    Use this forum to discuss general topics related to the Java programming language.
    I don't even know what JSCH is, let alone would kno whow to provide product support for it.

  • How to compare the date value with the date datatype column?

    Hi,
    I am executed a query to get output for the particular date in two different database.
    I got output in one db environment, but in the another environment i didnt get the output.
    APP_DECISION_DATE column contains date datatype
    ex:
    SQL> select DECISIONED_STAGE_ID,DECISIONED_STAGE_USER_ID from naap10_application where APP_DECISION_DATE = TO_DATE('23-JAN-07',
    'DD-MON-YY'); 2
    DECISIONED_STAGE_ID DECISIONED_STAG
    2006060106 SYSTEM
    DATABASE - II
    SQL> select DECISIONED_STAGE_ID,DECISIONED_STAGE_USER_ID from naap10_application where APP_DECISION_DATE=
    TO_DATE('31-JAN-2007','DD-MON-RRRR') and application_id=2007010028552;
    no rows selected
    in the same db i got the output while i used the TO_DATE(APP_DECISION_DATE)
    SQL> select DECISIONED_STAGE_ID,DECISIONED_STAGE_USER_ID from naap10_application where TO_DATE(APP_DECISION_DATE)=
    TO_DATE('31-JAN-2007','DD-MON-YYYY') and application_id=2007010028552; 2
    DECISIONED_STAGE_ID DECISIONED_STAG
    2006060113 SYSTEM
    is it necessary to use TO_DATE function while i am using the data datatype column in the WHERE CLAUSE?
    Thanks in advance.
    siva

    Sorry & thanks sathish,
    Now i got the result.
    SQL> select DECISIONED_STAGE_ID,DECISIONED_STAGE_USER_ID from naap10_application where APP_DECISION_DATE BETWEEN TO_DATE ('31.01.2007 00:00:00', 'DD.MM.YYYY HH24:MI:SS') AND TO_DATE ('31.01.2007 23:59:59', 'DD.MM.YYYY HH24:MI:SS')
    2 and application_id=2007010028552;
    DECISIONED_STAGE_ID DECISIONED_STAG
    2006060113 SYSTEM
    ================================
    But one doubt,
    When i created the column with the date datatype how it gets the time value,
    And in one environment db i got the result but in another environment i dont get,
    Shall i want to change any session status of date?

  • Multiple rows with single date

    I am using a CDC control task to extract and load data from our OLTP source to our Data Warehouse.
    For our Date dimension, we have a DateKey which is a
    DATETIME stamp (created using SSAS dimension wizard). Time is always 00:00:00 as a DATETIME
    value is required for populating the dates.
    Our fact table destination uses this DateKey as a FK.
    Our fact table OLTP data source contains multiple records with a single DATE and TIME field. This fine as I can convert the DATE field to a DATETIME using a derived column.
    However, as our Date dimension has granularity of a day, all we require for our fact table is the most recent daily record from our OLTP data source.
    At present, the data flow task is attempting to write all records and failing on PK constraint.
    How would I go about traversing all records for each date and loading only the most recent for that day? Is there a better way to go about this?

    If you wish to get only one record for today, you can simply use in your source query:
    SELECT TOP 1 ... FROM OLTPdata ORDER BY DEATETIMEcolumn DESC
    if you need one record for each date, you may use ranking functions:
    WITH Q AS (
    SELECT
    ROW_NUMBER() OVER (PARTITION BY CAST(DateTimeColumn AS DATE) ORDER BY DateTimeColumn DESC, some tie breaker column) AS ROWNUM,
    FROM  OLTPData
    SELECT * FROM Q WHERE ROWNUM=1

Maybe you are looking for

  • HELP! New songs show up on Itunes and Purchased list, but will not show up on phone.

    I've added some new songs to my Purchased list. They show up on iTunes, but do not add after being synced to my iPhone 4s! The sync goes through, but they don't show up on the phone at ALL. I've tried deleting and re-adding to Purchased, but it didn'

  • SRP527W wireless speeds--repeat submission from Dec.

    Bought the 527W in December, haven't been able to get a connection faster than 54Mbps even once.  Andy Hickman saw to it I had access to the 1.01.19 Firmware release which appears to have solved the random 'no connection to my WAN' issue which so man

  • Why does my computer restart every time I plug in my ipod?

    I got my ipod touch a few weeks ago, and for the last two weeks, every time I plug it in, my computer restarts. It continues to restart every time it reaches the XP loading bit (where the bars travel across the screen, I don't know the technical name

  • MAM30_095 Customisation

    We have customised syncbo mam30_095 by adding the Notification/order effects, configured for Plant Maintenance to item 40 (CE_Scenario).  When we test the FMod in R/3, it displayes the configured values selected however, when we synchronise the devic

  • Apple Ipad Air 2 Support in India

    I am planning to buy an Ipad Air 2 with AT&T carrier. I am planning to buy it unlocked. But I will be travelling to India in a couple of months and wanted to understand if the Ipad with support Indian carriers bandwidths Since this Ipad is not yet re