create timestamp column

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
ukyrvd
Premium Member
Premium Member
Posts: 73
Joined: Thu Feb 10, 2005 10:59 am

create timestamp column

Post by ukyrvd »

Hi,
I was wondering if there is any better method for doing this. For each row to be inserted/updated into the database (oracle) I need to include current time stamp information in the row in a separate column.

I was thinking of following tow options:
1) Oracle Enterprise stage, Have a user defined insert statement and in the insert clause have sysdate value for column .. however this requires insert array size of 1
2) Parallel transfer .. define and derive new column and use Oracle enterprise stage with load option.

Is there any other way to achieve this?? If any of you have tested the options which one is better one?? I could test it for myself, but just wanted to know if somebody else has already done this

Thanks for your help
prasad
thank you
- prasad
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

In otherwords you need to capture the timestamp at row level when that particular row was inserted or updated.
Well for inserts, specify that column to get the current timestamp at the table itself. This way you dont even need to pass that particular column. When a row gets inserted, the database will generate the timestamp. In sql server you do it by the function getdate(). Dont know its equivalent function in oracle. Folks working with Oracle can jump in and provide it.

For updates you can specify that column with sysdate in the sql as you mentioned.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
ukyrvd
Premium Member
Premium Member
Posts: 73
Joined: Thu Feb 10, 2005 10:59 am

Post by ukyrvd »

Thanks DsGuru.

You mean to say, during table creation have that column defaulted to currentTime (of row insertion) and pass nothing for that column in Insert SQL?? That looks like a better option than my #1.. thank you!!
thank you
- prasad
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

You got it. :lol:
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

DSguru2B wrote:In sql server you do it by the function getdate(). Dont know its equivalent function in oracle.
sysdate
-craig

"You can never have too many knives" -- Logan Nine Fingers
ukyrvd
Premium Member
Premium Member
Posts: 73
Joined: Thu Feb 10, 2005 10:59 am

Post by ukyrvd »

Yes chulett!!

Any other methods other than these two options (#1 and #2)?? And is it better to go with #1 compared to #2??
thank you
- prasad
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

For completeness, in DataStage you could use

Code: Select all

TimestampFromDateTime(current_date(),current_time())
to generate the timestamp. Use this expression when initializing a stage variable and do not modify the stage variable row by row, so that it is only calculated once. In this way every row will get the same update stamp. If you want "now" for each row, simply use this expression as the stage variable derivation for each row processed.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
ukyrvd
Premium Member
Premium Member
Posts: 73
Joined: Thu Feb 10, 2005 10:59 am

Post by ukyrvd »

Thanks Ray.
ray.wurlod wrote: If you want "now" for each row, simply use this expression as the stage variable derivation for each row processed.
thats how, I wanted to implement option #2.

I am in dilemma which one to chose Transformer vs Oracle_default value/insert statement
thank you
- prasad
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Factor in the 'overhead' of calling out for the system date/time on every record through the transformer. I'm not really sure how much it adds, but it must be something.

Balance that against doing it in Oracle, where the overhead is negligable as far as I know. The downside would be it would only work for inserts and not updates. A trigger could work for both, but some people are trigger shy... and there can be noticable overhead with them.

If you really want to know which way is more performant in your environment with your data - try both! Let us know. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
ukyrvd
Premium Member
Premium Member
Posts: 73
Joined: Thu Feb 10, 2005 10:59 am

Post by ukyrvd »

chulett wrote:If you really want to know which way is more performant in your environment with your data - try both! Let us know. :wink:
I sure will .. I will try with about 3M rows and see how it behaves!!
thank you
- prasad
Post Reply