How can i use multiple row subquery in update statement

Hai All
I using group function in my update statement.. and i need to update more rows so i need to use multiple row
subquery pls tell me how to use multiple row subquery in update statement
For example
while i am using this like this i got an error
update dail_att set outtime in (select max(r2.ptime) from temp_att where empcode=r2.enpno and
barcode=r2.cardn and attend_date=r2.pdate group by enpno,pdate,cardn);
Pls tell me how to use with example
Thanks & regards
Srikkanth.M

Hai Man
Thanks for ur response Let me clear what i need
First step Fetch the records as text file and stores into table T1
and the next step is i have seperated the text using substring and stores in different columns of a table
There are two shifts 0815 to 1645 and 1200 and 2000
Here I rep IN and O rep OUT
Empno date time inout
001 01-01-10 0815 I
002 01-01-10 0815 I
003 01-01-10 0818 I
001 01-01-10 1100 0
001 01-01-10 1130 I
002 01-01-10 1145 0
002 01-01-10 1215 I
004 01-01-10 1200 I
005 01-01-10 1215 I
004 01-01-10 1315 O
004 01-01-10 1345 I
001 01-01-10 1645 0
002 01-01-10 1715 0
003 01-01-10 1718 0
004 01-01-10 2010 0
005 01-01-10 2015 0
This is my T1 table i have taken data from text file and stored in this table from this table i need to move data to another table T2
T2 contains like this
Empno Intime Intrin Introut Outtime Date
001 0815 1100 1130 1645 01-01-10
002 0815 1145 1215 1715 01-01-10
003 0818 1718 01-01-10
004 1200 1315 1345 2010 01-01-10
005 1215 2015 01-01-10
This what i am trying to do man but i have little bit problems Pls give some solution with good example
And my coding is
declare
     emp_code varchar2(25);
in_time varchar2(25);
out_time varchar2(25);
Cursor P1 is
Select REASON,ECODE,READMODE,EMPD,ENPNO,FILL,PDATE,PTIME,INOUT,CARDN,READERN
From temp_att
group by REASON,ECODE,READMODE,EMPD,ENPNO,FILL,PDATE,PTIME,INOUT,CARDN,READERN
ORDER BY enpno,pdate,ptime;
begin
     for r2 in p1 loop
declare
bar_code varchar2(25);
begin
select barcode into bar_code from dail_att where empcode=r2.enpno and attend_date=r2.pdate;
For r3 in (select empcode,empname,barcode,intime,intrin,introut,addin,addout,outtime,attend_date from dail_att)loop
if r2.inout ='O' then
update dail_att set outtime =(select max(r2.ptime) from temp_att where empcode=r2.enpno and barcode=r2.cardn and attend_date=r2.pdate group by r2.cardn,r2.enpno,r2.pdate );
end if;
end loop;     
exception
     when no_data_found then
     if r2.inout ='I' then
               insert into dail_att(barcode,empcode,intime,attend_date)(select r2.cardn,r2.enpno,min(r2.ptime),r2.pdate from temp_att group by r2.cardn,r2.enpno,r2.pdate );
     end if;
end;
end loop;
commit;     
     end;
Pls tell me what correction i need to do i the update statement i have used a subquery with group function but when i used it will return only one row but my need is to return many rows and i need to use multiple row subquery
and how can i use it in the update statement
Thanks In Advance
Srikkanth.M

