[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1458
  • Last Modified:

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 9.2.0.1.0

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.
0
Spareyarn
Asked:
Spareyarn
  • 4
  • 4
2 Solutions
 
Kurt ReinhardtCommented:
I don't have Oracle installed locally, but you should be able to use:

(
SELECT DISTINCT
  SUM(account_balance)
FROM
  accounting_finrep
)

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.

~Kurt
0
 
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 ;->
0
 
EwaldLCommented:
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
http://support.businessobjects.com/communityCS/TechnicalPapers/sqlexpressions.pdf.asp
0
How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

 
Kurt ReinhardtCommented:
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:

http://www.experts-exchange.com/Databases/Crystal_Reports/Q_21161031.html

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

~Kurt
0
 
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.
0
 
Kurt ReinhardtCommented:
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...

~Kurt
0
 
Kurt ReinhardtCommented:
Also, here's a Business Objects KB article which discusses the error message you're getting, specific to your version of Crystal Reports:

http://support.businessobjects.com/library/kbase/articles/c2012294.asp

~Kurt
0
 
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.

0
 
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.
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now