Syntax error in a query
Hello all
I have a query, and i got this error , any idea ?
Error starting at line 1 in command:
WITH continent_table AS
SELECT en.country,en.continent
,ROW_NUMBER() OVER (PARTITION BY en.country ORDER BY en.percent DESC) ran
FROM encompasses en
where ran=1
select co.name,con.continent,co.population/co.area as pop_density,ec.GDP,pop.Population_Growth,pop.infant_mortality,pol.government
from country co
join economy ec
on co.code=ec.country
join population pop
on co.code=pop.country
join politics pol
on co.code=pol.country
join continent_table con
on co.code=con.country
Error at Command Line:6 Column:8
Error report:
SQL Error: ORA-00904: "RAN": invalid identifier
00904. 00000 - "%s: invalid identifier"
*Cause:
*Action:im using oracle 11g
thank you in advance
best,
david
>
So is it still possible to use this selection as a view? because i can run it but i can not use it to create a view
i think because i have with xx as structure, i don't know
>
I don't know either since you didn't post your 4 digit Oracle version. You probably just have an error in your query.
This works for me using vanilla 11.2.0.1.0:
create view v_emp as
WITH q AS
SELECT empno, deptno, ename
,ROW_NUMBER() OVER (PARTITION BY deptno ORDER BY deptno) r_id
FROM emp
q1 AS
SELECT * from q where r_id < 3
SELECT * from q1
select * from v_emp
EMPNO DEPTNO ENAME R_ID
7782 10 CLARK 1
7934 10 MILLER 2
7369 20 SMITH 1
7902 20 FORD 2
7499 30 ALLEN 1
7521 30 WARD 2
Similar Messages
-
Syntax error in ABAP query after implement patch
Dear All,
After implement patch from SAPKA46C39 to SAPKA46C53, we have syntax error in our query.
our SAP release version is 46C.
The error in query is -The data object "R01" does not have a component called "046" -
We don't found any SAP notes that match for our error.
Anyone ..please help...
Thanks a lot...
BuditutaHi,
The query generated is based on the table structures available as they are used, etc.
So please check if there is any difference in the fields available in the tables used, LDB used if any.
In addition, may be few of the properties of the SAP query and info set does not get copied properly.
and after activating the info set only, activate the query, etc...check them once again.
Regards,
Santhosh. -
MS SQL - Syntax error for valid query
I have a problem with the second query in this code (gives me
a syntax error in my HAVING line)
<cfquery name="getDupes" datasource="#application.ODBC1#"
dbtype="ODBC" username="#application.userNameODBC1#"
password="#application.userPassODBC1#">
SELECT *
FROM view_FormCount
WHERE formCount >= 2
ORDER BY formNum
</cfquery>
<cfset variables.lstForms = "">
<cfoutput query="getDupes">
<cfset variables.lstForms=
listAppend(variables.lstForms,"'#getDupes.formNum#'")>
</cfoutput>
<cfset variables.whereClause = "(formNum =
#ReplaceNoCase(variables.lstForms,',',' OR formNum =
','ALL')#)">
<cfquery name="getDetails"
datasource="#application.ODBC1#" dbtype="ODBC"
username="#application.userNameODBC1#"
password="#application.userPassODBC1#">
SELECT tblForms.formNum, tblForms.formName,
tblForms.formCustNum, tblCompanies.companyAbbr
FROM tblForms INNER JOIN tblCompanies ON tblForms.formCustNum
= tblCompanies.companyNum
GROUP BY tblForms.formNum, tblForms.formName,
tblForms.formCustNum, tblCompanies.companyAbbr
HAVING #variables.whereClause#
ORDER BY tblForms.formNum, tblForms.formCustNum
</cfquery>
Now, the really odd thing is if I just take the query text
out of the CFQUERY tags and use CFOUTPUT instead (to see in my
browser what query is getting executed) I get a query that I can
paste into Enterprise Mgr and runs fine.
I can even paste the resulting text into my code in a CFQUERY
and CF will run it fine.
In other words, the dynamic version query gives me an error,
but if I just output the SQL statement, copy-and-paste that into
the CFQUERY that's erroring out (replacing what's there) to run as
a static query, it works fine (sample of static query below).
The error I get when I try to do it dynamically is "Error
Executing Database Query. [Macromedia][SQLServer JDBC
Driver][SQLServer]Line 4: Incorrect syntax near '10169318'. The
error occurred on line 21." which is where the HAVING clause
starts.
SELECT tblForms.formNum, tblForms.formName,
tblForms.formCustNum, tblCompanies.companyAbbr FROM tblForms INNER
JOIN tblCompanies ON tblForms.formCustNum = tblCompanies.companyNum
GROUP BY tblForms.formNum, tblForms.formName, tblForms.formCustNum,
tblCompanies.companyAbbr HAVING (formNum = '10169318' OR formNum =
'1016CONCERTA' OR formNum = '1016NSAIDS' OR formNum =
'1016STRATTERA' OR formNum = '1016WELLBUTRIN' OR formNum =
'18504211' OR formNum = '185093807' OR formNum = '73208565' OR
formNum = '732120027' OR formNum = '7322154' OR formNum = '7323402'
OR formNum = '7323522' OR formNum = '73238900' OR formNum =
'7324211' OR formNum = '7324211S' OR formNum = '7324265' OR formNum
= '73242891' OR formNum = '732434341' OR formNum = '732434342' OR
formNum = '73243435' OR formNum = '73243436' OR formNum =
'73243439' OR formNum = '73243440' OR formNum = '73243441' OR
formNum = '73243442' OR formNum = '73243443' OR formNum = '7324359'
OR formNum = '7324360' OR formNum = '7324370' OR formNum =
'7324560' OR formNum = '7324959' OR formNum = '7326411ptreg' OR
formNum = '7326599' OR formNum = '7326600' OR formNum = '7326620'
OR formNum = '7326707' OR formNum = '7326931' OR formNum =
'7328410' OR formNum = '732851031TOP' OR formNum = '7328512' OR
formNum = '7328548' OR formNum = '7328548P2' OR formNum =
'7328548P3' OR formNum = '7328548P4' OR formNum = '73289400' OR
formNum = '73290D' OR formNum = '7329154' OR formNum =
'73291544JHS' OR formNum = '73291545JHS' OR formNum =
'73291546JHSMH' OR formNum = '73291547JHSMH' OR formNum = '7329174'
OR formNum = '7329308' OR formNum = '7329402' OR formNum =
'7329424' OR formNum = '7329455' OR formNum = '7329520' OR formNum
= '7329539' OR formNum = '73297701JH' OR formNum = '73298273' OR
formNum = '73298400' OR formNum = '73298403' OR formNum =
'73298404' OR formNum = '7329883' OR formNum = '73298860' OR
formNum = '7329887' OR formNum = '73298974' OR formNum = '7329899'
OR formNum = '7329899S' OR formNum = '73299190' OR formNum =
'7329987' OR formNum = '7329999PTO' OR formNum = '732AV5160' OR
formNum = '732CMHFRAZ' OR formNum = '732HIPAA' OR formNum =
'732HIPAAFLYERS' OR formNum = '734HEART' OR formNum = '7444711' OR
formNum = '7449230' OR formNum = '744HR4991' OR formNum =
'7538014MI' OR formNum = '77511044' OR formNum = '77511045' OR
formNum = '775stampnochange' OR formNum = '80851001BLUE' OR formNum
= '80MR4200' OR formNum = '80MR4273' OR formNum = '80MR4274' OR
formNum = '80MR4300' OR formNum = '80MR9934' OR formNum =
'80MR9935' OR formNum = '80SHC100' OR formNum = '80SHC4301' OR
formNum = '80SHC9830' OR formNum = '80SHC9832') ORDER BY
tblForms.formNum, tblForms.formCustNumAWFrueh1808 wrote:
> OK, that's simple enough. But then I'm really confused
as to why the query in
> my original post/example didn't work.
>
> The only single quotes in my #whereClause# variable were
wrapped around each
> varchar value in the WHERE clause (well, HAVING) as in
HAVING formNum = '12345'
> OR formNum = '54321'
>
> I never used a single quote within the value itself. And
yet
> preservesinglequotes fixed it. So what was CF doing? Why
did the single
> quotes still show up in the error msg - and in the right
place?
>
As I said the default behavior is to escape the quotes in
your variables
as data. So the default output of your SQL statement, before
preserveSingleQuotes() would be like this.
HAVING formNum = ''12345'' OR formNum = ''54321''
As you can see that is not the desired results in your case.
In your
case you have the proper number of single quotes in your
string and you
do not want any added. You want to preserve them so to say.
Thus
adding preserveSingleQuotes() around your whereClase
variable, i.e.
preserveSingleQuotes(whereClause) says do not add any quotes,
keep them
all single. -
Dear All,
Please tell me syntax error in the below query. When I'm going to write numeric number in this filed "$[ OVPM.DocNUm ]". It's working fine. But when I'm writing this it give me error.Please clear me where am wrong????I
SELECT T0.[AcctNum] FROM VPM1 T0 WHERE T0.[DocNum] =$ [OVPM.DocNUm ]
Regards
Edited by: Anwar Ali Sohail on Sep 27, 2011 11:43 AMHI
Try This
SELECT T0.[CheckNum] FROM VPM1 T0 INNER JOIN OVPM T1 ON T0.DocNum = T1.DocEntry WHERE T0.[DocNum] = $[OVPM.DocNum]
OR
SELECT T0.[AcctNum] FROM VPM1 T0 INNER JOIN OVPM T1 ON T0.DocNum = T1.DocEntry WHERE T0.[DocNum] = $[OVPM.DocNum]
Edited by: kambadasan on Sep 27, 2011 4:26 PM -
Hi All,
We are facing syntax erro with ABAP query.
We have a infoset/query which is perfectly working in one system and we downloaded the both infoset and query from this system.But the same query when it is uploaded to other system is not working.
Infoset is not giving any syntax error while activation. Morever, the generated report struture is also different from the other system. In old system, report was having one include for declaration and other for data retrieval process etc.
Can you please help us to resolve this issue?
ThanksHi,
The query generated is based on the table structures available as they are used, etc.
So please check if there is any difference in the fields available in the tables used, LDB used if any.
In addition, may be few of the properties of the SAP query and info set does not get copied properly.
and after activating the info set only, activate the query, etc...check them once again.
Regards,
Santhosh. -
I have a flash form that is used to inserts a record into an
Access database table. In the for there are 4 datefields, several
text input fields, and several select fields. When I submit the
form, I get a syntax error that reads:
Executing Database Query. [Macromedia][SequeLink JDBC
Driver][ODBC Socket][Microsoft][ODBC Microsoft Access Driver]
Syntax error in INSERT INTO statement.
The error occurred on line 184. Complex object types cannot
be converted to simple values.
Line 184 is the last line of the Values in the insert query.
The query looks like this:
<CFQUERY DATASOURCE="#REQUEST.DataSource#">
INSERT INTO EstimateNumber(
BidNumber,
Project,
JobSite,
EstimatedBy,
Region,
Company,
Division,
InquiryNumber,
SafetyChecklist,
SafetyChecklistDate,
QCChecklist,
QCChecklistDate,
EstimatedValue,
UserUsername,
UserPassword,
Updated,
ReviewDate,
ReviewedBy,
Discipline,
BidDate,
JobNumber,
UpdatedBy
VALUES(
#FORM.BidNumber#,
'#FORM.Project#',
'#FORM.JobSite#',
'#FORM.EstimatedBy#',
#FORM.Region#,
#FORM.Company#,
#FORM.Division#,
'#FORM.InquiryNumber#',
#FORM.SafetyChecklist#,
#FORM.SafetyChecklistDate#,
#FORM.QCChecklist#,
'#FORM.QCChecklistDate#',
#FORM.EstimatedValue#,
'#FORM.UserUsername#',
'#FORM.UserPassword#',
#FORM.Updated#,
#FORM.ReviewDate#,
#FORM.ReviewedBy#,
#FORM.Discipline#,
#FORM.BidDate#,
#FORM.JobNumber#,
'#FORM.UpdatedBy#'
</CFQUERY>
Any recomendations?Date/Time in Access provide some pretty strage hurdles. In
many occassions I have simply changed the field to a Text field and
ran with that and never seemed to have problems with the result. I
didn't like doing it but I never received errors. I have been
receiving some parameter errors with <cfqueryparam> like the
database doesn't recognized the preceding declared field in the
update or insert query. Here is an example of a wierd error with
Access. I have 2 tables. One is for estimate numbers and the other
is for sub estimate numbers that can be assigned to specific
estimate numbers. If is actually a complicated explanation about
what is taking place behind the doors on this. The concept is
simple on the surface. Both tables have the same fields except the
subestimate table has 1 extra for a user defined subestimate
number. The only relation between the two will be the estimate
number. This insert works fine.
INSERT INTO EstimateNumber(
BidNumber,
Project,
JobSite,
EstimatedBy,
Region,
Company,
Division,
InquiryNumber,
SafetyChecklist,
SafetyChecklistDate,
QCChecklist,
QCChecklistDate,
EstimatedValue,
UserUsername,
UserPassword,
ReviewDate,
Discipline,
BidDate,
JobNumber,
UpdatedBy
VALUES(
#FORM.BidNumber#,
'#FORM.Project#',
'#FORM.JobSite#',
'#FORM.EstimatedBy#',
#FORM.Region#,
#FORM.Company#,
#FORM.Division#,
'#FORM.InquiryNumber#',
#FORM.SafetyChecklist#,
<cfqueryparam
value="#FORM.SafetyChecklistDate#"
cfsqltype="CF_SQL_DATE "
maxlength="50"
>,
#FORM.QCChecklist#,
<cfqueryparam
value="#FORM.QCChecklistDate#"
cfsqltype="CF_SQL_DATE "
maxlength="50"
>,
#FORM.EstimatedValue#,
'#FORM.UserUsername#',
'#FORM.UserPassword#',
<cfqueryparam
value="#FORM.ReviewDate#"
cfsqltype="CF_SQL_DATE "
maxlength="50"
>,
#FORM.Discipline#,
<cfqueryparam
value="#FORM.BidDate#"
cfsqltype="CF_SQL_DATE "
maxlength="50"
>,
#FORM.JobNumber#,
'#FORM.UpdatedBy#'
This next one is the same exact query with the same table
setup with one added field but kicks back a parmeter error
expecting 4. I can't explain it.
INSERT INTO SubEstimate(SubBidNumber,
BidNumber,
Project,
JobSite,
EstimatedBy,
Region,
Company,
Division,
InquiryNumber,
SafetyChecklist,
SafetyChecklistDate,
QCChecklist,
QCChecklistDate,
EstimatedValue,
UserUsername,
UserPassword,
ReviewDate,
Discipline,
BidDate,
JobNumber,
UpdatedBy
VALUES(#FORM.SubBidNumber#,
#FORM.BidNumber#,
'#FORM.Project#',
'#FORM.JobSite#',
'#FORM.EstimatedBy#',
#FORM.Region#,
#FORM.Company#,
#FORM.Division#,
'#FORM.InquiryNumber#',
#FORM.SafetyChecklist#,
<cfqueryparam
value="#FORM.SafetyChecklistDate#"
cfsqltype="CF_SQL_DATE "
maxlength="50"
>,
#FORM.QCChecklist#,
<cfqueryparam
value="#FORM.QCChecklistDate#"
cfsqltype="CF_SQL_DATE "
maxlength="50"
>,
#FORM.EstimatedValue#,
'#FORM.UserUsername#',
'#FORM.UserPassword#',
<cfqueryparam
value="#FORM.ReviewDate#"
cfsqltype="CF_SQL_DATE "
maxlength="50"
>,
#FORM.Discipline#,
<cfqueryparam
value="#FORM.BidDate#"
cfsqltype="CF_SQL_DATE "
maxlength="50"
>,
#FORM.JobNumber#,
'#FORM.UpdatedBy#'
IF I get rid of the cfqueryparam fields it works. If I simply
remove the param, I get a Syntax error. Needless to say I commented
this query for the sake of sanity for the time being. -
Syntax error in 'UPDATE' query ???
hi..
i know there is something wrong with this query..but not able to find it out.
i am using session bean in my project..in one of the method of the bean class, i am updating 'Acc_holder' table.
below is the code
public String insDeposit(String vuserid, String vaccountno, int amount, int chqno)
... //connection code
Statement stmt=null;
query="UPDATE Acc_holder SET balance=balance" + vamount + "WHERE userid=' "+vuserid+" ' ";
}In above query, Acc_holder Table has balance(int), vamount(int), userid(varchar) fields.
when i run, error msg that i get is "java.rmi.RemoteException...java.sql.SQLException:...Incorrect syntax near 'userid'.
please suggest how this query should be formattedUse a prepared statement.
And after you start doing that then put a space in front of the 'where' -
Syntax errors in update query with inner joins and sub query.
Below is the query:
UPDATE sp_CFQ_Coord_Corrections
INNER JOIN (CFQ_Coord_Corrections
INNER JOIN CFQ_Referrals ON CFQ_Coord_Corrections.CorrID = CFQ_Referrals.RecID)
ON sp_CFQ_Coord_Corrections.ID = CFQ_Referrals.RecID
SET CFQ_Coord_Corrections.MatchFound = 1,
CFQ_Coord_Corrections.RecTblID = [CFQ_Referrals].[RecTblID],
sp_CFQ_Coord_Corrections.MatchFound = 1
WHERE (((CFQ_Coord_Corrections.MatchFound)=0)
AND ((sp_CFQ_Coord_Corrections.MatchFound)=0)
AND ((CFQ_Coord_Corrections.RecImported)=1)
AND ((CFQ_Referrals.RecFileName)='COORDCORR_SPOINT')
AND ((CFQ_Referrals.RecCombKey)='No.Match')
AND ((sp_CFQ_Coord_Corrections.RecImported)=1));
Error messages seen when executed:
Msg 156, Level 15, State 1, Line 3
Incorrect syntax near the keyword 'INNER'.
Msg 102, Level 15, State 1, Line 10
Incorrect syntax near 'CFQ_Coord_Corrections'.
Please help.....Below is the query:
UPDATE sp_CFQ_Coord_Corrections
INNER JOIN (CFQ_Coord_Corrections
INNER JOIN CFQ_Referrals ON CFQ_Coord_Corrections.CorrID = CFQ_Referrals.RecID)
ON sp_CFQ_Coord_Corrections.ID = CFQ_Referrals.RecID
SET CFQ_Coord_Corrections.MatchFound = 1,
CFQ_Coord_Corrections.RecTblID = [CFQ_Referrals].[RecTblID],
sp_CFQ_Coord_Corrections.MatchFound = 1
WHERE (((CFQ_Coord_Corrections.MatchFound)=0)
AND ((sp_CFQ_Coord_Corrections.MatchFound)=0)
AND ((CFQ_Coord_Corrections.RecImported)=1)
AND ((CFQ_Referrals.RecFileName)='COORDCORR_SPOINT')
AND ((CFQ_Referrals.RecCombKey)='No.Match')
AND ((sp_CFQ_Coord_Corrections.RecImported)=1));
Error messages seen when executed:
Msg 156, Level 15, State 1, Line 3
Incorrect syntax near the keyword 'INNER'.
Msg 102, Level 15, State 1, Line 10
Incorrect syntax near 'CFQ_Coord_Corrections'.
Please help.....
sp_CFQ_Coord_Corrections is a table and not a stored procedure.
are these both tables "sp_CFQ_Coord_Corrections" and "CFQ_Coord_Corrections" different ?? -
Syntax error while precompiling query
Hi,
Using dbxml 2.3.8.
I get this error when calling the manager's prepare() in PHP :
Error: Variable :state does not exist [err:XPST0008], <query>:76:98
The (simplified) xquery looks like:
" ... (doc("...")/*[1],$state)"
I want $state to be a variable which I can set with the context when I execute the query. I have followed the documentation found in: http://www.oracle.com/technology/documentation/berkeley-db/xml/gsg_xml/java/dbxmlqueries.html#queries
What is wrong?
/EnricReplying myself, I think the solution is to define the variable as external.
Another related question: how can I create an XmlValue as a node in PHP from an string? Its constructor only receives a $value. In Java I've seen there is a constructor where you can say the type of the XmlValue.
Thanks for any help,
/Enric -
This is the first time i am using Merge Query and the query is
;MERGE saSalesStockRecevedSub AS T
USING @tableSRN AS S
ON (T.prodCode=S.prodCode AND T.packtypeID=S.packtypeID AND T.batchCode=S.batchCode and T.stockReceiveMainID=S.stockReceiveMainID)
WHEN NOT MATCHED BY T
THEN
INSERT(stockReceiveMainID, prodCode, packtypeID, batchCode, quantityClaim, quantityReceived,reasonId, qQuantity, saleableQty, mfgDefect, slDamageQty, nonSaleableQty, damageQty, breakageQty, leakageQty, expiryQty, remarks,activeStatus,cnCreateSl,cnCreateNsl)
VALUES(S.stockReceiveMainID, S.prodCode, S.packtypeID, S.batchCode, S.quantityClaim, S.quantityReceived,S.reasonId, S.qQuantity, S.saleableQty, S.mfgDefect, S.slDamageQty, S.nonSaleableQty, S.damageQty, S.breakageQty, S.leakageQty, S.expiryQty,
S.remarks,'ACTIVE','FALSE','FALSE')
WHEN MATCHED
THEN
UPDATE SET T.quantityClaim=S.quantityClaim, T.quantityReceived=S.quantityReceived,T.reasonId=S.reasonId, T.qQuantity=S.qQuantity, T.saleableQty=S.saleableQty, T.mfgDefect=S.mfgDefect, T.slDamageQty=S.slDamageQty, T.nonSaleableQty=S.nonSaleableQty,
T.damageQty=S.damageQty, T.breakageQty=S.breakageQty, T.leakageQty=S.leakageQty, T.expiryQty=S.expiryQty, T.remarks=S.remarks
WHEN NOT MATCHED BY S
THEN
DELETE ;
It showing incorrect syntax near 'T'.
Please help me.
ThanksHere below is the complete code, hope it will work with you.
You should use the key word source and target instead of using S and T
MERGE saSalesStockRecevedSub AS T
USING tableSRN AS S
ON (T.prodCode=S.prodCode AND T.packtypeID=S.packtypeID AND T.batchCode=S.batchCode and T.stockReceiveMainID=S.stockReceiveMainID)
WHEN NOT MATCHED BY TARGET
THEN
INSERT(stockReceiveMainID, prodCode, packtypeID, batchCode, quantityClaim, quantityReceived,reasonId, qQuantity, saleableQty, mfgDefect, slDamageQty, nonSaleableQty, damageQty, breakageQty, leakageQty, expiryQty, remarks,activeStatus,cnCreateSl,cnCreateNsl)
VALUES(S.stockReceiveMainID, S.prodCode, S.packtypeID, S.batchCode, S.quantityClaim, S.quantityReceived,S.reasonId, S.qQuantity, S.saleableQty, S.mfgDefect, S.slDamageQty, S.nonSaleableQty, S.damageQty, S.breakageQty, S.leakageQty, S.expiryQty,
S.remarks,'ACTIVE','FALSE','FALSE')
WHEN MATCHED
THEN
UPDATE SET T.quantityClaim=S.quantityClaim, T.quantityReceived=S.quantityReceived,T.reasonId=S.reasonId, T.qQuantity=S.qQuantity, T.saleableQty=S.saleableQty, T.mfgDefect=S.mfgDefect, T.slDamageQty=S.slDamageQty, T.nonSaleableQty=S.nonSaleableQty,
T.damageQty=S.damageQty, T.breakageQty=S.breakageQty, T.leakageQty=S.leakageQty, T.expiryQty=S.expiryQty, T.remarks=S.remarks
WHEN NOT MATCHED BY SOURCE
THEN
DELETE ;
Working as a Senior Database Analyst & Architect at Ministry of Higher Education in KSA -
Why Syntax error in this query?
Hi
I have this simple query, but in run time I have a "sytax error in INSERT INTO". Why?
Statement st = con.createStatement();
st.executeUpdate("INSERT INTO TMail (From, Oggetto) VALUES ('" +
from + "', '" + mex.getSubject() +
"')");If it's not a problem with a reserved word, then you're probably generating an invalid query. You need to print your query out and see what the query is.
Also, many many many SQL problems can be avoided (nad you'll have cleaner, faster code), if you use PreparedStatement instead of Statement. Statement is for amateurs...
static final String SQL = "INSERT INTO TMail (From, Oggetto) VALUES (?, ?)";
PreparedStatement ps = con.prepareStatement(SQL);
ps.setString(1, from);
ps.setString(2, mex.getSubject() );
ps.executeUpdate(); -
Below is the query:
UPDATE CFQCC
SET sp_CFQCorr.RecImported = 1,
CFQCC.RecImported = 1
from [HR_DEV_DM].[CFQ_TEST].CFQ_Coord_Corrections as CFQCC
INNER JOIN [HR_DEV_DM].[CFQ_TEST].sp_CFQ_Coord_Corrections as sp_CFQCorr
ON CFQCC.CorrID = sp_CFQCorr.ID
WHERE (((sp_CFQCorr.RecImported)=0)
AND ((CFQCC.RecImported)=0));
When executed, it gives the below error:
Msg 4104, Level 16, State 1, Line 2
The multi-part identifier "sp_CFQCorr.RecImported" could not be bound.
Please help....UPDATE Table1, Table2
SET Table1.Column1 = 'one'
,Table2.Column2 = 'two'
FROM Table1 T1, Table2 T2
WHERE T1.id = T2.id
and T1.id = 'id1' -
Can not use SUM in a simple query because of a syntax error?
Hi
Thank you for reading my post.
I am trying to execute the following query:
q = em.createQuery("SELECT SUM((NE.pipeLength - 0.6)+((NE.networkDepth-NE.initialDepth)*0.41)+ NE.standLenght) FROM NExpansion NE where (( NE.contract.contractor=:contractor) AND (NE.pDiameter=:diameter))");
q.setParameter("contractor", contractor);
q.setParameter("diameter", diameter);
l = (Long) q.getSingleResult();And I get the following error:
Caused by: Exception [TOPLINK-8025] (Oracle TopLink Essentials - 2.0.1 (Build b09d-fcs (12/06/2007))): oracle.toplink.essentials.exceptions.EJBQLException
Exception Description: Syntax error parsing the query [SELECT SUM((NE.pipeLength - 0.6)+((NE.networkDepth-NE.initialDepth)*0.41)+ NE.standLenght) FROM NExpansion NE where (( NE.contract.contractor=:contractor) AND (NE.pDiameter=:diameter))], line 1, column 12: unexpected token [(].
Internal Exception: line 1:12: unexpected token: (
at oracle.toplink.essentials.exceptions.EJBQLException.unexpectedToken(EJBQLException.java:389)
at oracle.toplink.essentials.internal.parsing.ejbql.EJBQLParser.handleANTLRException(EJBQLParser.java:350)
at oracle.toplink.essentials.internal.parsing.ejbql.EJBQLParser.addError(EJBQLParser.java:278)
at oracle.toplink.essentials.internal.parsing.ejbql.EJBQLParser.reportError(EJBQLParser.java:378)
at oracle.toplink.essentials.internal.parsing.ejbql.antlr273.EJBQLParser.aggregateExpression(EJBQLParser.java:1416)
at oracle.toplink.essentials.internal.parsing.ejbql.antlr273.EJBQLParser.selectExpression(EJBQLParser.java:1158)
at oracle.toplink.essentials.internal.parsing.ejbql.antlr273.EJBQLParser.selectClause(EJBQLParser.java:403)
at oracle.toplink.essentials.internal.parsing.ejbql.antlr273.EJBQLParser.selectStatement(EJBQLParser.java:178)
at oracle.toplink.essentials.internal.parsing.ejbql.antlr273.EJBQLParser.document(EJBQLParser.java:135)
at oracle.toplink.essentials.internal.parsing.ejbql.EJBQLParser.parse(EJBQLParser.java:166)
at oracle.toplink.essentials.internal.parsing.ejbql.EJBQLParser.buildParseTree(EJBQLParser.java:127)
at oracle.toplink.essentials.internal.ejb.cmp3.base.EJBQueryImpl.buildEJBQLDatabaseQuery(EJBQueryImpl.java:215)
at oracle.toplink.essentials.internal.ejb.cmp3.base.EJBQueryImpl.buildEJBQLDatabaseQuery(EJBQueryImpl.java:189)
at oracle.toplink.essentials.internal.ejb.cmp3.base.EJBQueryImpl.buildEJBQLDatabaseQuery(EJBQueryImpl.java:153)
at oracle.toplink.essentials.internal.ejb.cmp3.base.EJBQueryImpl.<init>(EJBQueryImpl.java:114)
at oracle.toplink.essentials.internal.ejb.cmp3.base.EJBQueryImpl.<init>(EJBQueryImpl.java:99)
at oracle.toplink.essentials.internal.ejb.cmp3.EJBQueryImpl.<init>(EJBQueryImpl.java:86)
at oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerImpl.createQuery(EntityManagerImpl.java:204)
... 30 more
Caused by: line 1:12: unexpected token: (
at oracle.toplink.essentials.internal.parsing.ejbql.antlr273.EJBQLParser.aggregateExpression(EJBQLParser.java:1365)
... 43 morePlease let me know what am I doing wrong?
Thanks.Hello,
From the grammar in the JPA spec, SUM only takes a state_field_path_expression which is defined as
state_field_path_expression := {identification_variable | single_valued_association_path_expression}.state_field
Please feel free to file an enhancement to have this expanded upon.
Best Regards,
Chris -
AVG calculation and syntax error while parsing a named query
Hi all,
I've to calcolate the average of polling results for each value column (5 value column in total). I want to use this single row result line for a bar graph.
I created a new named query in the EJB:
@NamedQueries({
@NamedQuery(name = "Polls.findAll", query = "select o from Polls o"),
@NamedQuery(name = "Polls.findAVG", query = "select o AVG(Value1) as Value1, AVG(Value2) as Value2, AVG(Value3) as Value3, AVG(Value4) as Value4, AVG(Value5) as Value5 o from Polls o") // <-- my named query
...I tried it in the sql query tool of Oracle 10g XE and sql syntax is ok, but when I run my javaServiceFacade on JDev I receive this message:
Exception in thread "main" Local Exception Stack:
Exception [EclipseLink-8023] (Eclipse Persistence Services - 1.0.1 (Build 20080905)): org.eclipse.persistence.exceptions.JPQLException
Exception Description: Syntax error parsing the query [Polls.findAVG: select AVG(Value1) as Value1, AVG(Value2) as Value2, AVG(Value3) as Value3, AVG(Value4) as Value4, AVG(Value5) as Value5 o from Polls o].
Internal Exception: org.eclipse.persistence.internal.libraries.antlr.runtime.EarlyExitException
...Where is the syntax error in my named query?
Edited by: Silicio on 22-nov-2008 1.05Thanks Shay, now I think syntax is correct for gain an average for each column:
@NamedQuery(name = "Polls.findAVG", query = "select AVG(o.value1), AVG(o.value2), AVG(o.value3), AVG(o.value4), AVG(o.value5) from Polls o")But still got some trouble to get a bar graph...
If I drag&drop that query from data control, I get an empty graph with 5 values ,look http://img153.imageshack.us/img153/8710/emptygraphag7.png .
In the log there is some errors (due that named query and its methods in EJB):
AVVERTENZA: Transient state added to StateManager. State may not be serialized. State id: data.oracle_view_risultatiPageDef.Polls1__cubicDefinition
23-nov-2008 11.08.28 oracle.adf.share.http.HttpSessionStateManagerImpl putState
AVVERTENZA: Transient state added to StateManager. State may not be serialized. State id: data.oracle_view_risultatiPageDef.Polls1__dataModel
[EL Info]: 2008.11.23 11:08:29.546--ServerSession(20936795)--EclipseLink, version: Eclipse Persistence Services - 1.0.1 (Build 20080905)
[EL Info]: 2008.11.23 11:08:29.562--ServerSession(20936795)--Server: WebLogic Server Temporary Patch for CR380042 Thu Sep 11 13:33:40 PDT 2008
[EL Info]: 2008.11.23 11:08:29.562--ServerSession(20936795)--file:/C:/Oracle/Middleware/jdeveloper/system/system11.1.1.0.31.51.56/o.j2ee/drs/Application13/Application13-Model-ejb/-Model login successful
23-nov-2008 11.08.37 oracle.adfinternal.view.faces.config.rich.RegistrationConfigurator handleError
GRAVE: Server Exception during PPR, #1
oracle.jbo.JboException: JBO-29000: Unexpected exception caught: groovy.lang.MissingPropertyException, msg=Exception evaluating property 'id' for java.util.Arrays$ArrayList, Reason: groovy.lang.MissingPropertyException: No such property: id for class: java.lang.Double
at oracle.jbo.ExprEval.internalEvaluateGroovyScript(ExprEval.java:753)
at oracle.jbo.ExprEval.doEvaluate(ExprEval.java:779)
at oracle.jbo.ExprEval.evaluateForRow(ExprEval.java:690)
at oracle.jbo.server.AttributeDefImpl.evaluateTransientExpression(AttributeDefImpl.java:1816)
at oracle.jbo.server.ViewRowStorage.getAttributeInternal(ViewRowStorage.java:1554)
at oracle.jbo.server.ViewRowImpl.getAttributeValue(ViewRowImpl.java:1634)
at oracle.jbo.server.ViewRowImpl.getAttributeInternal(ViewRowImpl.java:746)
at oracle.adf.model.bean.DCDataRow.getAttributeInternal(DCDataRow.java:352)
at oracle.jbo.server.ViewRowImpl.getKey(ViewRowImpl.java:598)
at oracle.adf.model.bean.DCDataRow.getKey(DCDataRow.java:149)
at oracle.adf.model.binding.DCIteratorBinding.buildFormToken(DCIteratorBinding.java:3836)
at oracle.adf.model.binding.DCBindingContainerState.buildStringBuffer(DCBindingContainerState.java:71)
at oracle.adf.model.binding.DCBindingContainerState.toString(DCBindingContainerState.java:590)
at oracle.adf.model.binding.DCBindingContainer.getStateToken(DCBindingContainer.java:4293)
at oracle.adfinternal.controller.application.model.SaveStateTokenListener.afterPhase(SaveStateTokenListener.java:54)
at oracle.adfinternal.controller.lifecycle.ADFLifecycleImpl$PagePhaseListenerWrapper.afterPhase(ADFLifecycleImpl.java:529)
at oracle.adfinternal.controller.lifecycle.LifecycleImpl.internalDispatchAfterEvent(LifecycleImpl.java:118)
at oracle.adfinternal.controller.lifecycle.LifecycleImpl.dispatchAfterPagePhaseEvent(LifecycleImpl.java:166)
at oracle.adfinternal.controller.faces.lifecycle.ADFPhaseListener$PhaseInvokerImpl.dispatchAfterPagePhaseEvent(ADFPhaseListener.java:122)
at oracle.adfinternal.controller.faces.lifecycle.ADFPhaseListener.afterPhase(ADFPhaseListener.java:68)
at oracle.adfinternal.controller.faces.lifecycle.ADFLifecyclePhaseListener.afterPhase(ADFLifecyclePhaseListener.java:51)
at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._executePhase(LifecycleImpl.java:354)
at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:203)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292)
at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
at oracle.adf.model.servlet.ADFBindingFilter.doFilter(ADFBindingFilter.java:181)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
at oracle.adfinternal.view.faces.webapp.rich.RegistrationFilter.doFilter(RegistrationFilter.java:85)
at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:278)
at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._invokeDoFilter(TrinidadFilterImpl.java:238)
at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._doFilterImpl(TrinidadFilterImpl.java:195)
at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl.doFilter(TrinidadFilterImpl.java:138)
at org.apache.myfaces.trinidad.webapp.TrinidadFilter.doFilter(TrinidadFilter.java:92)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
at oracle.security.jps.wls.JpsWlsFilter.doFilter(JpsWlsFilter.java:102)
at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:65)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3496)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(Unknown Source)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2180)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2086)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1406)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
Caused by: groovy.lang.MissingPropertyException: Exception evaluating property 'id' for java.util.Arrays$ArrayList, Reason: groovy.lang.MissingPropertyException: No such property: id for class: java.lang.Double
at org.codehaus.groovy.runtime.DefaultGroovyMethods.getAt(DefaultGroovyMethods.java:2978)
at groovy.lang.MetaClassImpl.getProperty(MetaClassImpl.java:1368)
at groovy.lang.MetaClassImpl.getProperty(MetaClassImpl.java:2578)
at org.codehaus.groovy.runtime.InvokerHelper.getProperty(InvokerHelper.java:178)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.getProperty(ScriptBytecodeAdapter.java:474)
at Script1.run(Script1.groovy)
at oracle.jbo.ExprEval.internalEvaluateGroovyScript(ExprEval.java:741)
... 50 more
## Detail 0 ##
groovy.lang.MissingPropertyException: Exception evaluating property 'id' for java.util.Arrays$ArrayList, Reason: groovy.lang.MissingPropertyException: No such property: id for class: java.lang.Double
at org.codehaus.groovy.runtime.DefaultGroovyMethods.getAt(DefaultGroovyMethods.java:2978)
at groovy.lang.MetaClassImpl.getProperty(MetaClassImpl.java:1368)
at groovy.lang.MetaClassImpl.getProperty(MetaClassImpl.java:2578)
at org.codehaus.groovy.runtime.InvokerHelper.getProperty(InvokerHelper.java:178)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.getProperty(ScriptBytecodeAdapter.java:474)
at Script1.run(Script1.groovy)
at oracle.jbo.ExprEval.internalEvaluateGroovyScript(ExprEval.java:741)
at oracle.jbo.ExprEval.doEvaluate(ExprEval.java:779)
at oracle.jbo.ExprEval.evaluateForRow(ExprEval.java:690)
at oracle.jbo.server.AttributeDefImpl.evaluateTransientExpression(AttributeDefImpl.java:1816)
at oracle.jbo.server.ViewRowStorage.getAttributeInternal(ViewRowStorage.java:1554)
at oracle.jbo.server.ViewRowImpl.getAttributeValue(ViewRowImpl.java:1634)
at oracle.jbo.server.ViewRowImpl.getAttributeInternal(ViewRowImpl.java:746)
at oracle.adf.model.bean.DCDataRow.getAttributeInternal(DCDataRow.java:352)
at oracle.jbo.server.ViewRowImpl.getKey(ViewRowImpl.java:598)
at oracle.adf.model.bean.DCDataRow.getKey(DCDataRow.java:149)
at oracle.adf.model.binding.DCIteratorBinding.buildFormToken(DCIteratorBinding.java:3836)
at oracle.adf.model.binding.DCBindingContainerState.buildStringBuffer(DCBindingContainerState.java:71)
at oracle.adf.model.binding.DCBindingContainerState.toString(DCBindingContainerState.java:590)
at oracle.adf.model.binding.DCBindingContainer.getStateToken(DCBindingContainer.java:4293)
at oracle.adfinternal.controller.application.model.SaveStateTokenListener.afterPhase(SaveStateTokenListener.java:54)
at oracle.adfinternal.controller.lifecycle.ADFLifecycleImpl$PagePhaseListenerWrapper.afterPhase(ADFLifecycleImpl.java:529)
at oracle.adfinternal.controller.lifecycle.LifecycleImpl.internalDispatchAfterEvent(LifecycleImpl.java:118)
at oracle.adfinternal.controller.lifecycle.LifecycleImpl.dispatchAfterPagePhaseEvent(LifecycleImpl.java:166)
at oracle.adfinternal.controller.faces.lifecycle.ADFPhaseListener$PhaseInvokerImpl.dispatchAfterPagePhaseEvent(ADFPhaseListener.java:122)
at oracle.adfinternal.controller.faces.lifecycle.ADFPhaseListener.afterPhase(ADFPhaseListener.java:68)
at oracle.adfinternal.controller.faces.lifecycle.ADFLifecyclePhaseListener.afterPhase(ADFLifecyclePhaseListener.java:51)
at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._executePhase(LifecycleImpl.java:354)
at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:203)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292)
at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
at oracle.adf.model.servlet.ADFBindingFilter.doFilter(ADFBindingFilter.java:181)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
at oracle.adfinternal.view.faces.webapp.rich.RegistrationFilter.doFilter(RegistrationFilter.java:85)
at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:278)
at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._invokeDoFilter(TrinidadFilterImpl.java:238)
at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._doFilterImpl(TrinidadFilterImpl.java:195)
at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl.doFilter(TrinidadFilterImpl.java:138)
at org.apache.myfaces.trinidad.webapp.TrinidadFilter.doFilter(TrinidadFilter.java:92)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
at oracle.security.jps.wls.JpsWlsFilter.doFilter(JpsWlsFilter.java:102)
at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:65)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3496)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(Unknown Source)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2180)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2086)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1406)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)I try to print out a singlue AVG value in this way (main method of javaServerFacade class):
public static void main(String [] args) {
final JavaServiceFacade javaServiceFacade = new JavaServiceFacade();
// TODO: Call methods on javaServiceFacade here...
List<Polls> pollsAVG = javaServiceFacade.queryPollsFindAVG();
for (Polls a: pollsAVG){
System.out.println(a.getValue1());
...I get this error:
Exception in thread "main" java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to oracle.model.Polls
at oracle.model.JavaServiceFacade.main(JavaServiceFacade.java:25)
Process exited with exit code 1.
...I've searched for Ljava in the documantation finding nothing interesting. -
SQLException syntax error in query
I am baffled and hoping that maybe you can spot an error in my query - I can't seem to find it!
The query is:
INSERT INTO CreditCard (userID, type, name, number, expiration, addressID) VALUES (5, 1, 'Bill', '1264', 2004-04-10, 9)
And in code it is:
String sql = "INSERT INTO CreditCard (userID, type, name, number," + " expiration, addressID) VALUES (" + userId + ", " + type + ", \'" + name + "\', \'" + number + "\', " + expiration + ", " + addressId + ")";
I keep getting error for this line:
stmt.execute(sql);
with the following message:
java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement.
at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6879)
at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7036)
at sun.jdbc.odbc.JdbcOdbc.SQLExecDirect(JdbcOdbc.java:3065)
at sun.jdbc.odbc.JdbcOdbcStatement.execute(JdbcOdbcStatement.java:338)
at jauction.server.CreditCardImpl.<init>(CreditCardImpl.java:65)
at jauction.server.CreditCardTest.main(CreditCardTest.java:14)
Do you spot the syntax error in the query? Is there any other reason why I could be getting this error?
Similar INSERT INTO queries have been implemented and tested in this project of mine and they are working fine. I am baffled as to where the syntax error is in this query. If you spot it - could you point it out? Thanks.Thanks man, you saved me hours of debugging.
I had an Access table with a column named TimeStamp, just couldn't get the damn thing to work. But I think both our problems are JDBC/SQL related, not Access related. In other words, it wouldn't work on any other RDBMS system either.
Someone should put it in the documentation somewhere that using SQL datatype names for column names is a no-no.
Maybe you are looking for
-
I have a iPhone 4s and I was trying to download an app but it kept saying 'Your Apple ID has been disabled.' I'm not quite sure why this is happening but I googled what to do and it said I should make a new Apple ID account, I did this and then I tri
-
IPad to Apple TV to Projector Wirelessly
I want to be able to play videos wirelessly from my IPAD to my a flat screen monitor. I have been told that I will need IPAD2 with current firmware, Apple TV, and an active Itunes account. This is my understanding how this should work. I need to set
-
I am trying to create a treetable with some dynamic columns. The extra columns I need to show have been added as attributes to the node. So within the facet "nodeStamp" I display the label and need to add other columns dynamically reading the attribu
-
I enabled iTunes Plus accidentally and now I can't disable it
What do I do?
-
BAPI values in the Webdynpro dropdownbox
Hi All, Is there a way to get the BAPI values in the Webdynpro dropdownbox? Thanks in advance, Pravin