Inserting sequence value in a created column already table having some rows

i have a table emp whish has already having rows in that table
now i added one more column to that table with alter command and also i created sequence
now i want to insert the value in that newly created column with sequencename.nextval??????

insert into employees values (employees_seq.nextval);
commit;
Here employees_seq is the name of the sequence.
Regards
Asif Kabir
17 (17 unresolved)
-- Mark your answer as correct/helpful
Edited by: asifkabirdba on Dec 22, 2009 3:39 PM

Similar Messages

  • Inserting sequence value from JDBC and getting the same value back

    Hi: Gurus I have a table whose primary key is a sequence. I wonder how to make sure I get the same sequence value back for current transaction so I update the other table whose foreign key is the sequence value from first table.
    E.g lets say I do this
    String query_insert = INSERT INTO table1 (column1, ....) VALUES (HIGHLIGHT_ID_SEQ.nextval, ...);
    pstmt = con.prepareStatement(query_insert);
    pstmt.executeUpdate();
    How I make sure no other transaction update the sequence value so I can read the last inserted sequence value and update the second table with this value
    String query_select = "SELECT HIGHLIGHT_ID_SEQ.currval FROM DUAL";
    pstmt = con.prepareStatement(query_select);
    Regards,
    Rashid.

    <rant>No version again. I wonder why people requiring help want to stay anonymous and never want to type their version, only 4 digits. In this case, jdbc, not only the version of the driver is important, but also it's type. Waving a magic wand again? </rant>
    Look up the returning into clause of the insert statement in the sql reference manual for your version.
    Sybrand Bakker
    Senior Oracle DBA

  • Cannot solve ORA-30756 "cannot create column or table of type that..."

    Hi there!
    I'm working on some excersises for the university but just can't get rid of this error.
    First, here's my SQL:
    [http://pastebin.com/f1266a668]
    And here is what I get:
    TYPE "LieferserviceTyp" Kompiliert.
    TYPE "ArtikelTyp" Kompiliert.
    TYPE "LebensmittelTyp" Kompiliert.
    TYPE "HaushaltswarenTyp" Kompiliert.
    TYPE "ArtikelInArtKombiTyp" Kompiliert.
    TYPE "ArtikelKombiTyp" Kompiliert.
    TYPE "ArtikelInKatalogTyp" Kompiliert.
    TYPE "KatalogTyp" Kompiliert.
    Fehler beim Start in Zeile 60 in Befehl:
    CREATE TABLE "Artikel" OF "ArtikelTyp" (
    PRIMARY KEY("artnr")
    Fehler bei Befehlszeile:60 Spalte:0
    Fehlerbericht:
    SQL-Fehler: ORA-30756: Spalte oder Tabelle mit einem Objekttyp, der ein Supertyp-Attribut enthält, kann nicht erstellt werden
    30756. 00000 - "cannot create column or table of type that contains a supertype attribute"
    *Cause:    The user tried to create a column or table of an object type that
    contains a supertype attribute. This is not supported because
    it leads to infinite recursion in our current storage model.
    Note that creating a column of a type implies that we
    create columns corresponding to all subtype attributes as well.
    *Action:   Change the type definition to contain a supertype REF attribute
    instead of the supertype object attribute.
    Fehler beim Start in Zeile 67 in Befehl:
    CREATE TABLE "Kataloge" OF "KatalogTyp" (
    PRIMARY KEY("katalog_id")
    Fehler bei Befehlszeile:67 Spalte:0
    Fehlerbericht:
    SQL-Fehler: ORA-30756: Spalte oder Tabelle mit einem Objekttyp, der ein Supertyp-Attribut enthält, kann nicht erstellt werden
    30756. 00000 - "cannot create column or table of type that contains a supertype attribute"
    *Cause:    The user tried to create a column or table of an object type that
    contains a supertype attribute. This is not supported because
    it leads to infinite recursion in our current storage model.
    Note that creating a column of a type implies that we
    create columns corresponding to all subtype attributes as well.
    *Action:   Change the type definition to contain a supertype REF attribute
    instead of the supertype object attribute.
    Fehler beim Start in Zeile 76 in Befehl:
    DROP TABLE "Artikel"
    Fehlerbericht:
    SQL-Fehler: ORA-00942: Tabelle oder View nicht vorhanden
    00942. 00000 - "table or view does not exist"
    *Cause:   
    *Action:
    Fehler beim Start in Zeile 77 in Befehl:
    DROP TABLE "Kataloge"
    Fehlerbericht:
    SQL-Fehler: ORA-00942: Tabelle oder View nicht vorhanden
    00942. 00000 - "table or view does not exist"
    *Cause:   
    *Action:
    DROP TYPE "KatalogTyp" erfolgreich.
    DROP TYPE "ArtikelInKatalogTyp" erfolgreich.
    DROP TYPE "ArtikelKombiTyp" erfolgreich.
    DROP TYPE "ArtikelInArtKombiTyp" erfolgreich.
    DROP TYPE "HaushaltswarenTyp" erfolgreich.
    DROP TYPE "LebensmittelTyp" erfolgreich.
    DROP TYPE "ArtikelTyp" erfolgreich.
    DROP TYPE "LieferserviceTyp" erfolgreich.
    The comments are in german but the structure should be clear I think.
    Any help appreciated!

    Unfortunately it's a bad idea to store your code samples (or screenshots or whatever) on an external site, because not everybody can get access to such sites, especially if their workplace has limitations on websites that can be visited.
    you're pastebin.com is one such site that I cannot access, so I can't see your code.
    If you want to paste code and/or data on the forums remember to put the tag: {noformat}{noformat} before _and_ after it, so that the formatting is maintained and it's easier for us to read.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Create an internal table with the rows of another internal table.

    Hi I want to know if posible to create an internal table structure with the  rows of another internal table?
    ex.
    If in i_tab column A has this values: row 1 = first, row 2 = second, row 3 = third.
    Now I want that the structure of my internal table be: first, second, third

    Hi,
    If you do this way then what will be the difference between the two table anyway?? First internal table has the same structure irrespective of which row you select. and you are going to store the data from each row to the rows of the second internal table. In that case, the structure of the internal table is the same as first table. and it would have same rows.
    Am I missing something here? or you want to declare the internal table with each field being the structure of the first table? In this case you'd have to do a dynamic declaration of data as the first table can have any no of rows then the second table would have any no of fields in the structure.
    Now if you know that your first internal table is going to have a fixed no of rows eg 3 rows then it becomes simple. Do the following then
    Data: begin of second_table occurs 0,
    first type <first_table type>,
    second type <first_table type>,
    third type <first_table type>,
    end of second_table.
    Regards
    Prasenjit

  • Adding column in table having millions of records

    Hi,
    Oracle release :11.2.0.3
    Table A exists with millions of records. - has many indexes on it.
    Need to add one column which exists in table B with same no of records.
    Rowid is common join condition between table A and B to update this new column in A.
    Please advice the fastest way to update this column.
    Explain plan output for update query is :
    | Id  | Operation                                                   | Name                  | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | UPDATE STATEMENT                             |                       |   181M|  3287M|    95T  (1)|999:59:59 |
    |   1 |  UPDATE                                                | A                     |       |       |            |          |
    |   2 |   PX COORDINATOR                                |                       |       |       |            |          |
    |   3 |    PX SEND QC (RANDOM)                       | :TQ10000              |   181M|  3287M|   205K  (2)| 00:47:58 |
    |   4 |     PX BLOCK ITERATOR                           |                       |   181M|  3287M|   205K  (2)| 00:47:58 |
    |   5 |      TABLE ACCESS FULL                         | A                 |   181M|  3287M|   205K  (2)| 00:47:58 |
    PLAN_TABLE_OUTPUT
    |*  6 |   FILTER                                                    |                       |       |       |            |          |
    |*  7 |    TABLE ACCESS BY INDEX ROWID          | B        |   301K|    15M|   528K  (1)| 02:03:24 |
    |*  8 |     INDEX RANGE SCAN                              | SYS_C0073404          |    30M|       | 31081   (1)| 00:07:16 |
    Thanks in advance

    create table new_A as select *.A ,column_in_B from A,B where A.row_id=B.row_id;
    drop table A;
    rename new_A to A;
    No - that can't be right.
    You need to access the ROWID of table A; not some column in table A that is named 'row_id'. And that assumes, as PaulHorth asked, that table B DOES have a column named 'row_id' that contains the ROWID values of table A.
    Also you only posted the plan for the update statement: post the actual query that plan is based on.
    create table emp_rowid as
    select 'new_' || e.ename new_ename, e.rowid row_id from emp e
    where deptno = 20
    update /*+parallel (4) */ emp e
    set ename = (select new_ename from emp_rowid er
             where er.row_id = e.rowid)
    where rowid in (select row_id from emp_rowid)        
    select * from table(dbms_xplan.display_cursor())

  • How to get the rows from a table having some column has any letter

    Hi All,
    suppose i have a table having columns id(number), code(varchar).
    code has alphanumeric characters (ex. ABC123, 67B56 etc).
    some codes are only numbers (2344, 7898 etc).
    how can i get the rows which have alphabets in the code.
    ex:
    id code
    1 AB45
    2 456
    3 890
    4 67B7
    how can i write a query such that it should give me the ids 1 and 4 (as they have alphabets in code)
    thanks in advance to all

    Thanks to one and all.
    i am gettig my required output.
    But i have a doubt in the operator.
    If i add or remove '[]' in the operator, i am getting different ouputs.
    There is a count difference in the result of the operators used.
    REGEXP_LIKE(<column>,'[[:lower:]]')
    REGEXP_LIKE(<column>,'[[[:lower:]]]')
    REGEXP_LIKE(<column>,'[:lower:]')
    Can anybody please explain what is the difference in using '[]', in the operator?
    What is the correct syntax, whether i have to use two '[]'s or one '[]'.
    Also, can i use REGEXP_LIKE() in oracle 8i version.( I am unable to use the operator in 8i)?
    Any query to get the required output in 8i version?
    Thanks in advance to all.

  • Insert sysdate value to date type column in DB

    Hi All
    I need you help. How to set Last_Update_Date to a default date in sql… For example when a user runs the query, the query show display only those values which got changed as of that day’s date. For Example. If I run the query on May 22nd the query show display only that data which got last updated on May 22nd.Can we use INSER INTO. If so ow to insert Last_update_date = sysdate in the below query.
    select hzp.creation_date,fnd.user_id,hzp.party_id,fnd.user_name,
    hzp.person_first_name,hzp.person_last_name,hzl.address2,hzl.address3,hzl.city,
    hzl.postal_code,hzl.state,hzp.last_update_date,frt.responsibility_name
    from APPLSYS.fnd_responsibility_tl frt,APPS.fnd_user_resp_groups fur,
    APPLSYS.fnd_user fnd,AR.hz_parties hzp,AR.hz_party_sites hzps,AR.hz_locations hzl
    where fnd.user_id = fur.user_id
    and fur.responsibility_id = frt.responsibility_id
    and hzp.party_id = fnd.person_party_id
    and hzp.party_id = hzps.party_id
    and hzps.location_id = hzl.location_id
    and last_updated_date = ''
    Regards

    To have last_update_date automatically filled in, your best option is to create a trigger on the table that sets that field to sysdate every time any other field in the row is updated.
    Something like this:
    TRIGGER "TRIGGERNAME" AFTER INSERT OR UPDATE ON FIELD ON "TABLENAME" FOR EACH ROW
    BEGIN
    IF :new.FIELD_NAME IS NULL THEN
    SELECT SYSDATE INTO :new.FIELD_NAME FROM DUAL;
    END IF;
    END;
    To query off that field, you probably want to use trunc(last_update_date)=trunc(sysdate) which causes Oracle to basically ignore the time and only look at the date.

  • Creating Column in table or use Foreign Key

    I have a bunch of tables that are year specific, so I need to store the year in the record. I'm not sure if I should create a column in each table called 'year' or create a master 'Year' table and use a foreign key to it in all my other tables. Any advice?
    PK_ID NUMBER Constraint pk1
    PRIMARY KEY
    YEAR VARCHAR2(4)
    --- or----
    PK_ID NUMBER Constraint pk1
    PRIMARY KEY
    FK_YEAR NUMBER Constraint fk_year
    REFERENCES year_table(PK_ID)

    Does your "year" entity have any attributes ?
    Why do you have a year, which to most people seems to be a number, stored as a varchar2(4) ? And what are you going to do about the Y10K problem ?
    How about making the ID of year the numeric value of the year you are storing - then you have eat your cake and have it ;)
    Seriously, though, why do you want a table to say that the year 2008 is the year identified by a meaningless unique number ?
    Regards
    Jonathan Lewis
    http:/jonathanlewis.wordpress.com
    http://www.jlcomp.demon.co.uk

  • How to insert a local member in a column between two different nested row dimensions

    Hi Experts,
    We have a report which has two dimensions in rows with nesting. The dimensions are PROGRAMS and ACCOUNT.
    I have attached the layout of the report.
    We need to have a column for local member in between Col A and Col B, wherein we have to pull the long description of the program.
    We have long description of programs maintained in a property of PROGRAM dimension
    So if we can insert a column between Col A and Col B, we can have a local member in it with formula "EPMMemberProperty" refering to Col A
    Currently we are are not able to insert a local member in between Col A and Col B in EPM 10 SP 14 version because its not a data range
    I remember we used to do it in BPC 7.5 using expansion ranges to insert a blank column. So I believe similiar thing can be done in EPM 10
    I have tried the option of VBA macro to insert a column before Col A and populate the long description and then hide Col A. It works. But I dont want to complicate it with Macro, and want to use EPM functionality to achieve the same.
    Please advise if this is possible with BPC 10 to have a column for local member in between Col A and Col B.
    Thanks a lot in advance.
    Regards,
    Shiva

    Hi Sathish,
    Thanks a lot for replying. Since I had to insert the local member in between two dimensions, I couldnt use the position option in the local members. Because positions were staring from the data range.
    How ever I have tried the suggestion given by Varaprasad and Bishwajith above and it worked.
    Thanks,
    Shiva

  • Get the single signon userid to use as a default value to populate a column in table

    I created a form that has fields which are to be populated with a default value.
    I am able to use 'sysdate' function (in formatting and validation options page
    of form creation wizard) to populate a date field with current date. I used
    the function 'user' and get the oracle userid (This seems like the userid that
    the portal uses to log into the oracle database schema). However, I want to
    use the single sign on userid that I use to log into the portal application as
    the default value. Is there a way to do that?
    Thanks,
    Karuna

    Found the answer on this site. Use portal.wwctx_api.get_user
    Karuna

  • Create a new table using repeating rows

    Hi all,
    My team members are entering data into the below shortened table.
    I want to import this table to my model (a different excel file), but I need to manipulate the data in order to use it.
    The team members table (MaterialTypeTbl) looks like:
    For every Material Type (column B) they enter all the suppliers that can work with us. Suppliers are split by *.
    [Note: the * is a symbol I requested them to use, because supplier names can contain commas (which was my preferred option) and I thought that it can create confusion when extracted by query formulas. So basically you can change the * to anything that
    can promote the solution]
    My ideal new table will look like:
    Which is repeating the row, as the number of suppliers that we have in the "supplier" cell.
    <gs class="GINGER_SOFTWARE_mark" ginger_software_uiphraseguid="0f146976-cd66-42bf-a9a9-efb81fa43ab7" id="61366336-c5f8-402a-877c-9c08b112bd3d">i.e.</gs>: material 1 (Metal) had 3 suppliers, so in the new table I
    have 3 rows with only one name in each "supplier" cell.
    The purpose is to later on use the new table for pivots.
    The source table can have more columns + I need to have the data about the extracted file (file name, item name, date modified, date created, date accessed)
    I have a folder which contains several files like this (with one sheet and one table in the same format as the other) and I need to extract all and consolidate to one table in my power pivot model with the desired formation.
    Appreciate any help!
    עמית

    It looks as if anything can go wrong- it will :)
    <gs class="GINGER_SOFTWARE_mark" ginger_software_uiphraseguid="bf577f31-b5b2-4e33-8295-b503a9a6b597" id="31c7f26a-d1ac-4302-ab8a-934ec6378fda">let</gs>
        Source = Folder.Files("C:\Users\amendels\Desktop\MI Data Warehouse\Material Type"),
        #"Removed Other Columns" = Table<gs class="GINGER_SOFTWARE_mark" ginger_software_uiphraseguid="d16c857e-92ce-49fd-b50d-234fb6306a78" id="00650cfc-ee61-400b-bce8-93f3d08e806c">.</gs><gs class="GINGER_SOFTWARE_mark"
    ginger_software_uiphraseguid="d16c857e-92ce-49fd-b50d-234fb6306a78" id="05a88f4a-cc9a-412e-839a-a3eee9793fc0">SelectColumns</gs><gs class="GINGER_SOFTWARE_mark" ginger_software_uiphraseguid="d16c857e-92ce-49fd-b50d-234fb6306a78"
    id="ec79ede6-2a0b-449d-8733-e8b743d0ca0b">(</gs>Source<gs class="GINGER_SOFTWARE_mark" ginger_software_uiphraseguid="d16c857e-92ce-49fd-b50d-234fb6306a78" id="833506c2-9e6b-4877-85db-e59e0106a415">,</gs>{"Name",
    "Folder Path"}),
        #"Merged Columns" = Table<gs class="GINGER_SOFTWARE_mark" ginger_software_uiphraseguid="37c10c24-bce5-4d43-835c-46ed9cf2d5ed" id="19ec4b4d-02d5-4779-b1d8-70e054a55169">.</gs><gs class="GINGER_SOFTWARE_mark"
    ginger_software_uiphraseguid="37c10c24-bce5-4d43-835c-46ed9cf2d5ed" id="75be0e50-829a-44f8-bce0-c5c650ef25b1">CombineColumns</gs><gs class="GINGER_SOFTWARE_mark" ginger_software_uiphraseguid="37c10c24-bce5-4d43-835c-46ed9cf2d5ed"
    id="4c6d962d-3323-4a2d-af5d-deb764c514cd">(</gs>#"Removed Other Columns"<gs class="GINGER_SOFTWARE_mark" ginger_software_uiphraseguid="37c10c24-bce5-4d43-835c-46ed9cf2d5ed" id="3946184a-730d-40e8-91ea-fd2d81275202">,</gs>{"Folder
    Path", "Name"}<gs class="GINGER_SOFTWARE_mark" ginger_software_uiphraseguid="37c10c24-bce5-4d43-835c-46ed9cf2d5ed" id="c6268911-7d6e-43c5-8814-bad897f5a05a">,</gs>Combiner<gs class="GINGER_SOFTWARE_mark"
    ginger_software_uiphraseguid="37c10c24-bce5-4d43-835c-46ed9cf2d5ed" id="dccb45ac-42e5-4a27-a150-c7d78d286814">.</gs>CombineTextByDelimiter<gs class="GINGER_SOFTWARE_mark" ginger_software_uiphraseguid="37c10c24-bce5-4d43-835c-46ed9cf2d5ed"
    id="edb72e5c-842a-4887-be04-b12fea521766">(</gs>"", QuoteStyle<gs class="GINGER_SOFTWARE_mark" ginger_software_uiphraseguid="37c10c24-bce5-4d43-835c-46ed9cf2d5ed" id="0ab10849-2fe6-4841-a97a-84732c546fc2">.</gs>None),"path"),
        #"Added Custom" = Table<gs class="GINGER_SOFTWARE_mark" ginger_software_uiphraseguid="230c9450-a9fa-4694-ba10-df8a0eefbcfa" id="f66eebe2-c524-4cee-91df-e08bd9441bd0">.</gs>AddColumn<gs class="GINGER_SOFTWARE_mark"
    ginger_software_uiphraseguid="230c9450-a9fa-4694-ba10-df8a0eefbcfa" id="2661e215-822d-4461-ae1a-38ddaffdcfc2">(</gs>#"Merged Columns", "Custom", each <gs class="GINGER_SOFTWARE_mark" ginger_software_uiphraseguid="230c9450-a9fa-4694-ba10-df8a0eefbcfa"
    id="c471a6f8-de61-44ec-a4eb-4fe5879b86b3">getWorkbook</gs><gs class="GINGER_SOFTWARE_mark" ginger_software_uiphraseguid="230c9450-a9fa-4694-ba10-df8a0eefbcfa" id="beb17741-a1bd-45ee-8770-667b6a429b31">(</gs>[path])),
        #"Expand Custom" = Table<gs class="GINGER_SOFTWARE_mark" ginger_software_uiphraseguid="7656e752-6806-471e-aac1-aca2acc34672" id="6ab7b6f5-e01e-4969-8f22-ec937a2e8f68">.</gs>ExpandTableColumn<gs
    class="GINGER_SOFTWARE_mark" ginger_software_uiphraseguid="7656e752-6806-471e-aac1-aca2acc34672" id="064c2ab1-0322-4b2d-9734-86b2fca4d3dd">(</gs>#"Added Custom", "Custom", {"Column1", "Column2",
    "Column3", "Column4", "Column5", "Column6", "Column7", "Column8", "Column9", "Column10", "Column11", "Column12"}, {"Column1", "Column2",
    "Column3", "Column4", "Column5", "Column6", "Column7", "Column8", "Column9", "Column10", "Column11", "Column12"}),
        #"Removed Columns" = Table<gs class="GINGER_SOFTWARE_mark" ginger_software_uiphraseguid="73ce11cc-0be6-423c-9cd7-996ab0d86c3e" id="875308f8-4505-42bc-bcc4-be136c0d8b99">.</gs><gs class="GINGER_SOFTWARE_mark"
    ginger_software_uiphraseguid="73ce11cc-0be6-423c-9cd7-996ab0d86c3e" id="43a91980-9dd1-40da-84d4-4c2700db63ed">RemoveColumns</gs><gs class="GINGER_SOFTWARE_mark" ginger_software_uiphraseguid="73ce11cc-0be6-423c-9cd7-996ab0d86c3e"
    id="d8ecfee3-de63-4dd9-a916-ebdc7ab155f3">(</gs>#"Expand Custom"<gs class="GINGER_SOFTWARE_mark" ginger_software_uiphraseguid="73ce11cc-0be6-423c-9cd7-996ab0d86c3e" id="70479dcb-a6a3-44ac-a329-476bd6c2f216">,</gs>{"path"}),
        #"Removed Duplicates" = Table<gs class="GINGER_SOFTWARE_mark" ginger_software_uiphraseguid="42c1a334-cff4-432d-8d41-237fbb6cfa2b" id="4efdfd6c-b953-46bd-a673-d9f93ed4fb64">.</gs>Distinct<gs
    class="GINGER_SOFTWARE_mark" ginger_software_uiphraseguid="42c1a334-cff4-432d-8d41-237fbb6cfa2b" id="4108b4fd-3cbb-44ff-8f51-3e2f51e9b1e5">(</gs>#"Removed Columns", {"Column1"}),
        #"First Row as Header" = Table<gs class="GINGER_SOFTWARE_mark" ginger_software_uiphraseguid="e97a3de6-d2de-4872-b8f1-7b26dbacacae" id="9b321e4e-0fbb-40be-9953-5918b7b2c363">.</gs>PromoteHeaders<gs
    class="GINGER_SOFTWARE_mark" ginger_software_uiphraseguid="e97a3de6-d2de-4872-b8f1-7b26dbacacae" id="c566d7bd-ca67-457e-9698-dcaf9cf7ef90">(</gs>#"Removed Duplicates")
    <gs class="GINGER_SOFTWARE_mark" ginger_software_uiphraseguid="7344bfb8-a967-407a-8229-646035c0264c" id="2719b7a9-2b95-4862-8054-67f5da25353a">in</gs>
        #"First Row as Header"

  • Create a new table by joining rows of a given table

    Table1 (id, value1, value2)
    id value1 value2
    1 23 45
    2 34 54
    3 11 09
    new table (id, table1.id, table1.id, product)
    In other words I am trying to pair up rows in table1 and a new field and form the new table.
    How do I do this ?

    Hi,
    try something like this,
    -- untested
    CREATE TABLE T1 AS
    (SELECT id fld1, table1.id fld2, table1.id fld3, product fld4 FROM TABLE1);
    Thanks

  • Best way to fill a table where some row will already exist

    I have a table of 100,000 Books
    I have a Set 'Books' of 1000 Book Objects. (many of which will already exist in the table)
    I want to add the books not already in the table, I can see a few ways to do this but not sure which is the most efficient.
    A)
    Get a ResultSet from the DB matching a 'SELECT' matching the Books in my Set.
    iterate through ResultSet, removing Books in the Set, leaving the Set containing only Books not in the Table.
    Add all books in Set to Table.
    B)
    Iterate through my Set of Books and add all of my books to the Table in turn
    any Books already in the Table already existing will throw an exception
    Ignore the exception
    C)
    Iterate through my Set of Books and check if each is in the Table
    If already in Table go on to next Book
    otherwise add to Table

    Try it both ways, and see which takes longer.
    Of course once you've done that, you don't need to know because the task is complete. But the information might be useful for the next time.

  • Inserting oracle sequence values

    hI
    Do i need to do a select sequence.nextval from dual
    before i insert the next sequence value into the table
    For eg i tried using the foll insert statement but i get an invalid number exception
    insert into parts(PARTS'DATABASE.PARTNOSEQ.NEXTVAL',"+PARTNO+")
    But i get the above exception.I dont do a select now.
    Thanks
    Arn

    Hi
    I tried doing the following trying to insert sequence values but I still get an invalid get Column error.
    sql4 = "select PART_SEQ.NEXTVAL FROM DUAL";
    ResultSet rs3 = stmt2.executeQuery(sql4);
    while (rs3.next())
    seqVal = rs.getInt("PART_SEQ");
    rs3.close();
    for(int i=0; i<=count; i++)
    { // for loop
         sql3 = "Update part " +
         " SET part_mfr = '"+mfgcodeStr+"' ,
         " part_id = "+seqVal+"," +
         " WHERE invoiceno = '"+invoicenoStr+"' ";
    Thanks
    arn

  • Inserting values from a cursor to a table

    Hi,
    I need to insert the values from a cursor into a table,this i the part of code which trieds to do it...i get error stating "select stmt missing"...pls help out...
    OPEN  p_cursor for V_SQLSTATEMENT;
            ---for i in p_cursor
            LOOP
              FETCH p_cursor INTO v_cursor_type;      
              insert into TEMPCHARTVALUES(HOP,AMOUNT,EFFECTIVE_FROM,EFFECTIVE_TO,CURRENCY)
                   values (v_cursor_type.PMC1_HOP_CODE,
                         v_cursor_type.PMC1_Amount,
                         v_cursor_type.PMC1_EFFECTIVE_FROM,
                         v_cursor_type.PMC1_EFFECTIVE_UPTO,
                         v_cursor_type.PMC1_CURRENCY);
                                                           --dbms_output.put_line(v_cursor_type.KEYCODE1);
              EXIT WHEN p_cursor%ROWCOUNT = v_REC_COUNT;
              end loop;

    Hi, here it is..
    create or replace
    procedure  prm_sp_charts_db (P_CURSOR OUT SYS_REFCURSOR,CHARTCode VARCHAR,tablename varchar)
    IS
    v_COUNT varchar2(200);
    v_REC_COUNT NUMBER;
    V_SQLSTATEMENT VARCHAR2(2000);
    v_cursor_type  TEMPCHARTVALUES%ROWTYPE;
        begin
         v_COUNT:='SELECT COUNT(*) FROM PRM_M_Chart_' || CHARTCode;
         execute immediate v_COUNT into v_REC_COUNT;
         V_SQLSTATEMENT := 'SELECT ';
         V_SQLSTATEMENT := V_SQLSTATEMENT || 'PMC' || CHARTCode || '_F1_CODE Keycode1,';
          open  P_CURSOR for select column_name from  user_tab_columns where table_name=tablename and column_name='PMC' || CHARTCode || '_F2_CODE';
          IF P_CURSOR%FOUND then
          V_SQLSTATEMENT := V_SQLSTATEMENT || 'PMC' || CHARTCode || '_F2_CODE Keycode2,';
          else
          V_SQLSTATEMENT := V_SQLSTATEMENT || '0,';
          END IF;
          open  P_CURSOR for select column_name from  user_tab_columns where table_name=tablename and column_name='PMC' || CHARTCode || '_F3_CODE';
          IF P_CURSOR%FOUND then
          V_SQLSTATEMENT := V_SQLSTATEMENT || 'PMC' || CHARTCode || '_F3_CODE Keycode3,';
          else
          V_SQLSTATEMENT := V_SQLSTATEMENT || '0,';
          END IF;
           open  P_CURSOR for select column_name from  user_tab_columns where table_name=tablename and column_name='PMC' || CHARTCode || '_F4_CODE';
          IF P_CURSOR%FOUND then
          V_SQLSTATEMENT := V_SQLSTATEMENT || 'PMC' || CHARTCode || '_F4_CODE Keycode4,';
          else
          V_SQLSTATEMENT := V_SQLSTATEMENT || '0,';
          END IF;
          open  P_CURSOR for select column_name from  user_tab_columns where table_name=tablename and column_name='PMC' || CHARTCode || '_F5_CODE';
          IF P_CURSOR%FOUND then
          V_SQLSTATEMENT := V_SQLSTATEMENT || 'PMC' || CHARTCode || '_F5_CODE Keycode5,';
          else
          V_SQLSTATEMENT := V_SQLSTATEMENT || '0,';
          END IF;
          --open  P_CURSOR for select column_name from  user_tab_columns where table_name=tablename and column_name='PMC' || CHARTCode || '_F6_CODE';
          IF P_CURSOR%FOUND then
          V_SQLSTATEMENT := V_SQLSTATEMENT || 'PMC' || CHARTCode || '_F6_CODE Keycode6,';
          else
          V_SQLSTATEMENT := V_SQLSTATEMENT || '0,';
          END IF;
          --open  P_CURSOR for select column_name from  user_tab_columns where table_name=tablename and column_name='PMC' || CHARTCode || '_F7_CODE';
          IF P_CURSOR%FOUND then
          V_SQLSTATEMENT := V_SQLSTATEMENT || 'PMC' || CHARTCode || '_F7_CODE Keycode7,';
          else
          V_SQLSTATEMENT := V_SQLSTATEMENT || '0,';
          END IF;
          --open  P_CURSOR for select column_name from  user_tab_columns where table_name=tablename and column_name='PMC' || CHARTCode || '_F8_CODE';
          IF P_CURSOR%FOUND then
          V_SQLSTATEMENT := V_SQLSTATEMENT || 'PMC' || CHARTCode || '_F8_CODE Keycode8,';
          else
          V_SQLSTATEMENT := V_SQLSTATEMENT || '0,';
          END IF;
          --open  P_CURSOR for select column_name from  user_tab_columns where table_name=tablename and column_name='PMC' || CHARTCode || '_F9_CODE';
          IF P_CURSOR%FOUND then
          V_SQLSTATEMENT := V_SQLSTATEMENT || 'PMC' || CHARTCode || '_F9_CODE Keycode9,';
          else
          V_SQLSTATEMENT := V_SQLSTATEMENT || '0,';
          END IF;
          --open  P_CURSOR for select column_name from  user_tab_columns where table_name=tablename and column_name='PMC' || CHARTCode || '_F10_CODE';
          IF P_CURSOR%FOUND then
          V_SQLSTATEMENT := V_SQLSTATEMENT || 'PMC' || CHARTCode || '_F10_CODE Keycode10,';
          else
          V_SQLSTATEMENT := V_SQLSTATEMENT || '0,';
          END IF;
          V_SQLSTATEMENT := V_SQLSTATEMENT ||'PMC' || CHARTCode || '_HOP_CODE HOPCode,PMC' || CHARTCode || '_AMOUNT ,PMC'|| CHARTCode || '_EFFECTIVE_FROM Effective_From,PMC' || CHARTCode || '_EFFECTIVE_UPTO Effective_Upto,PMC' || CHARTCode || '_CURRENCY Currency FROM PRM_M_CHART_' || CHARTCode ;
          DBMS_OUTPUT.PUT_LINE(V_SQLSTATEMENT);
           OPEN  p_cursor for V_SQLSTATEMENT;
            ---for i in p_cursor
            LOOP
              FETCH p_cursor INTO v_cursor_type;      
              insert into TEMPCHARTVALUES(HOP,AMOUNT,EFFECTIVE_FROM,EFFECTIVE_TO,CURRENCY)
                   values (v_cursor_type.PMC1_HOP_CODE,
                         v_cursor_type.PMC1_Amount,
                         v_cursor_type.PMC1_EFFECTIVE_FROM,
                         v_cursor_type.PMC1_EFFECTIVE_UPTO,
                         v_cursor_type.PMC1_CURRENCY);
                                                           --dbms_output.put_line(v_cursor_type.KEYCODE1);
              EXIT WHEN p_cursor%ROWCOUNT = v_REC_COUNT;
              end loop;
    end prm_sp_charts_db;

Maybe you are looking for

  • Mini-DVI out problem

    I recieved my mini-dvi -> dvi apple adaptor from ebay this morning (finally!), but am having a feew teething problems. The plug fits snugly in the back of the iMac, but if pressure( only a little) is applied to the side or top of the plug (the one go

  • IPod mini battery discharges in just 3 days. Is this normal?

    I left my ipod mini off for 3 days and it was completely discharged. This is a new battery. Its as if it doesnt turn off and discharges the battery while not in use. Any ideas? Is this normal?

  • Downloads never finalized, stuck in downloads folder

    To fully diagnose this problem, I will start from the beginning I noticed something a bit 'off' about iTunes. i was browsing the iTunes Store, looking for a good mix of music to buy, adding to the Wish List, blah blah blah. I left the computer runnin

  • Report On Receipt Of materials for a material Group

    Dear All,            I have a requirement. I want the value of goods receipt for a particular material group for a particular period. MB51 does not provide input for material group.           I have seen other standard reports related to purchase , b

  • We need full support for Turkey!

    Hi! I've been wondering about this e-book system of yours. ibooks only displays free stuff which is very limited. I would like to BUY certain books and even tried to switch stores yet it's not doable. Most people on the internet suggests for other co