Oracle2Sybase: sequence and systime equivs?

I'm new to Sybase, but very familiar with Oracle. What is the Sybase equivalent of the following:

1) I want to write a trigger that updates/inserts a datetime field in a table with the current date. In Oracle I'd use systime from dual. I know that there's a "getdate()" function in Sybase, but what's the syntax for using in a INSERT/UPDATE statement?

2) Maintaining an ID in a table. I use sequences in Oracle to keep the counter going. What's the best way in Sybase to get the next ID (primary key) value in a table for an INSERT statements?

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

1. The syntax for creating trigger  is
   create trigger [owner.] trigger_name on [owner,] table_name
   for {insert,update,delete}
   as SQL Statements

or using the if update clause :

 create trigger [owner.] trigger_name on [owner,] table_name
   for {insert,update,delete}
if update (column_name)
     {{and| or) update(column_name)]...]..
  SQL Statements

The SQL staements are same as Oracle PL/SQL. I believe you know the insert and update statements the same way as oracle. Here you need to check against the trigger tested tables  i,e inserted. And with satisfied condition you can insert the date filed as getdate() or set the date field to getdate() in case of update. You can refer Transact-SQL User's guid for Sybase SQL Server for examples. Good examples there how to write triggers. If you still have questions , you can write comments , so that I can write in detail.

2. ID can be generated or maintained by using column data type 'Identity' in the table. Unfortunately Sybase does not maintain sequence like Oracle.
The maintenance to data on  Identity column is not easy all the time. You can even use general programming technique like maintaining a look up table with one column and incremenated value can be generated to use in the regular table. The choice depends on you.

Hope this will work for you....


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Sybase Database

From novice to tech pro — start learning today.