How could you auto-increment a number in a select

i have some select sentences that i think i could do in one line:
UPDATE RECIBO SET RECARGO = (SELECT FLOOR((SELECT MONTHS_BETWEEN (SYSDATE , (SELECT F_EMISION FROM RECIBO WHERE N_RECIBO = 0001)) / 12 FROM DUAL)) FROM DUAL) WHERE N_RECIBO = 0001 AND F_PAGADO IS NULL;
UPDATE RECIBO SET RECARGO = (SELECT FLOOR((SELECT MONTHS_BETWEEN (SYSDATE , (SELECT F_EMISION FROM RECIBO WHERE N_RECIBO = 0002)) / 12 FROM DUAL)) FROM DUAL) WHERE N_RECIBO = 0002 AND F_PAGADO IS NULL;
UPDATE RECIBO SET RECARGO = (SELECT FLOOR((SELECT MONTHS_BETWEEN (SYSDATE , (SELECT F_EMISION FROM RECIBO WHERE N_RECIBO = 0003)) / 12 FROM DUAL)) FROM DUAL) WHERE N_RECIBO = 0003 AND F_PAGADO IS NULL;
UPDATE RECIBO SET RECARGO = (SELECT FLOOR((SELECT MONTHS_BETWEEN (SYSDATE , (SELECT F_EMISION FROM RECIBO WHERE N_RECIBO = 0004)) / 12 FROM DUAL)) FROM DUAL) WHERE N_RECIBO = 0004 AND F_PAGADO IS NULL;
UPDATE RECIBO SET RECARGO = (SELECT FLOOR((SELECT MONTHS_BETWEEN (SYSDATE , (SELECT F_EMISION FROM RECIBO WHERE N_RECIBO = 0005)) / 12 FROM DUAL)) FROM DUAL) WHERE N_RECIBO = 0005 AND F_PAGADO IS NULL;
UPDATE RECIBO SET RECARGO = (SELECT FLOOR((SELECT MONTHS_BETWEEN (SYSDATE , (SELECT F_EMISION FROM RECIBO WHERE N_RECIBO = 0006)) / 12 FROM DUAL)) FROM DUAL) WHERE N_RECIBO = 0006 AND F_PAGADO IS NULL;
UPDATE RECIBO SET RECARGO = (SELECT FLOOR((SELECT MONTHS_BETWEEN (SYSDATE , (SELECT F_EMISION FROM RECIBO WHERE N_RECIBO = 0007)) / 12 FROM DUAL)) FROM DUAL) WHERE N_RECIBO = 0007 AND F_PAGADO IS NULL;
UPDATE RECIBO SET RECARGO = (SELECT FLOOR((SELECT MONTHS_BETWEEN (SYSDATE , (SELECT F_EMISION FROM RECIBO WHERE N_RECIBO = 0008)) / 12 FROM DUAL)) FROM DUAL) WHERE N_RECIBO = 0008 AND F_PAGADO IS NULL;
UPDATE RECIBO SET RECARGO = (SELECT FLOOR((SELECT MONTHS_BETWEEN (SYSDATE , (SELECT F_EMISION FROM RECIBO WHERE N_RECIBO = 0009)) / 12 FROM DUAL)) FROM DUAL) WHERE N_RECIBO = 0009 AND F_PAGADO IS NULL;
UPDATE RECIBO SET RECARGO = (SELECT FLOOR((SELECT MONTHS_BETWEEN (SYSDATE , (SELECT F_EMISION FROM RECIBO WHERE N_RECIBO = 0010)) / 12 FROM DUAL)) FROM DUAL) WHERE N_RECIBO = 0010 AND F_PAGADO IS NULL;
note that only the number changes. i would need it to go through EVERY row from table "RECIBO". please, some idea? thanks!
Edited by: user13475720 on 01-mar-2011 3:17

hi there
create s sequence
CREATE SEQUENCE scott.SEQ
  START WITH 1
  MAXVALUE 99
  MINVALUE 1
  NOCYCLE
  NOCACHE
  NOORDER;then put seq.nextval
in ur query
UPDATE RECIBO SET RECARGO = (SELECT FLOOR((SELECT MONTHS_BETWEEN (SYSDATE , (SELECT F_EMISION FROM RECIBO WHERE N_RECIBO = SEQ.NEXTVAL)) / 12 FROM DUAL)) FROM DUAL) WHERE N_RECIBO =  SEQ.NEXTVAL AND F_PAGADO IS NULL;Regards
Hitesh

