The ) is missing error in Crystal Reports XI - crystal-reports

When I try to run my report in the Crystal Report 11.5.0.313 I getting the error msg "The ) is missing " and it is pointing me out at the report Formula Workshop on the following code:
TrimRight (SQLcall('SELECT rest_name FROM micros.rest_def WHERE store_id = (select fem_getstoreid(*))')) + ' - ' +
TrimRight (SQLcall('SELECT location_name_1 FROM micros.rest_def WHERE store_id = (select fem_getstoreid(*))'));
I successfully used this report before but our server had been changed and the CR had to be reinstalled top newer version. Does anybody know if there is any error with the formula...?

Additional detail about "SQLCALL" would be helpful, but, I'm not sure if your SQL query is correct?
SELECT location_name_1
FROM micros.rest_def
WHERE store_id = (
SELECT fem_getstoreid(*)
)
What object is "fem_getstoreid"? - The syntax in the where clause is not correct for a table or a view, and store procedures cannot be called using "select"
If the problem started when your database changed, I would start by looking at that "fem_getstoreid".
If it is a view, the proper syntax would be
Select store_id
from femgetstoreid

Related

Where to get example data used in PostgreSQL documentation?

I would like to follow through and experiment with the examples in the PostgreSQL documentation but find it difficult to compare impacts of commands without actual working data.
Is there sample data or a default database that correlates with all the examples in the PostgreSQL documentation ?
Problem:
Getting table or column "does not exist" errors when executing SQL in documentation (https://www.postgresql.org/docs/10/tutorial-window.html):
SELECT depname, empno, salary, enroll_date
FROM
(SELECT depname, empno, salary, enroll_date,
rank() OVER (PARTITION BY depname ORDER BY salary DESC, empno) AS pos
FROM empsalary
) AS ss
WHERE pos < 3;
Error:
SQL Error [42703]: ERROR: column "enroll_date" does not exist
Attempted workarounds:
Stack Builder does not list sample data installation options
The sources do not contain required sample data (eg. "src\tutorial" directory et al in https://ftp.postgresql.org/pub/source/v10.23/postgresql-10.23.tar.gz)
Any 3rd-party sample data found appear incomplete or non-official (eg. "advanced-psql-examples.sql" from https://gist.github.com/marko-asplund/5561404 missing "enroll_date" column)
Versions:
PostgreSQL 10.23 (https://web3.pioneersoftware.co.uk/files/pgsql/10/postgresql-10.23-1-windows.exe)
Stack Builder 4.2.1

Crystal Report Gives me a Different SQL Result

I am getting a different result in CR. I got the right result when I tried to run the query in SQL Server
here is the example of my situation
TB1
TB2
what I am trying to achieve is like this
BUT the CR's result is like this
here is my query:
SELECT * FROM TB1 tb1 LEFT JOIN TB2 tb2 WHERE tb1.ControlNo='IDU 2005.0001' AND tb2.Type = 'Applicant'
This can't be the SQL statement used in the Crystal report.
Are you using a Command as the data source in the report? If so, please show the command in your question.
If you are not using a Command, please show the table joins and the record selection formula.
Most likely, you are not using a Command and the record selection formula in the report design is simply wrong.

Crystal Report - The ) is missing

I have encountered this issue with all of my report templates. I'm sure that it's not coming from the formula which all statements are nested properly.
I wonder do you guys have experienced this before?
The formula as below:
TrimRight (SQLcall('SELECT rest_name FROM micros.rest_def WHERE store_id = (select fem_getstoreid(*))')) + ' - ' +
TrimRight (SQLcall('SELECT location_name_1 FROM micros.rest_def WHERE store_id = (select fem_getstoreid(*))'));
I have never seen a SQLcall before in a report formula. I'm not sure you can execute SQL statements directly from a formula. You should link tables as needed in the Database Expert. If you have more complex data structures, then it is often reasonable to create intermediate queries (views) or stored procedures in the database and use them in the report.

Using WITH clause in Jasper report (JRXML file)

I am trying to use the WITH clause in my jasper report query, but it is giving me the error: -
java.sql.SQLSyntaxErrorException: ORA-00928: missing SELECT keyword
and net.sf.jasperreports.engine.JRException: No input source supplied to the exporter.
The same query works perfectly fine in the Oracle DB client.
Please let me know if there is a problem in using the WITH clause with Jasper report version 3.7.6.
If you are using WITH clause in the starting of select query then, you need to change in Jasper report configuration where you need to specify query start with either SELECT or WITH.
If you are using WITH clause in the middle of select query, you might forget to select records from the dataset generated from WITH clause. See below example...
select * from (
WITH temp as (
select data from any_table
)
)
Instead, use below...
select * from (
WITH temp as (
select data from any_table
)
select * from temp
)
OR
select * from (
select * from
(
WITH temp as (
select data from any_table
)
)
)
Keep Querying!

In SSRS, why do I get the error "item with same key has already been added" , when I'm making a new report?

I'm getting the following error in SSRS:
An error occurred while the query design method was being saved.
An item with the same key has already been added
What does an "item" denote, though? I even tried editing the RDL and deleting all references to the Stored Procedure I need to use called prc_RPT_Select_BI_Completes_Data_View.
Could this possibly have to do with the fact that the Stored Procedure uses Dynamic SQL (the N' notation)?
In the stored procedure I have:
SET #SQL += N'
SELECT bi.SupplierID as ''Supplier ID''
,bi.SupplierName as ''Supplier Name''
,bi.PID as ''PID''
,bi.RespondentID as ''Respondent ID''
,lk_slt.Name as ''Entry Link Type''
,ts.SurveyNumber as ''Initial Survey ID'''
It appears that SSRS has an issue(at leastin version 2008) - I'm studying this website that explains it
Where it says if you have two columns(from 2 diff. tables) with the same name, then it'll cause that problem.
From source:
SELECT a.Field1, a.Field2, a.Field3, b.Field1, b.field99 FROM TableA a
JOIN TableB b on a.Field1 = b.Field1
SQL handled it just fine, since I had prefixed each with an alias
(table) name. But SSRS uses only the column name as the key, not table
+ column, so it was choking.
The fix was easy, either rename the second column, i.e. b.Field1 AS
Field01 or just omit the field all together, which is what I did.
I face the same issue. After debug I fixed the same. if the column name in your SQL query has multiple times then this issue occur. Hence use alias in SQL query to differ the column name.
Ex:
The below query will work proper in sql query but create issue in SSRS report:
Select P.ID, P.FirstName, P.LastName, D.ID, D.City, D.Area, D.Address
From PersonalDetails P
Left Join CommunicationDetails D On P.ID = D.PersonalDetailsID
Reason : ID has mentioned twice (Multiple Times)
Correct Query:
Select P.ID As PersonalDetailsID, P.FirstName, P.LastName, D.ID, D.City, D.Area, D.Address
From PersonalDetails P
Left Join CommunicationDetails D On P.ID = D.PersonalDetailsID
I have experience this issue in past. Based on that I can say that generally we get this issue if your dataset has multiple fieldnames that points to same field source.
Take a look into following posts for detail error description
https://bi-rootdata.blogspot.com/2012/09/an-error-occurred-during-report.html
https://bi-rootdata.blogspot.com/2012/09/an-item-with-same-key-has-already-been.html
In your case, you should check your all field names returned by Sp prc_RPT_Select_BI_Completes_Data_View and make sure that all fields has unique name.
I had the same error in a report query. I had columns from different tables with the same name and the prefix for each table (eg: select a.description, b.description, c.description) that runs ok in Oracle, but for the report you must have an unique alias for each column so simply add alias to the fields with the same name (select a.description a_description, b.description b_description and so on)
Sorry, it is a response to an old thread, but might still be useful.
In addition to above responses,
This generally happens when two columns with same name, even from different tables are included in the same query.
for example if we joining two tables city and state where tables have column name
e.g. city.name and state.name.
when such a query is added to the dataset, SSRS removes the table name or the table alias and only keeps the name, whih eventually appears twice in the query and errors as duplicate key.
The best way to avoid it is to use alias such as calling the column names
city.name as c_name
state.name as s_name.
This will resolve the issue.
I got this error message with vs2015 enterprise, ssdt 14.1.xxx, ssrs. For me I think it was something different than described above with a 2 column, same name problem. I added this report, then deleted the report, then when I tried to add the query back in the ssrs wizard I got this message, " An error occurred while the query design method was being saved :invalid object name: tablename" . where tablename was the table on the query the wizard was reading. I tried cleaning the project, I tried rebuilding the project. In my opinion Microsoft isn't completing cleaning out the report when you delete it and as long as you try to add the original query back it won't add. The way I was able to fix it was to create the ssrs report in a whole new project (obviously nothing wrong with the query) and save it off to the side. Then I reopened my original ssrs project, right clicked on Reports, then Add, then add Existing Item. The report added back in just fine with no name conflict.
I just got this error and i came to know that it is about the local variable alias
at the end of the stored procedure i had like
select #localvariable1,#localvariable2
it was working fine in sql but when i ran this in ssrs
it was always throwing error but after I gave alias it is fixed
select #localvariable1 as A,#localvariable2 as B
SSRS will not accept duplicated columns so ensure that your query or store procedure is returning unique column names.
If you are using SPs and if the sps have multiple Select statements (within if conditions) all those selects needs to be handled with unique field names.