Syntax error in ABAP Query
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?
Thanks
Hi,
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.
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. -
How to check syntax errors in ABAP Queries
HI Guys,
How to check syntax errors in ABAP queries, Can please provide the T-Codes.
Advande thanks to everybody.
Thanks,
GourisankarHi
with these you can check syntax errors and performance points
Hi
these all are doing t he same thing that is checking the program for better performance
Tools for Performance Analysis
Run time analysis transaction SE30
SQL Trace transaction ST05
Extended Program Check (SLIN)
Code Inspector ( SCI)
Run time analysis transaction SE30 :This transaction gives all the analysis of an ABAP program with respect to the database and the non-database processing.
SQL Trace transaction ST05: The trace list has many lines that are not related to the SELECT statement in the ABAP program. This is because the execution of any ABAP program requires additional administrative SQL calls. To restrict the list output, use the filter introducing the trace list.
The trace list contains different SQL statements simultaneously related to the one SELECT statement in the ABAP program. This is because the R/3 Database Interface - a sophisticated component of the R/3 Application Server - maps every Open SQL statement to one or a series of physical database calls and brings it to execution. This mapping, crucial to R/3s performance, depends on the particular call and database system. For example, the SELECT-ENDSELECT loop on a particular database table of the ABAP program would be mapped to a sequence PREPARE-OPEN-FETCH of physical calls in an Oracle environment.
The WHERE clause in the trace list's SQL statement is different from the WHERE clause in the ABAP statement. This is because in an R/3 system, a client is a self-contained unit with separate master records and its own set of table data (in commercial, organizational, and technical terms). With ABAP, every Open SQL statement automatically executes within the correct client environment. For this reason, a condition with the actual client code is added to every WHERE clause if a client field is a component of the searched table.
To see a statement's execution plan, just position the cursor on the PREPARE statement and choose Explain SQL. A detailed explanation of the execution plan depends on the database system in use.
Extended Program Check
This can be called in through transaction SE38 or through transaction SLIN. This indicates possible problems that may cause performance problems.
Code Inspector (SCI)
You can call the Code Inspector from the ABAP Editor (SE38), the Function Builder (SE37), the Class Builder (SE24), or as a separate transaction (SCI).
The Code Inspector indicates possible problems. However, note that, especially with performance issues: There is no rule without exception. If a program passes an inspection, it does not necessarily mean that this program will have no performance problems.
reward if usefull -
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 -
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. -
hi
experts,
i am developing a report using abap query .(stand t code is s_alr_87012277 it contain more fields but i want only 4 fields , i found 2 but remaining 2 are from structure)
my problem is that debit and credit amount is in structure
how i can get data from structure(FAGL_S_RFSSLD00_LIST )
solbm = debit.
habbm = credit.
report is like
op.
gl acc no, discription, credit amount,debit amount.Hi ajay,
try to use with logical database SDF.
assign the logical database name in info set.
gl acc no - SKA1-SAKNR
debit. - Field: um02h
credit. - field: um02s
discription - SKAT-TXT20
regards,
sateesh. -
Syntax error in ABAP HR program
Hello Experts,
I am new to programming in HR. I am getting a syntax error "PERNR is not defined for the current logical database" with the following piece of code.
TABLES: PERNR.
INFOTYPES: 0002, 0006.
GET PERNR.
PROVIDE * FROM P0002 BETWEEN PN-BEGDA AND PN-ENDDA.
WRITE: P0002-PERNR, P0002-NACHN, P0002-VORNA.
ENDPROVIDE.
Am I missing a statement or something needs to be configured in the system?
Any help will be highly appreciated.
thanks...
Rony.HI,
your code works perfectly well.. I have added the PNP logical database and selection screen 100... i think you r not added this PNP logical database
*& Report ZTESTPRG *
REPORT ZTESTPRG .
TABLES: PERNR.
INFOTYPES: 0002, 0006.
GET PERNR.
PROVIDE * FROM P0002 BETWEEN PN-BEGDA AND PN-ENDDA.
WRITE: P0002-PERNR, P0002-NACHN, P0002-VORNA.
ENDPROVIDE.
Thanks
mahesh -
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 -
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'
Maybe you are looking for
-
I have created a page with a "New party" button that opens a popup. It clears that cache for the popup and works fine. The new party can be entered and "create"d. The page branches to itself and the create button is not displayed. The new party data
-
Starting Mythfrontend on tv-out - gnome [solved]
I've been running mythtv on KDE3, running it on my TV. I did a full system upgrade and with KDE4, my KDE desktop does not extend onto my tv, although I have a mousepointer on a black background. To hopefully get the system back up and running while
-
Hi Guys, I need to show the open POs in report. The user will input one date called 'key date' and 'lead time' in days. Now the calculation should be like the report will show those POs where : Key date < Gr posting date(present in the ODS) OR GR pos
-
Öffnen eine mit Premiere Pro 2.0 erselten Projektes in Premiere Pro CS5.5
Ich habe mir nach einer Zusage Ihres Hauses dass ich meine alten Projekte ohne Schwierigkeitn im CS5.5. weiter bearbeiten kann, die neueste Software von Ihnen besorgt. Ich kann das alte Projekt zwar öffnen, doch leider nicht im Schnittfenster weiter
-
Checking error message using Exception ID
Hello, How can I search the log files using an Exception ID? I can goto the NetWeaver administrator, and open the Logs and Traces screen. The log file is also getting displayed. But how can I do a search on the Exception ID, so that I can find my err