Works fine with isql but powerbuilder datawindow gives error

This script works fine when i run it with isql and gives me result
but when i run this script on powerbuilder database painter or datawindow it give error

"Incorrect syntax near '2'.
Select ..................................

"
The select is

SELECT a.comments,  
cc_paid = ( SELECT sum(payment_amount)
                       FROM Invoice,   Payments
                      WHERE ( Invoice.vendor_no = Payments.vendor_no ) and  
                            ( Invoice.invoice_number = Payments.invoice_number ) and  
                            ( Invoice.order_number = Payments.order_number )  
                   GROUP BY Invoice.order_number, Payments.fund_key  
                     HAVING ( Invoice.order_number = Encumbered_Funds.order_number ) and
                            ( Payments.fund_key = a.fund_key))
    FROM Encumbered_Funds  a
   WHERE a.order_number = "111"
ORDER BY Encumbered_Funds.fund_key ASC  

The whole select statement is repeated in the eroor message.
Please do help me.I have see this problem when i use a nested query in my  slect statment.I cannot change the select statement for the datawindow.Only powerbuilder gives the problem
LVL 2
ajith_29Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

kamel007Commented:
It happens to with me sometimes ..Just try to leave space at the end of each line in the select statement.It might seem silly but it usually works.
0
ajith_29Author Commented:
I tried it did not work
0
gmoriakCommented:
You may have done this, but it is not in your sample:  put a semi-colon at the end

and ... begin each line with a space or tab (same as rejected answer, but insures there are whitespaces)

and finally as a last result ...  this absolutely will work

create a database view and select from the view in your datawindow
0
jkotekCommented:
If you use a Sybase native db interface (SYC, SYD or SYJ drivers), try to use the 'ModifySyntax=0' DBParm.

When executing a query, PowerBuilder queries Sybase metadata and some times modifies a where clausule to get better performance. The 'ModifySyntax' prevents such behaviour and might help you.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Sybase Database

From novice to tech pro — start learning today.