SQL Expression for 8.5

I challenge any EEE to please provide me with a tried and proven simple Oracle select statement in a SQL Expression Editor that returns a sum() via a direct Crystal Reports Oracle Server database connection.

e.g.    select sum(amount_balance) from accounting_finrep  

I am using Crystal Reports 8.5 Developers edition on Oracle

I have read all recommendations in the entire universe regarding this problem and none of them work.
I continually receive ORA-????? errors without end.  Please help.

Thank Yee.
Who is Participating?
Kurt ReinhardtConnect With a Mentor Sr. Business Intelligence Consultant/ArchitectCommented:
Also, here's a Business Objects KB article which discusses the error message you're getting, specific to your version of Crystal Reports:


Kurt ReinhardtSr. Business Intelligence Consultant/ArchitectCommented:
I don't have Oracle installed locally, but you should be able to use:


Copy the above expression and paste it into your query editor (SQL+, Toad, Embarcadero, etc..).  If the query runs in the editor, it should be good in Crystal Reports.  One key factor is that you have to encapsulate this type of query in parentheses within the SQL Expression Editor.

SpareyarnAuthor Commented:
The SQL syntax you provided is correct and works fine in Toad, PL/SQL Developer, SQL*Plus etc...  
However, the syntax does not compile in the SQL Expression editor in CR8.5.

I receive "ORA-01007 variable not in select list" error message, then a subsequent CR error message stating invalid sql-cannot compile.  

I have tried many options trying to get this to work, encapsulation with parenthesis, {}, " "...and none work.  I either recieve ora-00904 or ora-01007.  Other than the SQL Expression editor, CR8.5 works fine with the Oracle database views, tables, joins and stored procedures.

One other note, the "account_balance" is a field in the report JIC that was your next suggestion.

Thanks for the help, I'll keep trying the same thing over and over again...it has to work eventually ;->
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

you can't use a select statement in an sql expression. sql expression can only manipulate fields, they can't return whole rows. they can be used for instance for concat or trim.

here is more info
Kurt ReinhardtSr. Business Intelligence Consultant/ArchitectCommented:
ewaldl, that's incorrect.  I use Select statements in SQL Expressions all the time.

You CAN use select statements in SQL Expressions.  In fact, you can have a highly complex and convoluted SQL statement.  The caveats are that you must encapsulate the Select statement in parentheses and the SQL Expression can only return a single distinct value.  A SQL Expression is passed to the database as a subquery field in the SELECT clause of the Crystal SQL statement.

Check out the following thread:


Spareyarn,  how are you connecting to the database?  Merant ODBC, Native Drivers, etc...  SQL Expressions depend upon the database connection.

SpareyarnAuthor Commented:
Native Oracle Server drivers provided with CR8.5

p.s.  thanks for saving me the longwinded response I was cooking up for ewaldl.
Kurt ReinhardtConnect With a Mentor Sr. Business Intelligence Consultant/ArchitectCommented:
Have you tried switching drivers?  You're getting oracle-specific errors, which could indicate issues with the driver.  Then again, I've found SQL Expressions to be kind of iffy with Oracle in some cases.

What is the report data source?  A View, Stored Procedure, Tables, etc...

SpareyarnAuthor Commented:
Unfortunately, I don't have a choice when it comes to what db driver to use.  The report, once finished, will be plugged into an ERP Application (Industrial and Financial Systems-IFS) that only supports direct Oracle connections, not ODBC.  

The article you posted looks promising, I will apply CR8.5 SP3 and see what happens.

Thanks for your help.

SpareyarnAuthor Commented:
Case Closed!!!

SP3 fixed it, thank you very much.  I can now sleep a happy man.  

Probably should've looked in more detail for CR8.5 updates, instead of syntax validation on the good ole world wide web.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.