Selecting first record from a table

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
saj
Participant
Posts: 30
Joined: Fri Aug 28, 2009 6:00 am

Selecting first record from a table

Post by saj »

Hi ,
I have a req where I need to select only the first record from a oracle table via Datastage job .Could any one tell me how to select only the first rec.
hamzaqk
Participant
Posts: 249
Joined: Tue Apr 17, 2007 5:50 am
Location: islamabad

Post by hamzaqk »

there is no such thing as first record in the table.. you need to specify on what condition you need to pull the record
Teradata Certified Master V2R5
hamzaqk
Participant
Posts: 249
Joined: Tue Apr 17, 2007 5:50 am
Location: islamabad

Post by hamzaqk »

there is no such thing as first record in the table.. you need to specify on what condition you need to pull the record
Teradata Certified Master V2R5
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

And then once you figure out what the 'first' record should be, either constrain your query to its primary key value or perhaps use "and rownum = 1" to help there.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

It is a fundamental tenet of database design and usage that it is the database server, not the user, that determines order of storage. Therefore, unless every record is timestamped somehow with the date/time it was inserted (so that you can specify the oldest), there is no such thing as the first record in a table. I believe you need to re-think your requirement.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

It's easy enough to select "only one" record from the table. For example you can constrain on ROWNUM = 1.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply