Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. advanced ADO.NET and Oracle Database

advanced ADO.NET and Oracle Database

Scheduled Pinned Locked Moved Database
databasecsharpsql-serveroraclesysadmin
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    koo9
    wrote on last edited by
    #1

    hi all just wonder if anyone have done any relatively complex project in oracle database. it seems hard to make an app for oracle database using ADO.NET dataset. in my app, I bind all the fields to all kind of controls and there are parent/child tables. so I create datarelations and all that for the datatable in a same dataset. Q1. when inserting new parent/child records, oracle database doesn't support scop_indentity(), how does one get the real id from the database and update the child records before they get inserted into the database? Q2. when adding new child records for existing parent entry, does the datarelation automatically add the parent foreign key into the newly added child record? it seems that's not the case, since it doesn't work for me when I try to add new child record. I posted a similar thread in the ms newsgroup, one of the ms guy showed me some of the sample how things are done in sql server 2000 and access, but not much with oracle. he also mentioned the use of sequence. get the some-sequence.currval to get the real id, but that's not connection oriented, because multiple users might insert record at the same time, how can one guarantee it is the correct id for the record. anyone have any idea? thx:) kevin

    G 1 Reply Last reply
    0
    • K koo9

      hi all just wonder if anyone have done any relatively complex project in oracle database. it seems hard to make an app for oracle database using ADO.NET dataset. in my app, I bind all the fields to all kind of controls and there are parent/child tables. so I create datarelations and all that for the datatable in a same dataset. Q1. when inserting new parent/child records, oracle database doesn't support scop_indentity(), how does one get the real id from the database and update the child records before they get inserted into the database? Q2. when adding new child records for existing parent entry, does the datarelation automatically add the parent foreign key into the newly added child record? it seems that's not the case, since it doesn't work for me when I try to add new child record. I posted a similar thread in the ms newsgroup, one of the ms guy showed me some of the sample how things are done in sql server 2000 and access, but not much with oracle. he also mentioned the use of sequence. get the some-sequence.currval to get the real id, but that's not connection oriented, because multiple users might insert record at the same time, how can one guarantee it is the correct id for the record. anyone have any idea? thx:) kevin

      G Offline
      G Offline
      Guillermo Rivero
      wrote on last edited by
      #2

      Oracle doesn't have autonumeric fields. You can achive a similar behavior with sequences. Sequences guarantee that the number generated is unique. Add a trigger to your table that inserts the sequence value on the table. Free your mind...

      K 1 Reply Last reply
      0
      • G Guillermo Rivero

        Oracle doesn't have autonumeric fields. You can achive a similar behavior with sequences. Sequences guarantee that the number generated is unique. Add a trigger to your table that inserts the sequence value on the table. Free your mind...

        K Offline
        K Offline
        koo9
        wrote on last edited by
        #3

        sorry, Gillermo I am way pass that level, in fact select max(someColumn) + 1 will do. it seems like you misunderstand my question. kevin;)

        M 1 Reply Last reply
        0
        • K koo9

          sorry, Gillermo I am way pass that level, in fact select max(someColumn) + 1 will do. it seems like you misunderstand my question. kevin;)

          M Offline
          M Offline
          Mike Dimmick
          wrote on last edited by
          #4

          I hope you're doing some locking, otherwise you'll get bitten by concurrency bugs. Example: Say the current maximum is n. Client A's connection performs SELECT MAX() + 1, then, before client A's connection performs an INSERT, client B's connection also does SELECT MAX() + 1. Both clients now think that their insert should be numbered n + 1. The second client to INSERT will either cause a unique constraint violation if you've defined that someColumn should be unique, or you'll get two values. SELECT MAX() also causes more work for the database. Instead of looking up and updating a single value, it has to seek through the index every time. (Speaking as someone who's used this technique in SQL Server.)

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups