Reading Multiple Values for a SQL Query

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
bapajju
Participant
Posts: 82
Joined: Wed Nov 19, 2003 11:58 pm

Reading Multiple Values for a SQL Query

Post by bapajju »

Hello,

I have a Query (In OraOCI8) that takes a single value to provide the result. For Example:
Select * from EMP where EMP_ID=1001.

But in EMP Table I have 100000 employees.

How to get the result set from the same query for all the employees. Please note that I can not take out the WHERE clause as I a using some Oracle function in the query that needs single value output from the query.

After pulling the results for each employee we need to perform some transformation in Transformer and put it in another Oracle table.

It will be of great help if someone can help in resolving this.

Thanks in advance
Amitav
Sunshine2323
Charter Member
Charter Member
Posts: 130
Joined: Mon Sep 06, 2004 3:05 am
Location: Dubai,UAE

Post by Sunshine2323 »

Hi,


If you specify the where clause it willl only return those rows that satisfy the condition specified in the where clause.
It will not return all the rows.

You can try the UNION Operation

Select * from EMP where EMP_ID=1001
UNION
Select * from EMP

Can you kindly elaborate more on your requirement and what is it that you are trying to achieve?
Warm Regards,
Amruta Bandekar

<b>If A equals success, then the formula is: A = X + Y + Z, X is work. Y is play. Z is keep your mouth shut. </b>
--Albert Einstein
rasi
Participant
Posts: 464
Joined: Fri Oct 25, 2002 1:33 am
Location: Australia, Sydney

Post by rasi »

Hi

Your question is not clear enough to respond. Could you explain it futher with some example
Regards
Siva

Listening to the Learned

"The most precious wealth is the wealth acquired by the ear Indeed, of all wealth that wealth is the crown." - Thirukural By Thiruvalluvar
bapajju
Participant
Posts: 82
Joined: Wed Nov 19, 2003 11:58 pm

Reading Multiple Values for a SQL Query

Post by bapajju »

I have a SQL statement that has a Where Clause. Which means it will return the result for the matching value in the where clause.

Ex
select * from Sale
Where
SALE_TSP >= nvl((SELECT max(begin_effective_dt)
FROM sale_history
WHERE sale_type_code in ('5','6','7','8','A')
AND invoice_id = (
SELECT invoice_id
FROM sale_detail
WHERE batch_id = 1001)
Now I have 100000 batch_id in sale_detail tables.

How do I pass the results to th target for all the batch_ids.

Hope now I am making it more clear.





Sunshine2323 wrote:Hi,


If you specify the where clause it willl only return those rows that satisfy the condition specified in the where clause.
It will not return all the rows.

You can try the UNION Operation

Select * from EMP where EMP_ID=1001
UNION
Select * from EMP

Can you kindly elaborate more on your requirement and what is it that you are trying to achieve?
sanjay
Premium Member
Premium Member
Posts: 203
Joined: Fri Apr 23, 2004 2:22 am

Re: Reading Multiple Values for a SQL Query

Post by sanjay »

Hi

Question is not clear ????


Sanjay
bapajju wrote:I have a SQL statement that has a Where Clause. Which means it will return the result for the matching value in the where clause.

Ex
select * from Sale
Where
SALE_TSP >= nvl((SELECT max(begin_effective_dt)
FROM sale_history
WHERE sale_type_code in ('5','6','7','8','A')
AND invoice_id = (
SELECT invoice_id
FROM sale_detail
WHERE batch_id = 1001)
Now I have 100000 batch_id in sale_detail tables.

How do I pass the results to th target for all the batch_ids.

Hope now I am making it more clear.





Sunshine2323 wrote:Hi,


If you specify the where clause it willl only return those rows that satisfy the condition specified in the where clause.
It will not return all the rows.

You can try the UNION Operation

Select * from EMP where EMP_ID=1001
UNION
Select * from EMP

Can you kindly elaborate more on your requirement and what is it that you are trying to achieve?
balajisr
Charter Member
Charter Member
Posts: 785
Joined: Thu Jul 28, 2005 8:58 am

Post by balajisr »

Sunshine2323 wrote:Hi,


If you specify the where clause it willl only return those rows that satisfy the condition specified in the where clause.
It will not return all the rows.

You can try the UNION Operation

Select * from EMP where EMP_ID=1001
UNION
Select * from EMP

Can you kindly elaborate more on your requirement and what is it that you are trying to achieve?
How about the below query

Select * from EMP where 1=1

I am not very clear about your requirement

Can you tell me in detail as to why you need where clause to be present when you need to get all rows?

--Balaji S.R
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

Code: Select all

select * from Sale 
Where 
SALE_TSP >= nvl((SELECT max(begin_effective_dt) 
FROM sale_history 
WHERE sale_type_code in ('5','6','7','8','A') 
AND invoice_id = ( 
SELECT invoice_id 
FROM sale_detail 
WHERE batch_id in (select batch_id from sale_detail ) )
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

But i still dont understand why you need the where condition if you want all the rows to be selected. :?
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
bapajju
Participant
Posts: 82
Joined: Wed Nov 19, 2003 11:58 pm

Reading Multiple Values for a SQL Query

Post by bapajju »

I need the where clause because somewhere down the line I have to use "connect by prior" function to travese a hierarchy. I can not traverse the hierachy if I do not specify a single value in the WHERE clause.




kumar_s wrote:But i still dont understand why you need the where condition if you want all the rows to be selected. :?
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

If you're doing this in DataStage surely the form you require is

Code: Select all

Select * from EMP where EMP_ID = :1
However, this does not traverse a hierarchy; it merely performs a lookup based on the current value for EMP_ID as supplied from the job's stream of data or some expression based on that. DataStage itself does not provide a mechanism for traversing a hierarchy; you may need to create a PL/SQL script or even a DataStage routine to do that.
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