Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PeopleSoft query problem in suing expression

Status
Not open for further replies.

gundrathi

Programmer
Mar 11, 2004
9
0
0
US
Hi

I am trying to put the result of a subquery in a varible using 'expression' feature in peoplesoft query (version 8.4). i get a nasty sql error. if i use a database field instead of the variable it works. can u please tell if i am doing anything wrong here.


code:
SELECT A.BUSINESS_UNIT, AMOUT1
FROM PS_LEDGER A
WHERE A.BUSINESS_UNIT = '00231'
AND AMOUT1 = (SELECT C.POSTED_TOTAL_AMT
FROM PS_LEDGER C
WHERE A.ACCOUNT = '7110')

In this code i defined 'Amount1' as a number in 'expression' feature.

If i use the database field instead of 'Amount1' variable code will be like this.
SELECT A.BUSINESS_UNIT, A.POSTED_TOTAL_AMT
FROM PS_LEDGER A
WHERE A.BUSINESS_UNIT = '00231'
AND A.POSTED_TOTAL_AMT = (SELECT C.POSTED_TOTAL_AMT
FROM PS_LEDGER C
WHERE A.ACCOUNT = '7110')

thanks
Sreedevi
 
Hi Sreedevi,

Having a look at your sql - what are you actually trying to do? Seems odd to use an expression in a select if you are only going to be pulling a field rather than summing or aggregating.

Also, your subquery does not seem to be joined to the main - but this may be ok as I am not sure of the data structure here - do your business units have many accounts?

Does the second query return the values you expected? If so, why not just re-label the posted_total_amount to the amout1 used in the first.
 
Hi Notadba

thanks for your response. Actually i have included the above query just as an example. My subquery does pull some amounts based on many criterions.

The point is the variable "amount1" doesn't work whether it is just relabling "posted_amt_total" as "amount1" or getting an amount with a more complicated subquery.


The message i get is
SQL error. Stmt #: 5492 Error Position: 0 Return: 8010 - [IBM][CLI Driver][DB2/6000] SQL0206N "AMOUT1" is not valid in the context where it is used. SQLSTATE=42703
SELECT A.BUSINESS_UNIT, AMOUT1 FROM PS_LEDGER A WHERE A.BUSINESS_UNIT = '00231' AND AMOUT1 = (SELECT C.POSTED_TOTAL_AMT FROM PS_LEDGER C WHERE A.ACCOUNT = '1007')
Error in running query because of SQL Error, Code=8010, Message=[IBM][CLI Driver][DB2/6000] SQL0206N "AMOUT1" is not valid in the context where it is used. SQLSTATE=42703 (50,380)

Does it work on ur system?

thanks
sreedevi
 
to give u more clear picture, my situation is

amount1 = select posted_total_amt where subquery1
amount2 = select posted_total_amt where subquery22
amount3 = amount1-amount2

To define amount 1, i click on "expressions"->"add criterion"->"expression type" drop down box = number->
"expression text"=amount1. then i add criterion to "amount1" to include the subquery.

thanks
sreedevi


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top