Announcement

Collapse
No announcement yet.

affect some information from one application to another one

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • #16
    ols03,

    Your code as written cannot be safely used in a multi-user environment.

    It has a race condition since you are reading max and then incrementing it. A second user may read the same value, and both try to write max + 1. The first one succeeds, the second one gets an error since the unique field already exists.

    This is the whole purpose for using auto-incement (which happens at the database server).

    If using Auto-Increment, you pass NOTHING for the field during an insert, the database decides what is the next unique number to insert for the index.

    Dave
    Dave Prue
    Code Whisperer
    Lahar International Corp
    www.lahar.net

    Comment


    • #17
      Hello Dave,
      I'm not in multi-user for this application, but your right, i must change that.Capture.JPG
      I try to passing nothing, but SC reject all my INSERT INTO. And in the database the field in auto-increment (see image).
      Do you see an error in the used syntax above?

      Best regards,
      Olivier

      Comment


      • #18
        Olivier,

        Do you get an error if you do this:

        sc_exec_sql("INSERT INTO aff_cde2 (CLIENT,NCDE,RESA,DLIV,CART,CART_SOURCE,AFFINAGE,L OT,STOCK,QTE) values ('[clientcde]',0,'[resacde]','[dlivcde]','[cartcde]','$carts','a','$lots','',[qtecde])");

        If this generates an SQL error then the ID field is probably not set as auto-increment in the database. The picture you are showing is NOT THE DATABASE, it is what scriptcase thinks the database settings are. You need to look at the database itself with a database manager tool ( I use phpMyAdmin for mysql) in order to know if the database has the field flagged as auto-increment.

        Dave
        Dave Prue
        Code Whisperer
        Lahar International Corp
        www.lahar.net

        Comment


        • #19
          Hello Dave;
          I have this error:
          Erreur
          ibase_query(): Dynamic SQL Error SQL error code = -104 Token unknown - line 1, column 73 OT

          Erreur
          Erreur en accédant à la base de données:
          Dynamic SQL Error SQL error code = -104 Token unknown - line 1, column 73 OT
          INSERT INTO aff_cde2 (CLIENT,NCDE,RESA,DLIV,CART,CART_SOURCE,AFFINAGE,L OT,STOCK,QTE) values ('TEST',0,'R','2014-11-14','BS38266C','','a','','',1)

          I use IBexpert for manage my database.
          I can associate generator on a field. I put an image.
          I try to create a new generator, i have the same problem finally.
          Capture.JPG
          Best regards,
          Olivier

          Comment


          • #20
            I'm stupid, i have an error on "L OT" either "LOT".
            But i always have:
            Erreur
            ibase_query(): validation error for column ID, value "*** null ***"

            Erreur
            Erreur en accédant à la base de données:
            validation error for column ID, value "*** null ***"
            INSERT INTO aff_cde2 (CLIENT,NCDE,RESA,DLIV,CART,CART_SOURCE,AFFINAGE,L OT,STOCK,QTE) values ('TEST',0,'R','2014-11-25','BS38504S','','a','','',1)
            I try to modify generator, add a trigger, but nothings happen more.

            Olivier

            Comment

            Working...
            X