![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
In Sybase 15, can I do the following: CREATE TABLE my_table_name ( updated_by VARCHAR(128) DEFAULT CURRENT USER, updated_date TIMESTAMP DEFAULT CURRENT TIMESTAMP ) where on an update the updated_by and updated_date will automatically be updated? This way I don't have to use an update trigger to update the columns? My syntax may be wrong. I have never done it before. Does this work in Sybase 15? |
#3
| |||
| |||
|
|
In Sybase 15, can I do the following: CREATE TABLE my_table_name ( updated_by VARCHAR(128) DEFAULT CURRENT USER, updated_date TIMESTAMP DEFAULT CURRENT TIMESTAMP ) where on an update the updated_by and updated_date will automatically be updated? This way I don't have to use an update trigger to update the columns? My syntax may be wrong. I have never done it before. Does this work in Sybase 15? |
#4
| |||
| |||
|
|
On 18-Oct-2011 00:31, 1dg618 wrote: In Sybase 15, can I do the following: CREATE TABLE my_table_name ( * *updated_by * * * *VARCHAR(128) * * * * * * * * *DEFAULT CURRENT USER, * *updated_date * * *TIMESTAMP * * * * * * * * * * DEFAULT CURRENT TIMESTAMP ) where on an update the updated_by and updated_date will automatically be updated? This way I don't have to use an update trigger to update the columns? My syntax may be wrong. I have never done it before. Does this work in Sybase 15? 'current user' and 'current timeastamp' are features that work in SQL Anywhere and Sybase IQ,not in ASE. In ASE, use either of the following: - default user_name() -- if you want the name of the ASE database user - default user * * * * -- same as user_name() - default suser_name() *-- if you want the name of the ASE login - default getdate() * -- get current date/time BTW, the 'timestamp' datatype for that column is not what you think it is. In SQL Anywhere/IQ this is a date/time datatype, but in ASE it has nothign to do with time, despite the name. Instead it is an internally generated unqiue number that can only be used in some very specific application scenarios. SO don't use it -- use 'datetime' or 'bigdatetime' instead. -- HTH, Rob V. ----------------------------------------------------------------- Rob Verschoor Certified Sybase Professional DBA for ASE 15.0/12.5/12.0/11.5/11.0 and Replication Server 15.0.1/12.5 // TeamSybase Author of Sybase books (order online atwww.sypron.nl/shop): "Tips, Tricks& *Recipes for Sybase ASE" (ASE 15 edition) "The Complete Sybase ASE Quick Reference Guide" "The Complete Sybase Replication Server Quick Reference Guide" r... (AT) NO (DOT) SPAM.sypron.nl |www.sypron.nl*| Twitter: @rob_verschoor Sypron B.V., The Netherlands *| *Chamber of Commerce 27138666 ------------------------------------------------------------------ Hide quoted text - - Show quoted text - |
#5
| |||
| |||
|
![]() |
| Thread Tools | |
| Display Modes | |
| |