Crystal Reports XI SQL Expression error: ORA-00936

Posted on 2007-07-24
Last Modified: 2013-12-19

I am currently experiencing problems making a very basic SQL Expression in Crystal Reports XI.  Here is the query:


Here is the error I get:
Error in compiling SQL Expression:
Failed to retrieve data from the database.
Details: ORA-00936: missing expression
[Database Vendor code: 936 ].

The frustrating part is that I did not write this SQL Expression myself.  After trying everything I could think of while writing my own queries, I did the following:  I created a new report, selected only the table I want to pull a field from.  Dragged the field onto the Details portion of the Report on the Design screen.  Went to Database > Show Sql Query ...    on the menu.  Copied the SQL query.  Deleted the field from the report.  Created an SQL Expression and pasted in the query.

I'm sure there's something I'm missing but I'm all out of ideas.  

We're running an Oracle 9 database
Question by:mikovia
    LVL 13

    Accepted Solution

    You cannot use the select statement in the SQL expression formulas. SQL expressiions are similar to formulas where you can define some  the sql fucntions. Then these sql expression formulas can then be referred in the selection formulas the advantage being the record selection is pushed to the server for definite. Also you can use the sql expression formula as the field. The field is precalculated on the server side.

    LVL 42

    Expert Comment

    Does this statement execute if you try it directly on the database (using TOAD, etc.?).  My guess is that it doesn't because the quotes around "PATIENT" are throwing off the parser whether the field you're going after is in the patient table or in the table aliased as patient.

    Take off all of the quotation marks and it should execute just fine.


    Author Comment

    Gary,  you were right.  SQL Expressions were not what I wanted to use.  

    frodoman: I tried every combination of quotations I could think of and they just won't work with SQL Expressions.

    It turns out that in order to run my query I need to create a Command through the Database Expert.  I pasted the query into there and it runs just fine.

    Gary: I still don't understand what SQL Expressions are for.  Could you give an example of a use for them?


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    How to Create User-Defined Aggregates in Oracle Before we begin creating these things, what are user-defined aggregates?  They are a feature introduced in Oracle 9i that allows a developer to create his or her own functions like "SUM", "AVG", and…
    Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
    Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
    This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now