Autonumeric

Hello they can help me please:
As I can create a field automuneric in a table??
Hola pueden ayudarem porfavor: como puedo crear un campo autonumerico en un campo de una tabla??? , o alguna alternativa para crearlo.

Tienes que crear una secuencia (Oracle no tiene un autonumber como DB2), y despues crea un triger como el siguiente (el triger debe ser para anter de INSERTAR).
val declare mynum;
begin
select <nombre_secuencia>.nextval from dual into mynum;
new.<campoTable> := mynum
end;
checa la sintaxis pero es algo asi

Similar Messages

  • How set or create an autonumeric ID column in access.

    I want to create or set the properties of the column for set an autonumeric id, I have a vi that send data to the DB but I need this column.
    Solved!
    Go to Solution.

    Hi Abraham 
    If you have already the column that you want to be autonumeric, this snippet will help you to do it. It's select the max number on your column and then will plus one. This is a way that you can use. Each time that you need to insert new rows use this code for having an autonumeric column.
    Greetings
    Julio Mena

  • How to insert more than one values

    Oracle 9i
    Hi all
    I have 80 values how to insert it in a single time, it is in production
    This is my insert statement
    Insert into FND_LOOKUP_VALUES
    (LOOKUP_TYPE,LANGUAGE,LOOKUP_CODE,MEANING,DESCRIPTION,ENABLED_FLAG,
    START_DATE_ACTIVE,END_DATE_ACTIVE,CREATED_BY,CREATION_DATE,LAST_UPDATED_BY,L
    AST_UPDATE_LOGIN,
    LAST_UPDATE_DATE,SOURCE_LANG,SECURITY_GROUP_ID,VIEW_APPLICATION_ID,TERRITORY
    _CODE,
    ATTRIBUTE_CATEGORY,ATTRIBUTE1,ATTRIBUTE2,ATTRIBUTE3,ATTRIBUTE4,ATTRIBUTE5,AT
    TRIBUTE6,ATTRIBUTE7,ATTRIBUTE8,ATTRIBUTE9,ATTRIBUTE10,ATTRIBUTE11,ATTRIBUTE1
    2,ATTRIBUTE13,ATTRIBUTE14,ATTRIBUTE15,TAG,LEAF_NODE)
    values ('XXHDNL_SHIPPABLE_POSTCODES','US','CF47 9','CF47 9','CF47 9','Y',
    to_date('23-JUL-09','DD-MON-RR'),null,1090,to_date('23-JUL-09','DD-MON-RR'),
    1090,47626,to_date('23-JUL-09','DD-MON-RR'),'US',0,3,null,null,null,null,nul
    l,null,null,null,null,null,null,null,null,null,null,null,null,null,null);
    I need to change the values in the field LOOKUP_CODE,MEANING,DESCRIPTION
    there are 80 values it takes time to insert one one value each time.
    The values are like this
    DE1,DE1,DE1
    D3,D3,D3
    DE5,DE5,DE5
    DE11,DE11,DE11
    DE12,DE12,DE12
    DE13,DE13DE13
    How to do this?
    Any help is highly appricatble
    Thanks & regards
    Srikkanth.M
    Edited by: Srikkanth.M on Jan 14, 2011 6:04 PM

    If the code is autonumeric ... then try
    insert into FND_LOOKUP_VALUES (LOOKUP_TYPE,
                                                      LANGUAGE,
                                                      LOOKUP_CODE,
                                                      MEANING,
                                                      DESCRIPTION,
                                                      ENABLED_FLAG,
                                                      START_DATE_ACTIVE,
                                                      CREATED_BY,
                                                      CREATION_DATE,
                                                      LAST_UPDATED_BY,
                                                      LAST_UPDATE_LOGIN,
                                                      LAST_UPDATE_DATE,
                                                      SOURCE_LANG,
                                                      SECURITY_GROUP_ID,
                                                      VIEW_APPLICATION_ID                                                 
    SELECT 'XXHDNL_SHIPPABLE_POSTCODES',
               'US',
               'DE' || level,
               'DE' || level,
               'DE' || level,
               'Y',
                to_date('23-JUL-09','DD-MON-RR'),
               1090,
               to_date('23-JUL-09','DD-MON-RR'),
               1090,
               47626,
               to_date('23-JUL-09','DD-MON-RR'),
               'US',
               0,
               3
    from dual connect by level < 81

  • What is the matter in using guids in a smart client against server scenario

    I am developing an application which consists in a smart client against a Server -with oracle db-. We use typed datasets to manage data between them. Our first aproach is using autonumeric, but we have found lot of issues: what happends when the pk comes back changed to the client? and a few more.
    I think guids were invented for this scenario, but i would want to know your opinion about them, specially performance issues.
    Thanks in advance.

    hi,
    A benefit of using OID for names resolution is that it allows you to centralize net8 naming (i.e., tnsnames) information in the same place (OID) where other types of administrative information (about users, enterprise groups, enterprise roles, etc) gets stored. If you are more comfortable using tnsnames.ora files for net8 naming, that is perfectly fine!
    An important reason that Oracle had for providing Net8 naming functionality in OID is that the legacy 'Oracle Names' functionality of Oracle 7 will eventually be desupported. This is discussed in metalink Note #135696.1 on http://metalink.oracle.com .
    Hope this helps.

  • Database insertion problem

    Hello,
    I was wondering how to solve a problem at inserting new rows in a mysql database. I have a table named employees and one named addresses. In order to link an address to an employee I use an address_id at the employee table. Though, the addresses table is also used by so many other tables. The problem is that every time I insert an employee to the database (and therefore an address) I need to know the address_id so that I can insert it into the proper column in the employee row. The address_id is autonumerical. One solution I thought was to query the addresses table before the insertion to get the next address_id. Then use that number in the employees table. Though, I imagine that when the web applications is used by a large number of people at the same time, there are going to be some concurrency problems.
    What can be a better solution?
    Is there a better data model I could use for this matter?
    I hope I made myself clear in my writing,
    Thank you,
    Alfredo Fern�ndez A.

    Typically you do the followng.
    1. Start a transaction.
    2. Insert address - which also returns the id of the insertion.
    3. Insert the employee.
    4. Commit the transaction.
    Step 2 depends on what specific database you are using.
    It can also depends on the business rules for an address.

  • How to get an sql query result to a textbox?

    i am working with jdk1.4 and office 2003.
    i need to run the following SQL Query: "SELECT max(BookId) as BookId FROM Books" where BookId is an autonumeric generated number obtained from the field autonumber in access 2003 database.
    now, the result of this must be placed in a textbox.
    does anyone knows how to do this?
    I ve tried this but nothing happens and niether any error comes
    st = con.createStatement ();     //Creating Statement Object.
    long bookNo;          //Use for Comparing the Book's Id.
    try {     //SELECT Query to Retrieved the Record.
    String q = "SELECT max(BookId) as BookId FROM Books";
    ResultSet rs = st.executeQuery (q);     //Executing the Query.
    bookNo = rs.getLong ("BookId");          //Storing the Record.
    bookNo =(bookNo+1);
    txtBookId.setText (""+bookNo);
    catch (SQLException sqlex) { }
    does anyone knows how to do this?????plz help me out.
    Thanks
    Aanchal

    Hi Aanchal,
    If an SQL error occurs now, you cannot see it in your code. You should do something with the exception you catch, e.g. printing it: sqlex.printStackTrace(), so that you can see if something goes wrong.
    For your number, you should move the cursor in the resultset to the first row - either by: calling first( ) or next ( ), then you can retrieve your booknumber.
    Best Regards,
    Martijn

  • MERGE AGAIN????? PLZ Somebody HELP ME!!!!!

    Hello everyone! I am so angry because of the merge statement!!!!! No one can't tell me what I have to do????
    Guys!!!! I am trying to de a trigger on a TableA that fire when I try to insert data, the trigger the only thing have to do is insert the same data inserted on TableA to the TableB (not all fields), if the the row I want to insert on TableB exist I just update it and increment by 1 a field that represent the amount of rwos I pretended to insert to the TableB with the same unique index of the TableB. I had to say before TableA has a unique index, it is compose for few fields, and the primary key of both tables is an autoincremented field. Here I put an example what I want to do:
    Example:
    This is the data I want to insert on TableA, after insert on TableA
    a trigger will fire, it will merge the data I want to Insert on
    TablaA with The TableB. If I Merge TableA with TableB will show an
    error of duplicated unique index, also an error of mutation. I want
    to do the Merge on TableB Using Each Rows I am inserting trated as
    a table or as a query (the merge sintax says that), but I don't
    know how to do that????
    Primary Key for TableA: IDROW
    Primary Key for TableB: IDROW
    Unique Index TableB: IDMOvil Service Date
    The trigger will result this:
    TableA
    IDRow IDMOvil Service Date Speed Operation
    1 234 A 8/2/2007 15.5 T
    2 234 A 8/2/2007 13.5 T
    3 234 A 8/2/2007 10.5 T
    4 235 A 8/2/2007 15.3 T
    TableB
    IDRow IDMOvil Service Date RowsWithSameUniqueIndex
    1 234 A 8/2/2007 3
    2 235 A 8/2/2007 1

    The TableA has an autonumeric as PK.
    The TableB has an autonumeric as PK.
    The TableB has a Unique Index compuse by some fields of the table except by his PK.
    Remember I do the insert of this way (Multiple insert):
    ------------------ 1st Insert---------------------
    Insert into TableA (Field1, field2, field3, field4)
    Select 'Value1','value2','Value3','Value4'
    Union All Select 'Value1','value2','Value3','Value5'
    Union All Select 'Value1','value2','Value3','Value6'
    Union All Select 'Value6','value2','Value3','Value7'
    I don't know how to fill the example you sent me???? Because I am not doing the Merge with the TableA and tableB.
    I don't think no one have done this before????
    I want to do the Merge with each row I want to insert on the TableA, I don't know what to do that??? I don't know how to obtein the actual row to insert and declare it as a table or a query (example: Select :New.Field1, :New.Field2, :New.Field3, :New.Field4 from Dual) and do the merge with this select and my TableB, but it doesn't work?????
    Forgive me if you can not understand me, ok.
    Thanks for everything,

  • Using get properties VI from database toolkit

    Hello I'm using database toolkit to read and import data from a MySql database.
    I want to read the last row that has been written in a table. I don't know how to do this but i think i can know the number of the last row written using the get properties block.
    But using this VI i have to use execute query block.....and i get an error, i think that the sql query is not defined correctly.
    I have posted a part of my VI where i use this blocks.
    I have two questions: is this the way to read the last row that has been written in  a table of a database??
    The other question is why doesn't run this subVi and what is the correct way to define a SQL query (you have to put the table name, o some other thing)
    Thank you very much
    Larson
    Attachments:
    example.PNG ‏12 KB

    I hate when this happens... if I press TAB + SPACE the message is sent to forum... :-s
    Hi, Larson:
    You can't read "the last row written" in a DataBase, as records are not sorted, by definition. You could have a field in a record that grows every time you insert in a table, like AutoNumeric, or DateTime and then you could know exactly wich record is the last one.
    Once you know how to get "the last row written" you have to translate it to SQL. Provided you have an AutoNumeric field named "IdRow" in your table "TestTable", you could write:
    SELECT * FROM TestTable WHERE IdRow = (MAX(t.IdRow) from TestTable t)
    Now you should build a call to the DataBase.
    First you need ExecuteQuery, as you did use, and SQL Query input should be the like "SELECT * FROM..."
    Second you have to retrieve the data with, for example, "DB Tools Fetch Recordset Data", in DB Palette, next to Execute Query. The output will be a Variant 2D Array that you can convert to anything you want, like String 2D Array, for example using Variant palette functions
    And third you have to close the recordset Reference with "DB Tools Free Object", the rightmost function in the same row as Execute Query.
    And once you have done all, you can close de DataBase.
    Hope it helps,
    Aitortxo.

  • SOS problem using one Entity bean for editing records. please help me

    Hello
    I have one great problem using one entity bean 2.1 and i am working with this problem several days and i dont solve it.
    i am using this jb 2.1 for add new records to one oracle database and for editing records.
    I have one great problem for editing records
    I have one objets that is as one of my database table. (PersonaObj.java)
         //personaObj.java
         public class PersonaObj implements Serializable{
              private Integer id_persona; //this ishte database table autonumeric
              private java.lang.String nombre;
              now the set/get methods.
         One field of this objets (bean) is the primary key of the table, and this field is one part of the pk from the entity bean.
         From one session bean i call the entity bena passing the objet
         into the entity bean (interface) i have one methods:
              public getPersona getT56aaat04();
         public void setPersona(PersonaObj obj);
         into the entitybean bean i have:
         public PersonaEntityPK ejbCreate(PersonaObj obj) throws CreateException {
              this.setT56aaat04(obj);
              public abstract Integer getId_persona();
         public abstract void setId_persona(Integer Id_persona);
         public abstract java.lang.String getNombre();
         public abstract void setNombre(java.lang.String Nombre);
         public PersonaObj getPersona() {
              PersonaObj obj = new PersonaObj();
              obj.setId_persona(getId_persona());
              obj.setNombre(getNombre());
              return obj;
         public void setPersona(PersonaObj obj) {
              setId_persona(obj.getId_persona());
              setNombre(obj.getNombre());
    But i have one graet problem.
    adding new record to the database i runs well but if i want to edit one recor appears this error:
    => Error <=
    java.rmi.RemoteException: EJB Exception: ; nested exception is: javax.ejb.EJBException: EJB Exception: : java.lang.IllegalStateException:[EJB:010144]The setXXX method for a primary key field may only be called during ejbCreate.
    at PersonasEJB_a43o8n__WebLogic_CMP_RDBMS.setId_persona(PersonasEntityEJB_a43o8n__WebLogic_CMP_RDBMS.java:328)
    at PersonasEntityBean.setPersona(PersonasEntityBean.java:114)
    at PersonasEntityEJB_a43o8n_ELOImpl.setPersona(PersonasEntityEJB_a43o8n_ELOImpl.java:45)
    at PersonasSessionBean.editarPersona(PersonasSessionBean.java:849)
    at PersonasSessionBean_bszo9t_EOImpl.editarPersona(PersonasSessionBean_bszo9t_EOImpl.java:208)
    at PersonasSessionBean_bszo9t_EOImpl_WLSkel.invoke(Unknown Source)
    into the session bean i make this (the session recibes one PersonaObj obj):
    T56aContactosEntityLocal personaLocal ;
                   try {
                        personaLocal = personaHome.findByPrimaryKey(new T56aContactosEntityPK(obj.getId_a04()));
                        T56aaat04Obj objTmp = new T56aaat04Obj();
                        objTmp.setAp1_a04(obj.getAp1_a04());
                        objTmp.setEstado_a04("false");
                        personaLocal.setT56aaat04(obj);
    Please can you help me to solve this problem?

    Hello Werner,
    The mappings seem to be alright at a first glance.
    Have you tried out un- and redeploying your application? Sometimes values appear to be cached in the server. So if you have deployed the application before you entered DB_BANK as alias this might solve the problem...
    BR
    Daniel

Maybe you are looking for

  • Calling web service using ksoap2

    Hello Friends, I am writing a Java client which uses ksoap2. I am new to web services and ksoap2. The WSDL is like this <?xml version="1.0" encoding="utf-8"?> <wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tm="http://micro

  • After changing my Apple ID and password, I can no longer sign into iCloud on my iPhone or iPad.  What do I do?

    After successfully changing my Apple ID and password on my MacBookPro, I can no longer connect with iCloud on my iPad2 or iPhone 4.  Both devices have the latest OS updates, although the MBP is 10.5.8.  When attempting to connect with iCloud, Setting

  • Wifi packet loss after upgrading to 10.7.4

    After upgrading all three macs (mb pro, mb air, imac) in the house to 10.7.4 they all experience wifi packet loss.  I ping to the local router.  I have connected to a multitude of wireless routers with similar result. But here is strong evidence that

  • Process not found in Process Repository (Cons) after transport

    Hello everyone, I have a NWDI track with all SC's that I need.  After test all in my DEV system (develop on track, deploy) I tried to transport my escenario : 1. Activities on track, all components and sources are there.  Check In and Activate sucess

  • Data updation in BI

    hi, i have developed a repository after developing cube n dimensions in oracle warehouse builder. Now, i have developed few graphs and pivot tables in bi answers and presented them on BI dashboard. My reports on dashboard contains employees strength