Auto-increment for alreay column in existing table DB

Hello

We have a DB table with column of type Number. Table is already to have contained huge. Now, we want to have the auto-increment for this particular column.

From now on, I created this table-based entity/view objects. Created attribute from entity sequence and update as follows.

Create the GLOBAL_SEQ INCREMENT OF 1 SEQUENCE START with 1;

Updated the expression of the attribute of the entity with logical next

(new oracle.jbo.server.SequenceImpl ("GLOBAL_SEQ", object.getDBTransaction ()) .getSequenceNumber)

When I tried to create a new line by using "Browser Oracle Business Component", the sequence fixed 0,1, 2... etc. But there are lines with these values in this column.

But we want to create new line taking into account the maximum value of the column and the increment of 1.

It would be great, if you can suggest an idea on this issue.

Thank you

MSR.

You can leave to start the sequence with any number you like. For example, you can first make a max (id) of the table selection and the beginning of the sequence value max + 100...

Timo

Tags: Java

Similar Questions

  • How to add the new column in existing table to our desired location?

    How to add the new column in existing table to our desired location?

    For example, I have to add the new column 'course' before the salary column in the emp table.

    I think the best way is to add the column at the end of the table and create a new view with the order of the columns...

    Another option...

    places the data into a temporary table and recreate the table with the correct order of the columns, and then insert data to the table from the temporary table

    Refer

    Add column (from table) in the desired position

    Example:

    CREATE TABLE temp_my_user LIKE)

    SELECT * FROM password);

    DROP TABLE password;

    (Password) CREATE TABLE

    userID NUMBER

    , first name VARCAHR2 (25)

    , middleInitial VARCHAR2 (1)

    (, name VARCHAR2 (25));

    INSERT INTO password (userID, firstName, lastName)

    (SELECT username

    first name

    lastName

    OF temp_my_user);

    DROP TABLE temp_user;

  • How to find the value max and min for each column in a table 2d?

    How to find the value max and min for each column in a table 2d?

    For example, in the table max/min for the first three columns would be 45/23, 14/10, 80/67.

    Thank you

    Chuck,

    With color on your bars, you should have enough experience to understand this.

    You're a loop in the table already.  Now you just need a function like table Max and min. loop.  And you may need to transpose the table 2D.

  • Adding a sequence as a default value for a column in a table field

    Hi all

    APEX 4.2.4. Oracle XE 11.2

    I'm trying to add a default value from a sequence to a column in a table field, so he fills when I hit the "Add Row" button...

    The reason for this by the way, rather than simply using a sequence database and the trigger on the column (which exists and works very well), is that I try also add detail records to the line when I create, and I can not, I do not have the ID of the parent to the child records.

    Looking at the docs, (for example oracle 11 g pl/sql enhancements), I thought I'd have be able to use a PL/SQL expression as to_char (petty_cash_seq. NEXTVAL) or to_number (petty_cash_seq. NEXTVAL) or all that kind of expression that extracts the sequence.nextval, as it became available in PL/SQL on the database

    so, Ive tried

    TO_CHAR (petty_cash_seq. NEXTVAL) in tabular form attributes - column default / PL/SQL expression and he said ORA-02287: unauthorized number sequence here...

    Ive also tried rolling upward in a PL/SQL package, as below:

    DECLARE v_seq_value NUMBER; BEGIN select petty_cash_seq. NEXTVAL in the double v_seq_value; return v_seq_value; END;

    and I get ORA-00923: KEYWORD not found where expected.

    Can anyone help as to why neither of them do not seem to work as an expression / packages in the default type?

    or... a simple alternative to get the ID of the next record when I hit 'Add Row' before I can create child folders at the same time...

    And I've been mulling over the merits of the master / detail integrity and try to think in an orderly manner to create the mask, add the details without having to first submit the master, then go back and go into details... And put it into context, its a request for costs where users create an expense entry and download copies of their expenses at the same time...

    Thank you very much

    Richard

    Use a combination of AJAX and JavaScript to get the next value in the sequence in a version substituted the line Add.

    1. on the page editor, right-click on the Ajax callbacks and select Create.

    2. on the next page, select PL/SQL. Do * not * select the tabular presentation. Leave this field blank.

    3. name your process, e.g. getNextSequence

    4. Add the code (under the DIRECTION of your own names of the object):

    DECLARE
        ln_NextSequence NUMBER := 0;
    BEGIN
        SELECT MY_SEQUENCE.NEXTVAL
        INTO ln_NextSequence
        FROM DUAL;
    
        HTP.P(TO_CHAR(ln_NextSequence));
    END;
    

    5. When you look now, you will see that the button Add a line called javascript:addRow (). Remove all this and change the button to be triggered by a dynamic action.

    6. create a dynamic action when a click on your button to add a line

    7. Add the following JavaScript code to get the new value of the sequence using your AJAX call from above and then place it on the newly added line:

    var nextSequenceID;
    
    apex.server.process(   'getNextSequence'
                         , {}
                         , { dataType: "text",
                             async: false,
                             complete: function( ajaxResponse )
                                      {
                                        nextSequenceID = ajaxResponse.responseText;
                                      }
                           });
    
    addRow();
    
    $('td [headers="YOUR_ID_COLUMN_NAME_HERE"] input:last').val(nextSequenceID);
    

    -Joe

  • Casting table PL/SQL for the type of existing table and back ref cursor

    Hello



    I have the problem of casting a pl/sql table for the type of an existing table and turning the ref cursor to the application. Casting a ref cursor back and number of pl/sql table works well.



    Declarant

    < strong > TYPE type_table_name IS TABLE OF THE package_name.table_name%ROWTYPE; < facilities >

    within the stored procedure, fill in a table of this type temp_table_name and returning the ref cursor help

    < strong > results OPEN to SELECT * FROM TABLE (CAST (temp_table_name AS type_table_name)); < facilities >

    generates an error. type_table_name is unknown in this distribution. According to me, this happens because of the declaration of the type locally.



    Statement type_table_name inside the package specification does not work neither. Incredible, cast to the said dbms_sql.number_table to specify ref cursor back and dbms_sql package works very well!



    < strong > CREATE TYPE type_table_name IS TABLE OF THE package_name.table_name%ROWTYPE; < facilities > deals without any error but creates an invalid type complain a reference to package_name.table_name



    I don't want to declare every column in the table in type_table_name, because any change the table_name table would result in an inconsistent type_table_name.



    Thanks in advance!

    Edited by: user6014545 the 20.10.2008 01:04

    In any case you are right that there is a problem around anchorage (or maintaining) types of objects persistent to match the table structures, they may represent.

    In the case you describe, you might be better off just open the refcursor immediately the using one of the techniques described in the http://www.williamrobertson.net/documents/comma-separated.html to manage the delimited list.

    In the more general case where the line of treatment is necessary, you may make the pipeline functions.

    Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production
    
    SQL> CREATE TABLE table_name
      2  AS
      3     SELECT ename column_name
      4     FROM   emps;
    
    Table created.
    
    SQL> CREATE OR REPLACE PACKAGE package_name
      2  AS
      3     TYPE type_name IS TABLE OF table_name%ROWTYPE;
      4
      5     FUNCTION function_name_pipelined (
      6        parameter_name IN VARCHAR2)
      7        RETURN type_name PIPELINED;
      8
      9     FUNCTION function_name_refcursor (
     10        parameter_name IN VARCHAR2)
     11        RETURN sys_refcursor;
     12  END package_name;
     13  /
    
    Package created.
    
    SQL> CREATE OR REPLACE PACKAGE BODY package_name
      2  AS
      3     FUNCTION function_name_pipelined (
      4        parameter_name IN VARCHAR2)
      5        RETURN type_name PIPELINED
      6     IS
      7     BEGIN
      8        FOR record_name IN (
      9           SELECT table_alias.*
     10           FROM   table_name table_alias
     11           WHERE  table_alias.column_name LIKE parameter_name) LOOP
     12
     13           PIPE ROW (record_name);
     14        END LOOP;
     15
     16        RETURN;
     17     END function_name_pipelined;
     18
     19     FUNCTION function_name_refcursor (
     20        parameter_name IN VARCHAR2)
     21        RETURN sys_refcursor
     22     IS
     23        variable_name sys_refcursor;
     24     BEGIN
     25        OPEN variable_name FOR
     26           SELECT table_alias.*
     27           FROM   TABLE (package_name.function_name_pipelined (
     28                     parameter_name)) table_alias;
     29
     30        RETURN variable_name;
     31     END function_name_refcursor;
     32  END package_name;
     33  /
    
    Package body created.
    
    SQL> VARIABLE variable_name REFCURSOR;
    SQL> SET AUTOPRINT ON;
    SQL> BEGIN
      2     :variable_name := package_name.function_name_refcursor ('%A%');
      3  END;
      4  /
    
    PL/SQL procedure successfully completed.
    
    COLUMN_NAME
    -----------
    ALLEN
    WARD
    MARTIN
    BLAKE
    CLARK
    ADAMS
    JAMES
    
    7 rows selected.
    
    SQL> ALTER TABLE table_name ADD (new_column_name VARCHAR2 (1) DEFAULT 'X');
    
    Table altered.
    
    SQL> BEGIN
      2     :variable_name := package_name.function_name_refcursor ('%A%');
      3  END;
      4  /
    
    PL/SQL procedure successfully completed.
    
    COLUMN_NAME NEW_COLUMN_NAME
    ----------- ---------------
    ALLEN       X
    WARD        X
    MARTIN      X
    BLAKE       X
    CLARK       X
    ADAMS       X
    JAMES       X
    
    7 rows selected.
    
    SQL>
    
  • Change data type for the column in a table - Oracle 8i

    Team,

    I need to change a VARCHAR2 column in number.

    ALTER table xyz change number abc;

    By giving the above statement, it says I need empty this column before you change.

    I can't change the data type before emptying this column.

    Please indicate any other solution. Give me some suggestions.

    Empty the column for me here BIG task.

    user11081688 wrote:
    I can't change the data type before emptying this column.

    Not according to the documentation:

    You can change the data type of any column or decrease the size of the entire column if all rows in the column contains NULL values.

    Please indicate any other solution. Give me some suggestions.

    You can add another column with the correct data type.

    ALTER TABLE xyz ADD COLUMN def NUMBER;
    UPDATE TABLE xyz SET def = TO_NUMBER(abc);
    ALTER TABLE xyz DROP COLUMN abc;
    ALTER TABLE xyz ADD COLUMN abc NUMBER;
    UPDATE TABLE xyz SET abc = def;
    ALTER TABEL xyz DROP COLUMN xyz;
    

    If I remember correctly, Oracle 8i does not support the change of name of column if this solution is a bit more complicated than 9i and above. Another option would be to create a new table with CREATE TABLE AS... SELECT, drop the old one and rename a new one to the old.

  • maximum value for a column in a table without using rownum and rowid, group

    Hi all

    Is it possible to recover the maximum value in a column of a table without help:
    1 rownum and rowid.
    2. the Group
    3. any built-in function of Oracle.

    Kindly let me know if possible.


    Kind regards.

    Published by: J2EE_Life on January 23, 2012 21:06
    select e1.empno
      from scott.emp e1
      left outer join scott.emp e2 on e1.empno < e2.empno
     where e2.empno is null
    
  • Find columns that exist in one, but that do not exist in another table?

    I ' having a slight problem. I can't find an appropriate SQL query to return values for a column that exist in a table, but that do not exist in another (related).

    TABLE CAR
    (
    PK CAR_ID,
    CAR_TYPE
    )

    TABLE CAR_IN_REPAIR
    (
    PK ID,
    FK CAR_ID,
    FK REPAIR_SERVICE_ID
    RETURN_DATE (NULL)
    )

    I want to show the records that appear in the table of the CAR, but who are not in the CAR_IN_REPAIR and that CAR_IN_REPAIR. RETURN_DATE is less than SYSDATE or zero (date of return unknown).

    In short, I want the query to display the cars that are currenty in repair or does not know the date of return from the repair center (NULL)

    I did a SQL query:

    SELECT c.id
    DRIVE c, CAR_IN_REPAIR r
    WHERE c.id NOT IN r.car_id

    the query returned no data but data is in the table of the CAR because he displayed when I SELECT * CAR?

    Published by: OraNewbie on August 28, 2008 21:02

    Try this-

    strikeselect * from CARminusselect * from CAR_IN_REPAIR--strike--
    
    select *
    from CAR c
    WHERE c.id NOT IN (
                         select r.car_id
                         from CAR_IN_REPAIR r
                      )
    

    Hope this will help you.

    Kind regards.

    LOULOU

    Published by: Satyaki_De on August 29, 2008 12:35 AM

    Oops! The table structure is different...

    Published by: Satyaki_De on August 29, 2008 12:38 AM

  • Max and Min value for each column

    Hello!

    Can someone help me to change my. VI? I want to get the Min and Max value for each column in the table in the appendices. Then I need to create two tables 1 d - the first with the min and the second with the max value.

    I've already solved the problem the solution is below

  • How to find the NULL columns in the table?

    Hello

    Please provide the query to search for null columns in the table. Here, all the rows in the table have same column as null. It will not change.

    Table
    ---------------
    C1 c2 c3 c4
    X C 10
    T D 20

    I want to know that C2 is the nullable column.
    Thanks in advance!

    Kind regards
    Florian...

    A variance more

    create or replace function is_nulled_column(tab varchar2, col varchar2) return varchar2 is
    cnt number:=1;
    begin
      execute immediate 'select count(1) from '||tab||' where '||col||' is not null and rownum=1' into cnt;
      return case when cnt=0 then 'Y' else 'N' end;
    end;
    

    and use:

    select
     c.OWNER,c.TABLE_NAME,c.COLUMN_NAME,c.NULLABLE,is_nulled_column(c.TABLE_NAME,c.COLUMN_NAME) all_nulls
    from all_tab_columns c
    where c.OWNER=user
    and c.TABLE_NAME like '%'
    order by c.OWNER,c.TABLE_NAME,c.COLUMN_ID
    
  • CSS: Pointing out the columns of the Table

    I want to use the border-bottom property to create underscore for the columns of the table. The complexity is when I try to create colspanned 'parent' or 'Super-colonnes' i.e. of the column heads that span 2 or more child/sub-headings heads. I need the underscore to stop a few pixels short of the next column, so that the user can see what child columns are included in the parent. When I tried to add white borders to the left and to the right, that he worked too good, in that not only it has created the space downstairs, he also created the space at the top (or bottom one above). Essentially the vertical borders to sit on top of the horizontal. Anyone can make sense what I said right? Any ideas how to get what I want (elegantly)?

    Thank you.

    Well, it was pretty easy. I just added the border-collapse attrib and set 'split' and now (white) borders left and right do not cut into the bottom border of the cell above.

    http://mysite.Verizon.NET/brentemerson/public/test_page0.html

  • Surrogate key / auto incremental identifier for a stand-alone table?

    I know that you have the surrogate key in a dimension table
    But what I want is a primary key in a normal table with extra car without any connection to a dimension table... is possible to do?

    Edited by: 854616 may 9, 2011 02:54

    Hello

    Yes, just use your own SEQUENCE object in the map and the NEXTVAL with the sequence operator for the inserted rows. You can match on your own key columns of the company for the columns updated. Within the mapping operator, you can control which columns are used to insert, which, for the update and are use to update.

    See you soon
    David

  • auto increment column restart

    I'm looking for a way to auto-increment column when I've found the solution here.
    BEST creation in Oracle auto-increment columns all the solutions I've found so far use a sequence. However when I remove the table and start the sequence restarts obviously in the last number that is used before.

    So in other words if I insert 5 records in the table I get the sequence 1-5, great! Then I delete the table and would like to raise again 1. obviously due to the method im using the sequence has been updated to obtain the next available number.

    How can I do an auto increment, which always starts from 1 in a table is a solid solution here?

    MySQL is a column of a simple table setting.

    Thanks in advance for any help you guys can provide.

    Miguel

    Here is the answer to my problem.

    UPDATE fvaljor

    SET FVALJOR_SEQ_NUM = ROWNUM

    WHERE FVALJOR_SEQ_NUM IS NULL

    Thank you Paul for trying to help.

    Is not to see that is a report on inserting records in a process already takes that awaits this column be numbered sequentially upwards by one. So I guess the business reason, it's simply that I have to do if I want to plug into this process.

    Thanks anyway, sorry if I wasn't clear.

    Miguel

  • auto increment column

    Hello

    I have a total of 700 tables, each table has a column that must be incremented automatically.

    I am thinking to create distinct sequences and triggers for all tables.

    Is there a different approach that could be followed or sequence-trigger is the best option available.


    * This database has been migrated from MySQL where auto-increment option is available for columns contrary to oracle.

    Please notify.

    Salman Qureshi says:

    So I want to generate a trigger too.

    Still not clear what triggers have to do with the automatic generation of the column values. You will probably have to ask them about the details of trigegrs self-generation of values? If you just need automatic generation of values, sequences are what you need.

    Salman

    Using a trigger to fill the column ID with the value of the sequence, you don't have to worry about the application 'forget' to do. Some DBA or developer is once of sqlplus and forget to do. Placing him in a trigger, there is simply no way to properly fill the column in question.

  • Auto increment in a MySQL table programmatically

    Hello!

    I use the database connectivity Toolkit to perform various tasks with my MySQL database.

    I am successfully able to create tables, save data, display data, etc. - no problems.

    However, there is something I have to do when creating a table that left me speechless. I need a column in one of my paintings to be autoincremented (Ie, no duplicates).

    It is possible to define this through a program such as MySQL Workbench, but it is not possible to do through LabVIEW.

    Is it possible through LabVIEW? And if so, how? Maybe it's a setting I'm missing or should I send a query using one of the functions in the box tools?

    If you need more info just ask.

    Thanks in advance.

    I have no specific experience with MySQL, but as a general rule, when inserting into a table with auto-increment columns, the insert query does NOT include this column, its value is determined automatically.

    If you are talking about creating a table with an auto-inc column, then I suppose that you use the create table VI. If you open the VI, you will see that it simply creates a SQL query. Search the relevant SQL syntax to do an auto-inc column and then create a copy of the VI and change it to you to specify the column using this syntax.

