×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

PeopleSoft query problem in suing expression

PeopleSoft query problem in suing expression

PeopleSoft query problem in suing expression

(OP)
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

RE: PeopleSoft query problem in suing expression

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.

RE: PeopleSoft query problem in suing expression

(OP)
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

RE: PeopleSoft query problem in suing expression

(OP)
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


Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close