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

Thread: default value for a field

  1. #1

    default value for a field

    can one use a select statement returning a single value for "default" ? what would be the syntax ? (enclosed, not enclosed ...)
    ex : select max(id) from ids

    Regards

  2. #2
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    7,359
    Blog Entries
    22
    Seqno() operates in a similar way to AUTOINC and returns a unique row id.
    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
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    7,359
    Blog Entries
    22
    I should also mention that this handles concurrent requests while maintaining that the result is guaranteed unique. The original question you asked about using SELECT MAX() ... Is not guaranteed to return a unique id in a multiuser context.
    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

  4. #4
    I can't use seqno(), as it is re-initialised at app startup. It has to be a sequence used by surrogate keys. My workaround is a virtual table invoking a function defined on the db side.
    Regards

  5. #5
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    7,359
    Blog Entries
    22
    Additionally, each row (record) inserted into a Lianja table has a hidden readonly column called SYNCNUM which is used internally, but it can be referenced in your apps too.

    GUID() is another built-in function which can be used to generate a unique id but unlike SEQNO() it's values are in random order whereas SEQNO() is always ascending.
    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
    7,359
    Blog Entries
    22
    The next Seqno() is maintained in the table header. It is not reset at app startup.
    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
    you mean in RC8?

  8. #8
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    7,359
    Blog Entries
    22
    No it is in RC7.
    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

  9. #9
    unless I am doing something wrong, seqno() does'nt behave that way
    table structure
    Structure for table : tab.dbf
    Alias : tab
    Number of records : 4
    Date of creation : 08/12/2013
    Date of last update : 08/12/2013
    DES3 Encrypted : No
    CursorAdaptor : No
    Field Field Name Type Width Dec Description
    1 ID Integer 1 id
    2 TSTAMP Character 19 tstamp
    ** Total ** 24
    In form Id is read only, default is seqno()
    below is what i get after creating 2 records, exiting the app and creating 2 other records
    ID TSTAMP

    1 08/12/2013 07:04:42
    2 08/12/2013 07:05:08
    1 08/12/2013 07:06:14
    2 08/12/2013 07:06:21

    4 records selected in 5ms
    Regards

  10. #10
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    7,359
    Blog Entries
    22
    There seems to be an issue using seqno() with tables opened exclusively. I will look into it and fix it. It works shared.
    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

Tags for this Thread

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