Syntax error in insert query

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.

Similar Messages

  • Syntax error in INSERT STATEMENT

    A problem on the date part of the query but why I don´t
    know, Thanks for any pointers,
    TIA
    <cfquery name="update1" datasource="trevor_SecurityDB">
    INSERT INTO imagesproducts
    (title, info, date)
    VALUES ( '#form.title#', '#form.info#', '#DateFormat(Now())#'
    </cfquery>
    Error Occurred While Processing Request
    Error Executing Database Query.
    [Macromedia][SequeLink JDBC Driver][ODBC
    Socket][Microsoft][ODBC Microsoft Access Driver] Syntax error in
    INSERT INTO statement.
    The error occurred in uploadmember.cfm: line 28
    26 : INSERT INTO imagesproducts
    27 : (title, info, date)
    28 : VALUES ( '#form.title#', '#form.info#',
    '#DateFormat(Now())#' )
    29 : </cfquery>
    30 :
    SQL INSERT INTO imagesproducts (title, info, date) VALUES (
    'News test', 'Testing news info', '12-Jul-07' )
    DATASOURCE trevor_SecurityDB
    VENDORERRORCODE -3502
    SQLSTATE 42000

    Perhaps it is a reserved word issue with the date column,
    since
    date is an ODBC Reserved Keyword. You might try enclosing it
    within brackets [ ].
    <cfquery name="update1" datasource="trevor_SecurityDB">
    INSERT INTO imagesproducts
    (title, info, [date])
    VALUES ( '#form.title#', '#form.info#', '#DateFormat(Now())#'
    </cfquery>
    Or, if that doesn't help, you might try using a cfqueryparam
    tag for the '#DateFormat(Now())#' value using a cfsqltype =
    "CF_SQL_TIMESTAMP" (assuming a date/time datatype on the column).
    Also, you might look into using one of the CreateODBCDateTime() or
    CreateODBCDate() functions.
    Phil

  • 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...
    Budituta

    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.

  • 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.formCustNum

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

  • Syntax Error in the Query

    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 AM

    HI
    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

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

  • 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();

  • 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

  • Syntax error in insert into

    Hi,
    I'm new to coldfusion and was doing a practice survey. I'm
    getting the following error:
    The INSERT INTO statement contains the following unknown
    field name: &apos;recipes&apos;. Make sure you have typed
    the name correctly, and try the operation again.
    The error occurred in (coldfusion form): line 405
    403 :
    (lname,fname,yourID,status,preprog_survey,recipes,activity,tips,stress,other,othertext,we ight_result,lbs_gained,lbs_lost,behaviors,desc_behaviors,most_help,improve_prog)
    404 : values
    405 :
    ('#lname#','#fname#','#yourID#','#status#','#preprog_survey#','#recipes#','#activity#','# tips#','#stress#','#other#','#othertext#','#weight_result#','#lbs_gained#','#lbs_lost#','# behaviors#','#desc_behaviors#','#most_help#','#improve_prog#')
    406 : </cfquery>
    407 :
    SQL Insert into maintaint
    (lname,fname,yourID,status,preprog_survey,recipes,activity,tips,stress,other,othertext,we ight_result,lbs_gained,lbs_lost,behaviors,desc_behaviors,most_help,improve_prog)
    values ('last name','first
    name','444444','member,'No','0','0','1','0','1','no work, all
    play','gained',' too many','','Yes','Dreaming of eating better, but
    not doing it','This survey!','no improvement suggestions'
    VENDORERRORCODE -3502
    SQLSTATE 42000
    Can anyone tell me what this possibly means? I'm sure its
    probably hard to understand without seeing the form. These are the
    types of fields each are:
    lname, fname, yourID = text
    status = radio
    preprog_survey = radio
    recipes, activity,tips, stress, other, = checkboxes
    othertext, = text
    weight_result, = radio
    lbs_gained,lbs_lost, = text
    behaviors, = radio
    desc_behaviors, most_help, improve_prog = text

    Looking at the code you supplied I noticed that for the
    checkboxes values where '0' and '1'.
    SQL Insert into maintaint
    (lname,fname,yourID,status,preprog_survey,recipes,activity,tips,stress,other,othertext,we ight_result,lbs_gained,lbs_lost,behaviors,desc_behaviors,most_help,improve_prog)
    values ('last name','first
    name','444444','member,'No','0','0','1','0','1','no work, all
    play','gained',' too many','','Yes','Dreaming of eating better, but
    not doing it','This survey!','no improvement suggestions'
    You don't need quotes around numeric values, only text.
    Hope that helps you.

  • Error in insert query

    stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
         String query =
         "insert into log1(converted_time,elapsed_time,client_ip,status_code,data_received,request_method,url,lookup_info,host_ip,object_type,system_time)values("+Fields[0]+","+Fields[1]+","+Fields[2]+","+Fields[3]+","+Fields[4]+","+Fields[5]+","+Fields[6]+","+Fields[7]+","+Fields[8]+","+Fields[9]+","+Fields[10]+")";
         System.out.println("\nExecuting query : "+query);
         rset = stmt.executeQuery(query);
         System.out.println("data inserted");
    this is the error i get
    java.sql.SQLException: SQL string is not Query

    Since you use JDBC API to insert this row into the table... you should post this problem to:
    http://forums.oracle.com/forums/forum.jspa?forumID=99
    Sim

  • 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 formatted

    Use a prepared statement.
    And after you start doing that then put a space in front of the 'where'

  • Syntax error in Merge Query

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

    Here 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

  • 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?
    /Enric

    Replying 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

  • Syntax errors in update query

    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

  • Free of charge item processing - France business requirement

    Hi, For free of charge sales, the net value of an item is made to zero using free item category in the sales order and the billing with zero value is released to accounting. One of the requirements for France is for Free of charge items, though the v

  • Final Cut Pro Video Playback not in Widescreen for Anamorphic Material

    I have a Panasonic DVX-100B hooked up to my computer and am running Final Cut Pro. I shot everything in the anamorphic squeeze mode. When I play this material back through my camera (which displays the material as widescreen because I forced it on th

  • Transportation zone does not exists

    hi, its urgent plz resolve this i have to create the bdc program so before there is a problem in transportation zone fields in xd01 , i am give the data for particular fields but it does not exists while am press the f4 key, it should ask the project

  • Why is exception not thrown in AseCommand when "Truncation error occurred"?

    In the below SQL, data is written to SOURCE and from there to TARGET. The DECIMAL columns in TARGET are deliberately smaller than those in SOURCE (eg a DECIMAL (12, 2) column populated from a DECIMAL (19,11) source). When I run this in an Query tool

  • Newbie, video not smooth

    I am new in OSMF development. I created a video player with F4M format. but that happens with the video is not smooth. displacement between the bitrate does not happen. Which part should I change in the OSMF library, I use flash builder to create OSM