Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: seqno vs Auto-Increment

  1. #1
    Senior Member
    Join Date
    Apr 2014
    Posts
    201

    seqno vs Auto-Increment

    What is the difference between these two options and which method is recommended for table ID columns?

  2. #2
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    5,769
    They both provide similar functionality. Seqno() existed before autoinc was added for VFP compatibility.
    Principal developer of Lianja, Recital and other products

    Follow me on:

    Twitter: http://twitter.com/lianjaInc
    Facebook: http://www.facebook.com/LianjaInc
    LinkedIn: http://www.linkedin.com/in/barrymavin

  3. #3
    Senior Member
    Join Date
    Jul 2013
    Location
    Ontario, Canada
    Posts
    658
    Hi alia,

    Keep in mind that you can't use autoinc on virtual tables.
    Also, seqno() is available for Lianja native tables only and is table-based, increasing each time it is called.

    Cory

  4. #4
    Senior Member
    Join Date
    Apr 2014
    Posts
    201
    Hi,

    I ended up using autoinc based on the replies below. Something I have picked up though - in desktop when adding records in a form the autoinc field is populated just fine but in web it is not, is this supported?

  5. #5
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    5,769
    Autoinc happens when you insert a new record on the server. In desktop apps the database engine is embedded. So yes it is handled in the database engine. So therefore it is implemented in the cloud server. It is not client UI functionality.
    Principal developer of Lianja, Recital and other products

    Follow me on:

    Twitter: http://twitter.com/lianjaInc
    Facebook: http://www.facebook.com/LianjaInc
    LinkedIn: http://www.linkedin.com/in/barrymavin

  6. #6
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    5,769
    If you are adding a record and you want an auto generated unique id for a record you would be better off having a server side procedure as the default expression. That server side procedure can use seqno() or guid().

    There is is a functional difference between desktop and web/mobile as the latter are client/server.
    Principal developer of Lianja, Recital and other products

    Follow me on:

    Twitter: http://twitter.com/lianjaInc
    Facebook: http://www.facebook.com/LianjaInc
    LinkedIn: http://www.linkedin.com/in/barrymavin

  7. #7
    Senior Member
    Join Date
    Apr 2014
    Posts
    201
    Ok Barry that makes sense but how do I add a record in a web form using autoinc then?

    After clicking the + button I get this (suppid is autoinc):

    Name:  lianja.webadd.jpg
Views: 68
Size:  10.8 KB


    I leave suppid empty because this will get populated on the server-side, click save and I get this:

    Name:  lianja.webadd2.jpg
Views: 66
Size:  20.4 KB

    I even tried manually typing in the next autoinc suppid value just for kicks but that gives the same result. In desktop everything works as expected.

  8. #8
    Senior Member
    Join Date
    Apr 2014
    Posts
    201
    We have a timing problem here as my reply was actually to your previous post .

    Ok IIUC the short answer to "autoinc vs seqno" is that they are same...but only for desktop, for web I need to use seqno or similar?

  9. #9
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    5,769
    Yes. Developing for client/server is mainly done for you if you follow best practices.

    In the case of autoinc you would not include the autoinc field on the form, make it read only, or generate it via a default as I previously described.

    Unlike many other databases Lianja records have an implied unique rowid also.

    When following best practices and visually constructing pages out of related sections adding child records automatically maintains the parent child relationships by evaluating the parent key and inserting it into the child section. That's what you use the relationship builder for.
    Principal developer of Lianja, Recital and other products

    Follow me on:

    Twitter: http://twitter.com/lianjaInc
    Facebook: http://www.facebook.com/LianjaInc
    LinkedIn: http://www.linkedin.com/in/barrymavin

  10. #10
    Senior Member
    Join Date
    Apr 2014
    Posts
    201
    Hi Barry,

    I did some tests and I found the following re your comment below (NB I am only talking web here):

    In the case of autoinc you would not include the autoinc field on the form, make it read only, or generate it via a default as I previously described.

    1. Having an autoinc field on the form never works, even if that field is non-editable as suggested
    2. Having a seqno() default field (instead of autoinc) also does not work if that field is on the form (editable or not)

    The only way I can insert is by removing the autoinc/seqno field from the form, I have attached a demo app to illustrate both.

    Can you confirm that what I am saying is correct?

Page 1 of 2 12 LastLast

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Journey into the Cloud
Join us