Similar Messages

  • How can I use multiple row insert or update into DB in JSP?

    Hi all,
    pls help for my question.
    "How can I use multiple rows insert or update into DB in JSP?"
    I mean I will insert or update the multiple records like grid component. All the data I enter will go into the DB.
    With thanks,

    That isn't true. Different SQL databases have
    different capabilities and use different syntax, That's true - every database has its own quirks and extensions. No disagreement there. But they all follow ANSI SQL for CRUD operations. Since the OP said they wanted to do INSERTs and UPDATEs in batches, I assumed that ANSI SQL was sufficient.
    I'd argue that it's best to use ANSI SQL as much as possible, especially if you want your JDBC code to be portable between databases.
    and there are also a lot of different ways of talking to
    SQL databases that are possible in JSP, from using
    plain old java.sql.* in scriptlets to using the
    jstlsql taglib. I've done maintenance on both, and
    they are as different as night and day.Right, because you don't maintain JSP and Java classes the same way. No news there. Both java.sql and JSTL sql taglib are both based on SQL and JDBC. Same difference, except that one uses tags and the other doesn't. Both are Java JDBC code in the end.
    Well, sure. As long as you only want to update rows
    with the same value in column 2. I had the impression
    he wanted to update a whole table. If he only meant
    update all rows with the same value in a given column
    with the same value, that's trivial. All updates do
    that. But as far as I know there's know way to update
    more than one row where the values are different.I used this as an example to demonstrate that it's possible to UPDATE more than one row at a time. If I have 1,000 rows, and each one is a separate UPDATE statement that's unique from all the others, I guess I'd have to write 1,000 UPDATE statements. It's possible to have them all either succeed or fail as a single unit of work. I'm pointing out transaction, because they weren't coming up in the discussion.
    Unless you're using MySQL, for instance. I only have
    experience with MySQL and M$ SQL Server, so I don't
    know what PostgreSQL, Oracle, Sybase, DB2 and all the
    rest are capable of, but I know for sure that MySQL
    can insert multiple rows while SQL Server can't (or at
    least I've never seen the syntax for doing it if it
    does).Right, but this syntax seems to be specific to MySQL The moment you use it, you're locked into MySQL. There are other ways to accomplish the same thing with ANSI SQL.
    Don't assume that all SQL databases are the same.
    They're not, and it can really screw you up badly if
    you assume you can deploy a project you've developed
    with one database in an environment where you have to
    use a different one. Even different versions of the
    same database can have huge differences. I recommend
    you get a copy of the O'Reilly book, SQL in a
    Nutshell. It covers the most common DBMSes and does a
    good job of pointing out the differences.Yes, I understand that.
    It's funny that you're telling me not to assume that all SQL databases are the same. You're the one who's proposing that the OP use a MySQL-specific extension.
    I haven't looked at the MySQL docs to find out how the syntax you're suggesting works. What if one value set INSERT succeeds and the next one fails? Does MySQL roll back the successful INSERT? Is the unit of work under the JDBC driver's control with autoCommit?
    The OP is free to follow your suggestion. I'm pointing out that there are transactions for units of work and ANSI SQL ways to accomplish the same thing.

  • How Can I Use Multiple Weblogic Instances in a Single OS

    Hello Everyone,
    Actually I have to install Some different applications. Few of them need weblogic 10.3.6 and others need 10.3.4. The OS am using is Oracle  Enterprise Linux 5.
    Now I am able to install 2 separate(One of 10.3.4 and 10.3.6) instances with two different users,In two different directories.
    I have installed the weblogic 10.3.6 version with a user webadmin and installed node manager with port 5556. This is working fine.
    The main problem here is :
    In the second instance (10.3.4 ) installed with a a different user and gave the port number to NodeManager as 1600 and its not getting started. Its throwing error and also after some errors in the terminal am able to see that its reverting to port number 5556 only.
    What might be the issue?
    I have to install 2 different versions of weblogic in a single Server. But am failing with NodeManager. What Can I do to have multiple weblogic instances with multiple versions in a single server ?
    Can anyone suggest a resolution for this please ?
    Thanks in advance.

    Pl do not spam these forums with multiple posts - How Can I Use Multiple Weblogic Instances in a Single OS

  • How can we use multiple transactions by using bdc_insert.

    HI
    How can we use multiple transactions by using bdc_insert.

    Hi,
    In between the Open and Close we have to use the BDC_INSERT for the Tcodes you have to do.
    BDC_OPEN_GROUP
    BSD_INSERT
    TCODE = tcode1
    BDC_INSERT
    TCODE = tcode 2
    BDC_CLOSE_GROUP
    check the SDN for more on this.
    Regards
    Lekha

  • TA23485 How can I use multiple identities in Mail?

    To be specific: How can I use one email address and different names? I used to do this with Eudora.

    MrHoffman: thank you for the answer. You answered to the question: many email addresses and different names, it seems. Please read my question once again and let me know if you have a solution.

  • How can I use multiple icloud Accounts with Fotos?

    Hello.
    Yesterday, my wife and I started using the new App "Fotos" on OSX and iOS.
    What I can't figure out, and where I would like to get some insight and help, is how we should use our icloud Accounts.
    How it is right now:
    - Wife (MacBook and iPhone)
    Has her own icloud-Account ([email protected]) for Backup (iOS) and Fotosync, Keychainsync, Bookmarks. 20GB iCloud-Account (18GB free).
    - Husband (MacBook, Mac Mini and iPhone and iPad)
    Has his own icloud-Account ([email protected]) for Backup (iOS) and Fotosync, Keychainsync, Bookmarks. 20GB iCloud Account (10 GB free).
    - Husband has about 400 GB of Photos from over 10 Years on Mac Mini
    How I want it to be:
    - Husband
    upgrades to at least the 500GB Account, to use for all 400GB of Photos and Backup, Keychainsync, Bookmarks.
    - Wife
    Has her own Account ([email protected]) for Keychain and Bookmark, but uses [email protected] on MacBook and iPhone for Backup an Fotosync, so that all Photos are stored in a single one family "container". All Photos in one Place without being able to forget to put them there.
    I don't see, how I can accomplish that, since only one "real" icloud account seems to be possible in iOS, so that if i put my account in her iPhone I would get the Photo and Backup I want, but she would not be able to sync her own bookmarks an keychain any more.
    Any thought on how to resolve this?
    Am I missing something?
    Thanks for your ideas,
    thomas

    Yes, you could have multiple iCloud accounts for Mail, Contacts, Calendars, Reminders, Safari, Notes, and Find My iPhone, but only one primary iCloud account for Photo Stream, Documents & Data, and Storage & Backup.

  • How can I have multiple rows of bookmarks in the bookmark toolbar? I can't find any way to do this in 4.0. If I had know this wasn't possible in the new version, I would not have downloaded it.

    I have many bookmarks that I like to have readily available on the toolbar. With the older versions of Firefox, I was able to have multiple rows of icons that I grouped by topic. I have now wasted a lot of time trying to find a way to have multiple rows in version 4.0. I do not want to use the down arrow on the right.

    This can be done by adding a userstyle with the Stylish add-on.
    # First install the Stylish add-on - https://addons.mozilla.org/en-US/firefox/addon/stylish
    # Go to http://userstyles.org/styles/29428 and click on "Install with Stylish"
    # Restart Firefox and you should then have a multi-row bookmarks toolbar.

  • With Pages 5.2 how can i use multiple language types in a single document

    My Macbook Air Has the version 10.9.3
    I'm used to work with the old version of Page.
    But now I am using the new version of Pages 5.2 (1860).
    I want to know with the new version how do I use an multiple language types in a single document option.
    In the old  version of Pages I was using  Inspector -> Text -> "More" tab -> Language: British Inglese.
    In the new Pages 5.2 I do not know how to do it
    Could you help me?
    melo

    It's not possible to tag text with multiple languages in Pages 5.  Go back to Pages 4, which should still be in you iWork folder.
    For the whole doc in Pages 5, use Edit > Spellling and Grammar > Show Spelling and Grammar.

  • How can I use multiple constructor

    Hi,
    I have some problem to using multiple constructor in java. It shows some error while compiling the following program. can any one give better solution for me.......
    public class Test6{
       public Test6(){
    this(4);    /*
    C:\Test6.java:5: cannot find symbol
    symbol  : constructor Test6(int)
    location: class Test6
    this(4);
      Test6(byte var){
    System.out.println(var);
    public static void main(String[] args){
    Test6 t6 = new Test6();
    }

    A number like 4 is an integer literal. So, you are passing an int to a function that is defined to accept a byte, hence you have a type mismatch. You need to cast the integer literal to a byte before passing it to the function:
    this( (byte) 4);

  • How can I use multiple iTunes accounts on one phone?

    I Have an iTunes account with iTunes match enabled. I've just moved in with my gf and want to be able to share music on our phones. I've enabled her computer and put my Apple ID in and I now have all her music on my phone (thanks to iTunes match) but when I try and **** her phone it ignores all my music. How can I get all my music on her phone? The only way I have managed it is to sign out of her account on the phone and sign in with my ID but that would mean all her purchases would be charged to me etc so this isn't a solution really

    Put everything on the computer to which she syncs, and sync them to her iPhone.

  • How can i use multiple languages ?

    I want to add language options on my web page.
    I duplicate a page, wanting to translate it.
    On the menu bar, the name of the new page appears.
    How can I make it unvisible ?

    This iWebFAQ.org page may be of interest to you....
    http://iwebfaq.org/site/iWeb_Multilingual_sites.html

  • How can I use multiple front panel controls to be mirrors of each other?

    Hi All:
        I know this is going to be a strange question, but I have multiple inputs that control one output.  This in itself not necessarily difficult, but I have a strange need.  If one of the control inputs change I would like this to be indicated by the other controls.  For example, I have a slider, numeric and dial controls on the front panel that control RPM.  If the slider changes to 1000 RPM I would like the numeric and dial controls to see that change.  Is this possible.  If so, can you give me advice on doing this.  I am using 7.1.  Thanks for the help.
    John Honnold

    What you want is not that hard, but asked for a rather  limited times.
    Here's a how to:
    Drop a slider
    Right click Visible items-> Digital display
    Right click on the slider Advanced-> Customize
    Right click on the Digital display Replace select the control you want to replace it with (a gauge for instance)
    Right click on the Gauge Visible items -> Digital Display
    Now you have one control with three control options:
    This was done in 8.2 but I think the same goes for 7.1
    Ton
    Message Edited by TonP on 04-06-2009 09:52 AM
    Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
    Nederlandse LabVIEW user groep www.lvug.nl
    My LabVIEW Ideas
    LabVIEW, programming like it should be!
    Attachments:
    Example_VI.png ‏7 KB

  • 10GR2 - How can I load multiple row values into one field?

    Hi
    Can anyone please help with a problem I'm having with merging data.
    The source table has multiple entries for the same Id e,g,
    ID Code
    1 123
    1 234
    2 123
    2 567
    The output should only have one row per ID e.g.
    ID Code_List
    1 123;234
    2 123;567
    Do you know what operator I could use that would allow me to do this? I've looked at unpivot but I think I would need multiple output fields (one for each Code). I have to concatinate the codes and separate with a semi-colon.
    Thanks
    GB

    Q) Input data
    =============
    COL_0,COL_4
    1235,"G0123,G124,G25,G6"
    1236,"G01,G23,G124,G25,G6"
    1237,"G0123,G1,G24,G25,G6"
    1238,"G,G0123,G124,G25,G6"
    1239,"G0123124,G256"
    Output
    ======
    TEST_ID,TEST_VAL
    1235,G0123
    1235,G124
    1235,G25
    1235,G6
    1236,G01
    1236,G23
    1236,G124
    1236,G25
    1236,G6
    1237,G0123
    1237,G1
    1237,G24
    1237,G25
    1237,G6
    1238,G
    1238,G0123
    1238,G124
    1238,G25
    1238,G6
    1239,G0123124
    1239,G256
    I wrote this procedure...
    declare
    rcd_cnt number;
    test_id123 number;
    junk_1 number;
    cd_occurences number;
    child_count number;
    str_abc varchar2(200);
    char_pos     number default 0;
    cd_temp_str varchar2(50);--:= 'G0123,G124,G25,G6';
    begin
    select nvl(count(col_4),0) into rcd_cnt from test_ee where col_4 is not null;
    for aa in 1 .. rcd_cnt loop
    select col_0,rownum rn,nvl(trim(col_4),0) into test_id123,junk_1,cd_temp_str from (select col_0,rownum rn,col_4 from test_ee where col_4 is not null) where rn = aa;
    --dbms_output.put_line('...I am in for loop...' || cd_temp_str);
         --dbms_output.put_line('===================' || rcd_cnt || '.................' ||aa);
    cd_occurences := length(cd_temp_str) - length(replace(cd_temp_str,','));
    dbms_output.put_line(cd_temp_str || '...Str Occurences are ...'||cd_occurences ||'**************'||test_id123);
    child_count :=0;
    for z in 1..length(cd_temp_str)+1 loop
    child_count := child_count+1;
         if(instr(cd_temp_str,',') > 0) then
         char_pos := instr(cd_temp_str,',',1,1);
              str_abc := substr(cd_temp_str,1,char_pos-1);
         dbms_output.put_line('..Partial String of..'|| z ||'..is.....' || str_abc);
              insert into test_xx(test_id,test_val) values(test_id123,str_abc);
         end if;
         cd_temp_str := substr(cd_temp_str,char_pos+1,length(cd_temp_str));
         if(cd_occurences=child_count) then
         dbms_output.put_line('..Partial String of..is.....' || cd_temp_str);
              insert into test_xx(test_id,test_val) values(test_id123,cd_temp_str);
         end if;     
    end loop; -- close for of z */
    --dbms_output.put_line('...I am in end for loop...');
         end loop; -- close for of aa
    end;
    instead of procedure,is there any way from sqlqery.

  • How can I use multiple ipad's on one account without sharing individuals personal email accounts?

    Is it possible to have multiple ipads on one account and share info, but also allow the individual users to have personal email that is not seen on the other ipad's? We have all ipads on same icloud account because we all need to see the same ical. It seems like that's the problem. If it IS related to icloud then if we have separate icloud accounts, how would we share the main ical otherwise? Sharing the ical is very important for this business so everyone can access the daily schedule. Of course each user still wants to have private email.
    Hope this wasn't too confusing!
    Thanks!
    Doreen

    you could set up the main icloud itunes acount for ical and not have in setup on the devices
    and share the calandar with the other itunes accounts on the devices
    or only have it on one device
    devices have the users indervidual itunes icloud setup
    they should be able to access the shared "main" itunes icloud ical account once it's shared
    http://howto.cnet.com/8301-11310_39-57542557-285/three-methods-for-sharing-an-ic loud-calendar/
    if the devices are company owned you could go futher and setup find my iphone on the main itunes account
    and not on the user icloud accounts

  • How can I use multiple client side vlans in ACE?

    In CSM we have a default-gateway per Client VLAN, in ACE there is no equivalent command! How does the ACE handles routing in this situation?

    Hi,
    Talk about a deja-vu. I was faced with the exact same challenge about a year ago.
    Basically, I think you're looking at two options:
    1) Firewall-consolidation - Consolidate your four firewalls into one, having one dedicated interface towards the ace and route all your vips using the ace as
        next-hop. It looks like your firewalls are virtual (but I don't know), so it's duable. But I don't know if this is even an option for you.
    2) Per. clientvlan context - Context A for vlan1001, Context B for vlan1002 and so on. Each context handles clienttraffic for the respective vlan and since
        each context handles it's own routingtable, simply use the firewall-address as your default route. But from your drawing, it looks like your server-vlans
        are all connected to the same ace, so you will need to split that up. Assign each servervlan to an ace-context as you do with the clientside-vlans.
    Well, a third option would be NAT in your firewall. Unless you have a specific need for the original client-ip the reach the ace, you could nat incoming clientsessions in each of the firewalls to an interface-address on that firewall, hence the ace will see the clientrequest as originating from the firewall and since ace has connected routes to each of the firewall, it wall return traffic to respective firewall and leave it to him to return the traffic to the client.
    Since each firewall will present the packets with a unique NAT'ed address, you can apply different policies, parameters etc. for that NAT-address, if this is required.
    hth
    /Ulrich

Maybe you are looking for