Maybe you are looking for

  • Is it possible for my daughter maintain its programme of Photos on its 3 t Time Capsule? It happened to wide to keep on his Mac laptop.

    My daughter is running out of room on his Mac laptop to store his photos. She still uses iPhotos, so I have him asked to look at pictures. However, we also tried dragging his case iPhotos to 3t Time Capsule that we arrived to appear on his desk. It w

  • HP Pav p6-2007nl desktop PC: why its port DVI says "do not remove"?

    Hello, my name is Alex from Holland and I have another novice question, but I hope this helps someone else in novice like me! I have the computer mentioned in the title and I want to use a DVI monitor only. According to the specification on the Inter

  • fake email from Microsoft or real?

    I need to know if a message I received is from Microsoft. It says to download an update for Microsoft Office Starter 2010 - English 'which is now available online', or it is just a scam of fake fishing?

  • Messages to organize blackBerry Smartphones

    I have two email accounts on my 8350i and cannot find a way to separate the messages.  Currently, all e-mail messages, telephone calls and direct links are listed when I click on the messages icon.  Is there a way to only show as my main e-mail messa

  • Cannot add cluster hosts

    I'm done with this...It started when I had to change my non routable IP addresses management network to my private IP addresses.  I kept getting errors with the host, not the new IP address.  I solved this problem, but now when I try to add the hosts