Similar Messages

  • How to auto increment a NUMBER(10) datatype

    Anyone know the syntax on how to auto increment a number field every time a new row comes in?
    TIA
    CREATE TABLE loc_color_group_values(
         ID number(10) NOT NULL auto_increment, <----------------
         COLOR_CODE_ID number(10) default 0,
         PROD_LOC_ID number(10) default 0,
         COLOR_GROUP_CODE_ID number(10) default 0,
         PRIMARY KEY(ID)
    );

    Here is an example:
    CREATE OR REPLACE TRIGGER "EXAMPLE_TRIG" BEFORE
    INSERT ON "loc_color_group_values" FOR EACH ROW BEGIN
      IF :NEW.id IS NULL THEN
        SELECT loc_color_group_values_seq.nextval INTO :NEW.id FROM dual ;
      END IF;
    END ;This allows you to overide the sequence without having to disable the trigger.

  • How to use auto-increment and search option for MS Access DB

    Dear All,
               I have configured our invoice in Adobe Livecycle and connected it to MS Acess 2007 as per http://forms.stefcameron.com/2006/09/18/connecting-a-form-to-a-database/.
    All is working fine, I can insert, retrieve data from DB to invoice and vice versa.
    Now I want few things to be implemented on our invoice.
    When ever I open our invoice, it populate the first entry from DB, Is it possible to populate the last entry ?
    Auto increment invoice number from MS Access DB every time we open our invoice after save.
    How to implement search option from DB for invoice number ?
    Please let me know if someone can provide me help on my scenario, so that I can share more stuff related to invoice and DB.
    Look forward to hearing soon from experts and other team members.
    Thanks & Regards
    Riyad...

    As far as I know there is not any auto increment data type in Oracle. Instead of this you should create a sequence and get the next value of the sequence while creating a row in your table.
    CREATE SEQUENCE Test_Sequence ;
    CREATE TABLE Test_Table ( Id NUMBER , Foo VARCHAR2(4) ) ;
    ALTER TABLE Test_Table ADD CONSTRAINT Test_Table_PK_Id PRIMARY KEY ( Id ) ;
    INSERT INTO Test_Table ( Id , Information ) VALUES ( Test_Sequence.NEXTVAL , 'FOO' ) ;

  • How to generate an incrementing batch-number per set number of rows

    Hi,
    How could you generate an incrementing batch-number per set number of rows for a table in SQL?
    The returned result set of the SQL query should show a preceding batch number per row set and incremented by 1 for the next row set.
    Eg, you want to start the batch_number by 1 for the first three returned rows of the table and than increment by 1 for the next three rows.
    The result set would look like:
    BATCH_NO, TAB_COL1, TAB_COL2, TAB_COL3, TAB_COL4, ..
    1, ...
    1, ...
    1, ...
    2, ...
    2, ...
    2, ...
    3, ...
    3, ...
    3, ...
    etc.
    Cheers.

    Many thanks guys, I would have never thought about these options.. Yes the reason for adding the preceding batch number has to do with migrating data from a source table where we only can grab small sets of rows at the time to bring across to a target table.
    Cheers.

  • How could I change my telephone number from iMessage ?

    How could I change my telephone number from iMessage ? I've try in my Apple ID and doesn't work.

    Hi,
    On your iPhone Add the Apple ID
    On the Mac then Accept the pop up(s) that appear saying the iPhone is using the ID and iPhone number.
    Untick the old number in the list for Receive At and Start Conversation From drop down if it is the listed item.
    For complete removal you have to delete a .plist or two.
    Open a Finder window
    Use the Go Menu whilst holding down the ALT key
    Select the Library that appears.
    Navigate to the Preferences
    Find com.apple.imservice.imessages.plist and com.apple.imessage.bag.plist and drag them to the Trash.
    Restart the app on the Mac.
    It will ask for the Apple ID.
    It should get the pop ups about the iOS device.
    10:23 pm      Wednesday; November 13, 2013
      iMac 2.5Ghz 5i 2011 (Mavericks 10.9)
     G4/1GhzDual MDD (Leopard 10.5.8)
     MacBookPro 2Gb (Snow Leopard 10.6.8)
     Mac OS X (10.6.8),
     Couple of iPhones and an iPad

  • How do you remove a badge number from the app store without downloading...

    HOw do you remove the badge number icon for a program that you do not want to update from the app store.
    I have an app that is updated but i don't want the update (new ugly artwork and I am content with what the present artwork and app does)...I don't want the update. How do I remove/refuse the update and remove the number badge?
    Thanks!

    so you have an app on your phone that you do not want to update?
    But you want to get rid of that annoying badge from the appstore?
    There is a fix for this!
    Created by Elit3!
    if you post this anywhere else please acknowledge my find! thank you.
    new directions:
    1. go to itunes
    2. click applications
    3. right click on the application you want to use
    4. press show in windows explorer
    5. Copy the ipa to desktop
    6. right click and press open with
    7. open file with winrar, winzip, what ever, something so you can see all the files
    8. open iTunesMetadata.plist with PLIST EDITOR
    9. search for "itemId"
    10. Delete the number under "itemId" in between </integer>
    11. leave One number remaining. (any number)
    12. save.
    13. double click your new ipa
    14. sync
    15. No more update badge
    DONE.
    remember to backup everything you change. just in case.

  • How do you auto tone a group of photos. I selected them all and tried to auto tone but it keeps doing only one

    How do you auto tone a group of photos. I tried command a to select all and then auto tone but it only did one Photo. I troes several times and yes all photos were selected

    In Develop you can highlight a group of thumbnails in the filmstrip, then right-click and choose Develop Settings -> Auto Tone
    In Library you can highlight a group of thumbnails in the Grid and click the Auto Tone button in the Quick Develop area.
    What you can’t do is click the Auto button in Develop and have it do more than one photo—this is by design, except, maybe if you have Auto Sync enabled.

  • How do you change the phone number on an ipad mini in the imessage settings?

    How do you change the phone number on an ipad mini in the imessage settings?

    The Phone number of a Cellular iPad is assigned by the carrier the iPad is connected to.  Usually changing the sim card will change this number.
    If that is not what you mean can you please explain in more detail

  • How could you map the Records of OM- PA

    Hello Experts,
    How could you map the Records of OM->PA ,if the designation of person changes from manager to supervisor from certain date.and how can we see the changed records??
    Solution :we can see the changes in the addition action infotype 302,personel hiring action(0000) delimit the record whenerver we changes the designation,and in the orgassingment infotype overview ,action infotype over view we can see the changes and PLOGI-ORGA IS the integration switch and position is the key for map the recoed from OM ->PA
    Post your comments if the solution is correct???
    Regards
    Chandra

    Thanks  a Lot!!!!
    Regards
    Chandra

  • HT4061 How do you change your phone number than is in your iPad and replace it with right one to receive and send messages?

    How do you change your phone number in your iPad messages and replace it with another number. In order to send and receive messages to the correct phone number?

    It's best to use an email address on the iPad.
    Using FaceTime http://support.apple.com/kb/ht4319
    Troubleshooting FaceTime http://support.apple.com/kb/TS3367
    The Complete Guide to FaceTime + iMessage: Setup, Use, and Troubleshooting
    http://tinyurl.com/a7odey8
    Troubleshooting FaceTime and iMessage activation
    http://support.apple.com/kb/TS4268
    iOS: FaceTime is 'Unable to verify email because it is in use'
    http://support.apple.com/kb/TS3510
    Using FaceTime and iMessage behind a firewall
    http://support.apple.com/kb/HT4245
    iOS: About Messages
    http://support.apple.com/kb/HT3529
    Set up iMessage
    http://www.apple.com/ca/ios/messages/
    iOS 6 and OS X Mountain Lion: Link your phone number and Apple ID for use with FaceTime and iMessage
    http://support.apple.com/kb/HT5538
    How to Set Up & Use iMessage on iPhone, iPad, & iPod touch with iOS
    http://osxdaily.com/2011/10/18/set-up-imessage-on-iphone-ipad-ipod-touch-with-io s-5/
    Troubleshooting Messages
    http://support.apple.com/kb/TS2755
    Troubleshooting iMessage Issues: Some Useful Tips You Should Try
    http://www.igeeksblog.com/troubleshooting-imessage-issues/
    Setting Up Multiple iOS Devices for iMessage and Facetime
    http://macmost.com/setting-up-multiple-ios-devices-for-messages-and-facetime.htm l
    FaceTime and iMessage not accepting Apple ID password
    http://www.ilounge.com/index.php/articles/comments/facetime-and-imessage-not-acc epting-apple-id-password/
    FaceTime, Game Center, Messages: Troubleshooting sign in issues
    http://support.apple.com/kb/TS3970
    Unable to use FaceTime and iMessage with my apple ID
    https://discussions.apple.com/thread/4649373?tstart=90
    How to Block Someone on FaceTime
    http://www.ehow.com/how_10033185_block-someone-facetime.html
    My Facetime Doesn't Ring
    https://discussions.apple.com/message/19087457
    Send an iMessage as a Text Message Instead with a Quick Tap & Hold
    http://osxdaily.com/2012/11/18/send-imessage-as-text-message/
    To send messages to non-Apple devices, check out the TextFree app https://itunes.apple.com/us/app/text-free-textfree-sms-real/id399355755?mt=8
    How to Send SMS from iPad
    http://www.iskysoft.com/apple-ipad/send-sms-from-ipad.html
    You can check the status of the FaceTime/iMessage servers at this link.
    http://www.apple.com/support/systemstatus/
     Cheers, Tom

  • How do you auto reconnect a live video stream broadcast in flash action script 3?

    how do you auto reconnect a live video stream broadcast in flash action script 3?
    so i don't have to ask people to refresh the page if the connection drops
    i copy pasted the live video stream broadcast files and script from here;
    http://www.adobe.com/devnet/adobe-media-server/articles/beginner_live_fms3.html
    http://www.adobe.com/content/dotcom/en/devnet/adobe-media-
    server/articles/beginner_live_fms3/_jcr_content/articlePrerequistes/multiplefiles
    /node_1278314297096/file.res/beginner_live_fms3.zip
    i don't know what i'm doing

    Why don't you use several layers with appropriate alpha properties, and move these layers according to the mouse events?

  • HT204053 I don't want to receive any SMS from Apple. Could you remove my cell number from your list.

    I don't want to receive any SMS from Apple. Could you remove my cell number from your list?

    It's been suggested that somehow you may have emails being routed to your SMS, which is passing marketing emails from Apple to your text messaging. Go here:
    http://mynews.apple.com/ca/subscribe
    and unsubscribe and see if the SMS messages then stop. You can also check your Apple ID:
    https://appleid.apple.com/cgi-bin/WebObjects/MyAppleId.woa/
    and make the change there if you are subscribed.
    Regards.

  • CS6 has two options when installing, try or enter serial number. How do you buy a serial number?

    CS6 has two options when installing, try or enter serial number.
    How do you buy a serial number?
    I would like to keep it going a little longer after the beta expires and convert it to a full retail version.
    thanks

    We are thrilled that you like the CS6 beta and are ready to buy. Unfortunately it has not been released yet. If you would like to be notified when it is available, go to this link and enter your information:
    Pattie
    Sign up to be notified when Photoshop CS6 is available for purchase

  • How could you create 'Last Time Contacted' Smart Mailbox in Mail app Lion?

    Hello!
    For the purposes of maintaining regular contact with a large group of contacts in your address book:
    How could you create a smart mailbox in the Mail App (Lion) which contained that last unique sent/received email from each individual contact?
    So ideally just the last email per contact. For my purposes I would then sort by date and find the contacts I havent emailed in a while and re-initiate conversation.
    I also thought that perhaps it would be possible through Automator? (I am not very familiar with how to use this app)
    Any ideas/solutions would be very appreciated!
    nmarks
    (running lion 10.7.4 macbook pro late 2011)

    Okay, I think I just discoverd a workaround. This will work if you're lucky enough to already have a smart-mailbox folder that persists after close. (Somehow I had two such folders that already existed and weren't subject to the mysterious disappearances on closing the app; perhaps I created them in a previous OS X release?) Anyway, here goes:
    Locate an already existing smart mailbox folder that's working properly. Select the folder (in the sidebar).
    Duplicate that folder using the "Duplicate Smart Mailbox" Command. (It's on the contextual pop-up menu or available via the gear icon in the lower left of the window). This should produce and exact copy of the folder and the boxes inside, appearing at the bottom of the smart mailbox list.
    Edit the duplicate folder to put the smart mailboxes you want in it, and delete the previous mailboxes (duplicates) that you don't want.
    The new folder structure should now persist between launches of the app.
    There you go. Not the most elegant process, but workable. Don't know if there's a method if you don't have at least one smart mailbox folder already though.

  • How do you find your phone number?

    How do you find your phone number?

    You can't.  The iPod tuch does not have a phone number.  For the Messages and FaceTime apps you use the email address that yu set them up with.  With some oher texting apps like Text+, the apps assign you a phone number.

Maybe you are looking for