Date and Sequence number

I need some help coming up with some SQL that I can put in an Insert Trigger to generate a unique id. The unique ID is composed of the two digit year, the two digit month, and a four digit sequence number. At the beginning of each month, the sequence part of the number should be reset to 0001.
An example of the data follows:
02110001
02110002
02110003
02120001
02120002
02120003
Thanks in advance for any help/advice.

Creating the unique key is relatively straight forward.
CREATE SEQUENCE monthly
START WITH 1 INCREMENT BY 1 NOCACHE;
CREATE TRIGGER my_trigger
BEFORE INSERT ON my_table
FOR EACH ROW
BEGIN
   :new.unique_id := TO_CHAR(sysdate,'yymm')||TO_CHAR(monthly.nextval,'fm0000');
END;Depending on your version of Oracle, you may need to select it into a variable from dual before assigning to :new.unique_id. To reset the sequence at the beginning of the month, you could use DBMS_JOB, or cron to run a procedure that drop and re-create the sequence at midnight.
John

Similar Messages

  • Load field in sqlldr with a sysdate and sequence number

    Hi
    LOAD DATA
    INFILE 'C:\testsequence.dat' "STR '\r\n'"
    REPLACE
    INTO TABLE testsequence
    FIELDS TERMINATED BY "" OPTIONALLY ENCLOSED BY '"'
    TRAILING NULLCOLS
    SEQ EXPRESSION "to_char(sysdate,'YYYYMMDDHH24MISS')" ,
    DATA CHAR
    I want to concatenate a sequence number with SEQ example:
    20100216054415 + 500 from lets say sequence(500,1)
    How can I concatenate
    "to_char(sysdate,'YYYYMMDDHH24MISS')" and sequence(500,1)
    Your help is appreciated!!
    Mike

    Mike,
    Take at look at this example...
    ------  =====SQLPLUS=========
    sql>  create table t(
      2   id number,
      3   test_string varchar2(50));
    Table created.
    ---sequence starting with 50 increment by 1
    sql> create sequence test_seq
      2      start with 50
      3      increment by 1
      4  /
    Sequence created.
    =====SQL Loader control file....
    LOAD DATA
    INFILE *
    REPLACE
    INTO TABLE T
    FIELDS TERMINATED BY ','
    TRAILING NULLCOLS
    id,
    test_string "to_char(sysdate,'YYYYMMDDHH24MISS') || test_seq.nextval"
    BEGINDATA
    100
    -- load it using...
    sqlldr uid/pwd@dbinstance control=test.ctl
    ====sqlplus
    sql> select * from t;
            ID TEST_STRING
           100 2010021619495250Post any issues you encounter/ any other questions you might have....

  • Changing date (and sequence) of events by changing dates of photos no longer seems to work. Any idea what to do?

    I am scanning in old slides and negatives (from the 1960s and 70s), and I want to get the resulting "events" in sequence from when the photos were taken, rather than when they were scanned. So I have been changing the dates of the photos, and previously this resulted in the associated event moving to the proper sequence. This definitely worked a month or so ago, both with prints scanned in on a flat-bed scanner, and also with slides and negatives scanned with a Veho scanner. That was faulty, however, and so it has been replaced with a Plustek 7500i scanner, using SilverFast scanning software, and importing the resulting images into iPhoto. I have recently tried to change the dates of the resulting events, and it doesn't seem to work as it used to. There has been an update to iPhoto 9.1.3 since my earlier success.
    Take for example one event, CS73A. Hovering over the event in the "All events" display gives dates of 1 Apr 2011 to 2 Apr 2011; these are the dates the slides were scanned in. If I open the event and choose the Info tab, it gives the event date as 02/03/1973 (which is the approximate date that I changed it to). I had done a batch change on the event this time, so the date and time on the first slide is 2 March 1973 09:30:48. Each successive slide is 1 minute later, and the last is 2 March 1973 10:08:48 (38 slides). I asked for the dates in the files to be changed as well.
    I don't know what I'm doing that's different from before. The only things I can think of are (a) something has changed in the iPhoto update, or (b) the SilverFast software stores the scanning date in some part of the EXIF that iPhoto can read but not change. I don't have tools to examine the EXIF unfortunately.
    What to do?

    Chris, I have run into the same problem.
    Try this:
    Open an event with more than one photo in it.
    Adjust the date of one or more photos. The event date does not update.
    Delete any one photo. The event date now updates to match the above date change.
    Undo the delete photo. The event date stays matching.
    Change the date of any photo again. The event date updates now every time.
    If you close the event and reopen it, you have to start over with the delete one photo thing.
    I don't understand it but it works here.
    I also have had the problem of events not sorting themselves in order of the dates when VIEW, SORT, BY DATE is selected. This seems to affect only the events were photo date changes had been made. Using the delete thing seems to keep the events in order.
    Another funny thing: When I put photos into iMovie the times in iMovie show as 7 hours off the photo time.
    I think Apple owes us an update to iLife!

  • How do I append data and sequence numbers to a *.csv file name?

    All,
    I am looking for an easy way to build a filename with the data and time included, as well as a sequential number between 1 and 999 in the following format:
    C:\TestDirectory\test_11-08-25_1551_1301_001.csv
    I have looked at using the Express function "Write to Measurement File" but I cannot see an easy way to include column headers as text into the output file.  Maybe someone could show me how to do that?
    Or, someone could point me toward another function that allows me to date and serialize the file name.  Any help would be greatly appreciated.
    I could code all this the old-fashioned, manual way, but I would rather find out if LabVIEW has built in functions that do this first.
    Thanks!

    Like this
    Tim
    Johnson Controls
    Holland Michigan
    Attachments:
    Example.vi ‏13 KB

  • Calculating the next meeting date and the number of days until that

    Hi all,
    I created a meeting log page and I made a query that returns the most recent meeting date:
    to_char("MFR_MEETING_LOG_MAIN"."ML_MEETING_DATE",'MM/DD/YYYY')
    What I want to do is to calculate the next meeting date which is 6 month after the most recent meeting and the number of days until the next meeting.
    How do I do that? THank you very much for the help in advance!

    Basic SQL:
    Datetime/Interval Arithmetic.
    ADD_MONTHS function.
    If you're new to Oracle and SQL it may be advisable at this point to complete the Database 2 Day Developer's Guide.

  • Sales order query - display invoice date and invoice number

    I have a query that is reading information from both the ORDR and RDR1. How do I link to AR invoice to get the invoice number and invoice date if the line item of the sales order has been shipped (we do not use deliveries so the AR invoice is the next document after the sales order.
    Thanks

    Hi Keith,
    The link between ORDR and RDR1 to invoice:
    RDR1.trgetentry = OINV.DocEntry
    or
    INV1.BaseEntry = ORDR.DocEntry
    Use which is more appropriate to your query
    Regards,
    David

  • Drill down on posting date and Document number

    Hello Gurus,
    In a Bex report, I am looking at account balance on a keydate for a G/L Account. When I drill down based on posting date I do not see any values for the keyfigure 'Account balance as on key-date'....But after I drill down on posting date --> document number I get to see values for thie key figure.
    What is this strange behaviour? Kindly explain.
    Regards,
    KP

    Hi KK,
    This may be due to the values/quantities having different UOM or currency for different documents/posting date.For example,  Usually when there are mixed values like this, the aggregated value is not displayed, instead a '*' is displayed in the report result. However there is a setting in BW where you can mention how to handle such mixed values.
    So I suggest you first check the currencies for the amount at the posting date/document level(when you drill down). If they are different then check the settings in the transaction SPRO --> SAP Business Information Warehouse --> Report-relevant settings --> General Reporting settings in the Business Explorer --> Presenting the numeric value in the Business Explorer.
    Here check the value maintained for 'Mixed Values'. If it is blank, then this is the reason that no value is displayed.
    Regards,
    Shilpa

  • Can Acrobat create a PDF file not viewable after some date and/or number of times being opened?

    Is it possible to restrict the usability of a PDF file in such fashion, regardless of which Adobe product tries to open the file, especially even when the file is opened with Acrobat Reader for example? If yes, does it require accessing Adobe's website or the solution could be totally 'stand alone'?
    Any other ideas about restricting the usage of a PDF file,  using Acrobat or any other tool?
    Thanks, David

    You can use the product 'Adobe LiveCycle Rights Management':
    http://www.adobe.com/products/livecycle/rightsmanagement/

  • Sequence Number By Date Option For File Naming

    I would like to see Lightroom have the option to have the sequence numbers be reset when the date changes and increment accordingly. For example, I have the file naming set to use Date (YYYYMMDD) Sequence Number (0001) and the sequence number starting at 1. As Lightroom is now I will end up with 200909010001, 200909010002, 200909020003, 200909020004, 200909030005 200909030006 etc. and what I would like to see is the option for 200909010001, 200909010002, 200909020001, 200909020002, 200909030001 200909030002.
    This would make it much faster for renaming or import when using this combination of date and sequence in file names.

    Hi
    For the Transport Protocol "File Transfer Protocol (FTP)" files are always processed in ascending alphabetical order
    If you want the file to be processed in sequence then you can use Quality of Service EOIO in the sender adapter.
    The files are processed in the sequence they are picked up.
    otherwise use BPM for File Sequencing..
    Refer the following Threads
    FTP Sender Adapter - Processing Sequence
    Processing Sequence issue of FTP protocol
    Regards
    Abhijit
    Edited by: Abhijit Bolakhe on Nov 4, 2009 10:32 AM

  • Custom Date and Number Formats

    Is there a way in disco admin to set the date format based on values from the database?
    For example, we have a function that we use in Oracle Reports (p_indicator passed in):
    CASE p_indicator WHEN '1'
    THEN v_format := 'MM/DD/YYYY'; -- US Date format
    ELSE v_format := 'DD-Mon-YYYY'; -- Foreign Date format
    END CASE;
    return v_format;
    In the Oracle Report field Format Trigger we use (iss_date_field_display is the database field indicator from the report SQL):
    SRW.SET_FORMAT_MASK(format_mask(:iss_date_field_display));
    So, any way to dynamically change the format mask for date and/or number fields in Discoverer based on data in the schema and/or a function?
    Thanks!

    Thank you,
    What would be the best way to call this function in a workbook?
    i created a function in the schema, and tied it to a calculation in the workbook, but the dbms lines fail. if i comment them out, i get a return, otherwise, the return is not getting set. here is the work...
    BEGIN
    dbms_session.set_nls('nls_currency', '''£''');
    CASE p_indicator WHEN '1'
    THEN
    dbms_session.set_nls('nls_date_format', '''MM/DD/YYYY'''); -- US Date format
    v_format := 'MM/DD/YYYY';
    ELSE
    dbms_session.set_nls('nls_date_format', '''DD-Mon-YYYY'''); -- Foreign Date format
    v_format := 'DD-Mon-YYYY';
    END CASE;
    RETURN v_format;

  • Please turn back sequence number to one in Batch rename

    In Bridge 2 the sequence number option has changed. It used to start automatically at 1 starting a new session. In the rare cases that there is one project in different sessions that needed to start with the following number of the last session I just needed to fill that number in.
    Unfortunately now it is the other way round. I'm used to sessions with a small number of photographs from the same session (I think that I'm not the only one in this).
    With the very useful and easy function batchrenaming set to date - text - sequence number the only thing I had to care about was the text, now I also have to fill in 1 as start number sadly enough, and this is in my opinion unnecessary time consuming :-(

    And so very, very easy to forget.
    This incrementing is a setting preferred by a minority of photographers, not the majority. It's quite handy if you shoot many, many cards worth of the same thing and load and rename whilst still shooting. Most photographers, i.e. those without assistants loading + naming images as they shoot, will do the opposite and when after a long day's shooting, having to remember to reset the sequence no. every time you rename some files is very easily overlooked and then a real pig to then redo correctly. Esp when tired.
    If it was an option fine, but as the default, duh!?

  • Batch rename without sequence number

    In LR3 I originally named imported images with the date, custom
    word, and sequence number.  I now want to batch rename with just the date, and cust
    om word - no sequence number.  Yet the rename includes the
    numbers anyway, and they are different than the original sequence numbers.  How do I get rid of
    the unwanted numbers?  Thanks

    I don't think LR provides a way to cut characters from the end of an existing filename.
    Beat Gossweiler
    Switzerland

  • How do you date and time stamp pictures and videos using a EOS Rebel T3?

    I am needing to utilize date and time stamping on videos and photos in my work.  The pictures and videos must display time, a date, and reference number.  I have gone through the cd, owner's manuel and software manuel and I am unclear if I can perform this function. 

    While this is a relatively common feature on point & shoot cameras -- where the photo is thought of as a snapshot to document a memory in a person's life, among DSLR cameras it's not very common (I don't actually know of a DSLR that does this though I don't doubt that it may exist).  DSLR users are usually expecting a higher quality image -- so now the image is thought of more like art and less like a snapshot and the date/time in the corner distracts from the image.  Also they tend to be more advanced users who would be able to modify the image themselves so they have little need for such a feature.
    The camera does record the date & time... but it's in the EXIF data (information recorded into the image file but not displayed).  
    SO... there are programs that will just do this.  You'll need to do a search (I found several but have never tried one so I can't vouch for them).  I think there are Photoshop plug-ins that do this (assuming you have Photoshop). These programs allow you to define the info you want printed (including EXIF data such as date/time) and you get to pick the location, font, size, color, etc. and ultimately the location on the image where you'd like the info displayed.  They then add the info visibly onto the image for you and most support "batch" use (e.g. drop a whole folder of images on it and they'll do them all.)
    Tim Campbell
    5D II, 5D III, 60Da

  • Date and Roll

    I clicked on a picture and the date and roll number came up when it was taken. The date and roll number will not disappear. I can go to another album and it still stays on the screen. I can click to view the picture bigger and it still stays there.

    You know sometimes you get caught up, you forget to do the simple things to fix most problems. Restart. Its working fine now. Thanks!

  • Week Start Date from Week Number

    How would I display the Week Start Date and Week Number for a range of dates.
    required output:
    weekno weekstartdate qty
    11 8/03/04 50
    12 15/3/04 100
    13 22/3/04 75 etc

    Do you have a start and end date and need it expanded to weeks ?
    Let's say you have a table that include both the start and end dates
    select to_char(ddate,'WW'), ddate
          from (select start_dt + rownum - 1 ddate
                  from user_objects,
                       (select min( START_DATE ) as start_dt,
                               max( END_DATE ) as end_dt
                          from MY_TABLE
                          WHERE .... )
                  where start_dt + rownum <= end_dt ) a
      where to_char(ddate,'D') = '1'
    /Of course, one of the problems with WEEK is interpretation. Week one does not start until the First Sunday of the year. Which may or may not be what you want

Maybe you are looking for

  • How can I read an XML string that's not from an XML file?

    I've got a script I'm trying to setup that communicates over a socket to retrieve different directions from a custom built Java program.  The Java program listens to requests from the Adobe scripting engine (in my case it's a Photoshop script) on a s

  • How / from where to start on Solaris Driver developement?

    Hi, 'm a User domain developer, want to also learn about driver developement. Please give me pointers so that I can start with Thanks, -Vikrant

  • You are not connected to the internet error

    Recently, my old Apple iMac 9.1 - OS X V10.5.8 - stopped connecting to the internet with error message "You are not connected to the Internet". Having checked all other devices on the WIFI network, there seems to be is no reason for issue. Now utilis

  • Oracle.jbo.TooManyObjectsException: JBO-25013

    Hello, We are using JDeveloper 9.0.3.1 (I know, quite old). The following exception appears from time to time when re-initializing a dialog with a different id: oracle.jbo.TooManyObjectsException: JBO-25013: Too many objects match the primary key ora

  • Will it make any sense to create materialized view on top of a MOLAP cube?

    Hi, We have developed few MOLAP cubes for our reporting environment. Now we are planning to create materialized with query rewrite enabled for faster performance? Is this a correct approach? Will it make any sense? I mean will i get any performance i