Generate an unique number without sequence

Hello,
I need generate an unique number without sequence. I am using Oracle 11.2, here is the details. The column idSeq is unique withing one specific idType. I don't want a sequence for each idType.
create table tb_test (idSeq number(5), idType number(5), addr varchar2(256));
insert into tb_test
(select case when idSeq is null then 1 else max(idSeq)+1 end, 3, 'Main street');
I am having ORA-00937 : not a single-group group function error, any suggestion?
Edited by: 939569 on 13-Feb-2013 11:21 AM

Hi,
939569 wrote:
Hello,
I need generate an unique number without sequence. Explain what you're trying to do, and why a sequence won't do it.
I am using Oracle 11.2, here is the details. The column idSeq is unique withing one specific idType. I don't want a sequence for each idType.
create table tb_test (idSeq number(5), idType number(5), addr varchar2(256));
insert into tb_test
(select case when idSeq is null then 1 else max(idSeq)+1 end, 3, 'Main street');
I am having ORA-00937 : not a single-group group function error,Right. Since the sub-query is using an aggregate function (MAX), everything in the SELECT clause must be an aggregate, a group by expression, a constant, or something that depends entirely on them. In this example, the CASE expression depends on idSeq, which is not an aggregate, not a group by expression (there is no GROUP BY clause) and not a constant.
Also, the sub-query must have a FROM clause. All queries and sub-queries in Oracle require a FROM clause.
any suggestion?Use a sequence. The numbers won't be consecutive within each idType, but what does that matter? Chances are, no matter what you do, you won't be able to maintain consecutive numbers within each idType anyway.
If you won't use a sequence, then you can try:
INSERT INTO  tb_test (idSeq, idType, addr)
SELECT  1 + NVL ( MAX (id_seq)
              , 0
,       3
,     'Main street;
FROM     tb_test
WHERE   idType  = 3
;

Similar Messages

  • Function module to generate a unique number in report based on descrepency

    hi friends,
    i have a object that..
    Every discrepancy Should Have a unique number in the report, which calls based on the discrepancy (dc_qty)-(recd_qty)=shortage
    the shortage value will be always positive,n not <=0..
    is there any function module which should generate a unque no
    based on passing MBLNR..
    or any other way...
    Thanks n regards
    harish

    use following funtion module
    call function 'NUMBER_GET_NEXT'
            exporting
              nr_range_nr             = '01'
              object                  = 'ZBDCMSC2N'
            importing
              number                  = file_no
            exceptions
              interval_not_found      = 1
              number_range_not_intern = 2
              object_not_found        = 3
              quantity_is_0           = 4
              quantity_is_not_1       = 5
              interval_overflow       = 6
              buffer_overflow         = 7
              others                  = 8.
          if sy-subrc <> 0.
            message id sy-msgid type sy-msgty number sy-msgno
                    with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
          endif.
    in This
    Creat a number Range object(ZBDCMSC2N') using transction SNRO.
    for any problem revert back.
    regards
    Rajesh

  • How to generate Serial(Unique) Number for finished goods?

    Guru's,
    How do i generate Serial(Unique) Numbers for finished goods.Suppose,if we get an order for a finished good A of 10 qty.We want to generate unique number to identify each and every A item separately for quality purpose.Any help is much appreciated.
    thanks Guru's

    Depending on serial control of item, you will need to generate serial numbers at the time of WIP Completion transaction using Serial Entry window (i.e. if serial control is At Receipt) or at the time of job creation (i.e. if you are using serial control as predefined)
    In latter case, you will have to use MES or MSCA screens to perform serialized WIP completion.
    Thanks,
    Hrishi

  • Generate GUID (unique number random)...

    hi,
    i have a situation, i want to generate a GUID, a random alphanumeric numbers in the pattern like below.
    f2157b31-fded-11d8-ae89-15c8e06e3da2
    how can i do that.
    thanks

    It's not going to be very useful as a key if it's random.
    get Random to deliver you an int between 1 and 36. Map the
    numbers to the numbers 0-9 and the letters a-z.
    Repeat as necessary to fill in your pattern.

  • Generating a Primary Key WITHOUT using a Sequence Number

    Hi Everyone:
    I am trying to generate a primary key without using a sequence number or row count. What the user wants is the maximum value of the highest primary key already in the row set plus 1.
    For example, this is a Oracle Table (eg. named BatchSubmit) used to initiate batch job submission, and the primary key is an integer named "Runcard_Number". If there are 4 rows in this table and the Runcard_Numbers are 2, 6, 8 & 12, then the next generated Runcard_Number would be 13.
    I have looked throughout this forum and see how to generate numbers using a DBSequence, but the user does not want that. The numbers mean something to them, and they don't want them randomly assigned other than the max in the rowset plus 1. To do it in SQL it would be - select max(Runcard_Number) + 1 from BatchSubmit;
    I have been looking at using a hasnext loop and moving the maximum value to the new Runcard_Number, but I am very new to JHeadstart/JDev and I do not know where to put this. I am assuming the BatchSubmitImpl.java, but I'm not sure where to put it or which method to utilize
    I would appreciate any assistance.
    Mary
    U o Windsor

    Mary you're in luck, 'cause, I've been playing with the same thing, these days and found that..
    You can do that in two ways (that I know):
    - by calling a stored function that does max+1 (you can look it up in Dev's guide for Forms&4GLDevs 10g chapter 25.5 Invoking Stored Procedures and Functions)
    - by calling hardcoded or dinamicaly written statement, that does the same
    public Number callStatement(String stmt)
    Number id = new Number(0);
    Row idRow = getDBTransaction().createViewObjectFromQueryStmt(stmt).next();
    if(idRow != null)
    Object o = idRow.getAttribute(0);
    if(o != null)
    if(o instanceof Number)
    id = (Number)o;
    else
    throw new JboException("Conversion error!");
    return id;
    You should call it in
    protected void doDML(int operation, TransactionEvent transactionEvent)
    switch (operation)
    case DML_INSERT:
    // call here
    super.doDML(operation, transactionEvent);
    break;
    case DML_UPDATE:
    super.doDML(operation, transactionEvent);
    break;
    case DML_DELETE:
    super.doDML(operation, transactionEvent);
    break;
    Enjoy!
    S. Julijan

  • Increment a number without using sequence in Mapping

    Hi,
    Is there anyway to increment a number without using oracle sequence generator in OWB? I am using version 10.2.0.4.
    Please let me know.
    Thanks,
    Siva

    Perhaps it would help if you were more specific on what you wanted to do. I mean, there are many ways to generate sequences of numbers in Oracle. For example:
    select level as seq_num from dual connect by level < 100;
    to get the integers from 1 to 100. If you are dealing with order of rows within subsets of a query, take a look into analytic functions like rank().
    But "Ways to increment a number"? Sure:
    create function increment( x in number) returns number is begin if x is not null then return x+1; else return null; end if; end;
    Now call your increment function!
    Not sure what you are trying to accomplish, and can't help much without knowing.
    Sorry.

  • Replace the hidden step property Id (GUID) by a unique integer number on sequence level.

    Hi,
    I want to log TestStand data into an existing SQL database.
    The step ID in my database is an integer (Integer data van -2^31 (-2.147.483.648) tot 2^31-1 (2.147.483.647)),
    so a GUID id does not fit in this field.
    Is it possible to change the GUID id to a unique integer number on sequence level? TestStand should stuff the integer id automatically while inserting steps…
    If a number field is added to the test steps definitions, is it possible that TestStand automatically fills the numeric step ID for each instance of the test steps in the sequence while inserting the step?
    Best regards

    You could use the index and step group of the step to create a numeric id, but it will change as soon as any step is inserted before the step.
    If you absolutely can't change your database and have to make it work, you could always generate/update a map of GUID to integer id for each sequence, perhaps at runtime from the first step in the sequence. Basically, have the first step create or update the mapping. You'd also likely need to store a last used id so you know what id to start with when you add anything to the map.
    Really probably the best solution is to change the database though. If you really want a unique ID per step that survives inserting new steps before it, then a GUID is a much simpler way to go.
    Hope this helps,
    -Doug

  • Generate Random Number By sequence

    How to generate random 4 digit random number using sequence or any other method. Please suggest

    4 digit random numbers can be obtained by:
    SQL> SELECT TRUNC(DBMS_RANDOM.VALUE(1000,9999)) FROM DUAL;
    TRUNC(DBMS_RANDOM.VALUE(1000,9999))
                                   4002
    SQL> /
    TRUNC(DBMS_RANDOM.VALUE(1000,9999))
                                   4748
    SQL> /
    TRUNC(DBMS_RANDOM.VALUE(1000,9999))
                                   8328
    SQL> /
    TRUNC(DBMS_RANDOM.VALUE(1000,9999))
                                   3667
    SQL> /
    TRUNC(DBMS_RANDOM.VALUE(1000,9999))
                                   7464
    SQL> /
    TRUNC(DBMS_RANDOM.VALUE(1000,9999))
                                   4893
    SQL> /
    TRUNC(DBMS_RANDOM.VALUE(1000,9999))
                                   4961In mine case there is no repetition using Oracle 11.2.0.1 on Windows XP.
    Regards
    Girish Sharma

  • How to generate a unique 8 byte number for a String in DES

    Hi All,
    Is there any way to generate a unique 8 byte number representation of String?
    I know it can be done with DES encryption (while MD5 gives 16 bytes number). My requirement is:
    Every time a String is passed - my static method should return the same unique number - all the time.
    i.e A String "AAAAAA" will return same unique number all the time. How can I achieve this (8 byte number) by DES Encryption or any other encryption?
    Thanking all in advance.

    Thanks for your reply. Won't there be any loss of data if I consider only first 8 bytes? Will Integrity be maintained.?
    In some cases my Strings can be unusually long - having length of 400 to 500.
    I want 8 bytes as I want to map the number with MySQL bigint field.

  • F110 Generate Check Number without creating a spool.

    Dear Gurus,
    In F110 Automatic Payment Run, I want to generate check numbers but without creating a spool. I want to do so because the interface would give the cheque details straight away to the banks. Also a spool should not be created in system for control purposes to avoid duplication.
    Thanks in advance...
    Regards
    Dhaval Thakkar

    Hi,
    Create a blank payment form and assign it to the payment method in FBZP. Thus no cheque is printed / spool created when running the print program in F110. At the same time cheque numbers are also generated.
    Rgds
    Shivram.

  • How to generate a Unique key based on a some String value

    Hello every one,
    I am sorry , If I post this question in wrong group... I have a requirement to generate a unique key ( what every it may be alpha, numeric or alpha numeric) based on some String..
    For ex : String str = "AbCX" - Gives a unique key based on "AbCX" value..
    Is there any way we can get the unique value using Java ?
    Thanks

    May be not what you are looking for, but here's may idea:
    use a sequence (db sequence) and add it the the string value. This way the value is unique, because the sequence is unique. So you could omit the string theoretically, but your requirement is met.
    It's very easy to get a unique sequence number from the db using java, depending of the technology you use (which you did not say :-( )
    Timo

  • Want to use document number as the cheque number (without cheque management

    Dear All,
    During Automatic payment run - F110 I would like to use accounting document number as cheque number.
    Kindly suggest solution for the same.
    Thanks
    Prashant

    Hi Santosh,
    In this country Bank letters are issued as mode of payment. Unique sequence number is used to track the Bank letter. Since Accounting Document is Unique number I want to use the same.
    Kindly suggest the solution for capturing Accounting Document number instead of Cheque number.
    Or in other words I want to run F110 without maintaining cheque lot. Is it possible to make payment run without maintaining cheque lot number.
    Thanks
    Prashant

  • How to select  random and unique number

    hi all
    suppose i have millions of rows in emp table
    i want to select group of empno
    group of records would be 10
    all records uniquely selected
    make sure all records are selected in any Group
    thanks

    BluShadow wrote:
    Solomon Yakobson wrote:
    3360 wrote:
    It is the definition of random that the each value generated has an equal chance of being generated again. A coin toss is random despite the result only having two values.Absolutely. Except one little thing. The above applies if we randomly pick from same set. Now OP asked to randomly select group of objects. This is same as you have a set of unique objects and you randomly pick one and put it in your pocket. Then you randomly pick another object and put it in your pocket. So you end up with a UNIQUE set of randomly picked objects in your pocket. Now DBMS_RANDOM allows to specify low & high value but it doesn't allow to provide something like "pick N values" or except list to mimick "put in your pocket" part. That is why we have to write something like I suggested to OP.
    SY.In that case it should just be an answer like...
    select * from tablename where rownum <= 10because the order is not guaranteed without an order by clause and therefore that's just as random as needed to meet the requirements. ;)hi BluShadow
    rownum surely give unique number of records but it will not A RANDOM....
    thanks

  • Generating a unique ID to pass to Payment Provider?

    Hi.
    I have a site that has "orders" from customers which have a
    unique ID (PK).
    I'm using ASP / SQL.
    I was passing this ID to my payment service provider but have
    discovered
    that, if a customer for some reason cancels the order (highly
    likely), then
    that ID cannot be passed to the payment provider again.
    Therefore, when the
    customer logs back in to our site, they'll still see the
    order as "requiring
    payment" but when they try to re-submit the order, the
    payment provider
    won't allow it! Groan!
    Anyway, that is the way their system works, and I understand
    why I suppose
    (unique identifier 'an all that).
    So, my solution is to simply pass a unique value (which
    doesn't have to
    relate to my unique order ID) to the payment provider.
    My question is....how can I create/generate a unique value on
    my checkout
    page and ensure that the same value is never generated twice?
    Is there a
    feature in DW?
    Oh yes, and I need it to be a numerical value! :o)
    Thanks.
    Nath.
    Brain < Pea

    Here is a guaranteed unique algorithm for any string (sequence of characters.)
       String createMyId(String stringToEncode)
          String uniqueId = stringOfChars;
          return uniqueId;
       }The code above guarantees the following properties (expressed as psuedo logic code, not java code.)
    For any given sequence of chars A and B.
    If A = B is true if and only if createMyId(A) = createMyId(B)
    And of course
    If A != B is true if and only if createMyId(A) != createMyId(B)
    Of course the problem with the above algorithm is that it produces a variable sized value. But if you use a char array of of size Integer.MAX_VALUE then you can guarantee that it will work for any String in java. There is still a downside to this in that it requires a lot of data.
    Of course someone who is particularily observant might note that this suggests that one might as well just store the string. That however is just an optimization in the above algorithm and as nothing to do with the validity of the algorithm itself.

  • Use hardware to generate a certain number of pulses using PXI-5652

    Is it possible to generate a certain number of periods (turn on the output for a predetermined amount of time using hardware with micro-second resolution) using the PXI-5652.

    Hello Matt,
    If you had a Vector Signal Generator, this would be more controllable using something similar to this forum.
    Otherwise, the only way to control time on the 565x would be to use OOK modulation scheme. This will allow you to turn on the signal for a little time On and Off.
    There is a shipped example called "565x Digital Modulation.vi" (on versions 1.3 and later of the RFSG driver) that can perform this task. Basically it uses the function named "niRFSG Configure Digital Modulation User Defined Waveform.vi" to write the user bit sequence and with property nodes you will configure the OOK scheme and the symbol rate (refer to specifications of your card for the possible values).
    Hope this helps,
    Gerardo O.
    RF Systems Engineering
    National Instruments

Maybe you are looking for

  • Merging multiple libraries

    On my C drive under Music- Itunes, I have multiple Itunes libraries.  There are some duplicates (don't get me started on that !).  There are regular music libraries and xml libraries.  How do I consolidate them all into one, so that when I un-install

  • WAD: Size of graphic is too small to display data

    Hi BI-Gurus I get a message showing that the graphic size is not large enough to display data. I already have a chart item linked to a query which has the same amount of columns as result. This chart/graphic seems to be okay, WAD displays it. But the

  • I can't download emails to my iPhone today, working fine yesterday.

    I suddenly cannot download incoming emails over several accounts to my iPhone5 mail app. I can still receive emails. another iPhone5 (my wifes) can still receive emails ok with same settings On my imap4 account I get imap4.blueyonder.co.uk is not res

  • Missing Makefile.cpu in a custom build

    Hello, I have built a vanilla 2.6.15 kernel package and one with the ck1 patchset using ABS and the script from dibble.  The kernels work nicely, but I am needing to build atheros drivers (madwifi) and they complain about Makefile.cpu being missing.

  • Spanning tree bpdu

    Hi all, can anyone tell me 2 things, firstly do only the uplinks on a switch send out bpdu's ? secondly if I disabled spanning tree on the uplink ports would the switch not send any bpdu's out thus the switch not participating in spanning tree to the