Query Syntax error

后端 未结 4 1790
渐次进展
渐次进展 2021-01-27 23:14

Please help me correct the following query:

SQL = \"insert into tblContract (Empid, Start1, Finish1, Store1, \" & _
                    \"Start2, Finish2, St         


        
4条回答
  •  天涯浪人
    2021-01-27 23:53

    You need to re-write your VALUES clause as a SELECT query.

    You have seven columns in your INSERT clause and eight in your VALUES clause. From the column names I guess your subquery

    select max(testid) FROM tbltesting
    

    is missing a destination. Guessing it may be called starting_testid; also guessing data types (Access database engine ANSI-92 Query Mode syntax):

    CREATE PROCEDURE AddContract
    (
     :Empid INTEGER, 
     :Start1 DATETIME, 
     :Finish1 DATETIME,
     :Store1 VARCHAR(20), 
     :Start2 DATETIME,
     :Finish2 DATETIME,
     :Store2 VARCHAR(20)
    )
    AS
    insert into tblContract 
    ( 
     Empid, starting_testid, 
     Start1, Finish1, Store1, 
     Start2, Finish2, Store2
    )
    SELECT :Empid, max(testid), 
           :Start1, :Finish1, :Store1, 
           :Start2, :Finish2, :Store2
      FROM tbltesting;
    

提交回复
热议问题