2

Oracle データベースにレコードを挿入しようとしていますが、コードは次のとおりです: ORA-00936 を取得しています:

Dim t1 As Integer = cmd3.ExecuteNonQuery() に式がありません。

3 回確認しましたが、変数が欠落していないと確信しています。助けてください!:(

Dim cmd3 As New OracleCommand
                cmd3.Connection = conn
                Dim timepara As String = Now.Hour & Now.Minute & Now.Second & Now.Millisecond
                cmd3.CommandText = "INSERT INTO d009040 (LBRCODE,ENTRYDATE,BATCHCD,SETNO,SCROLLNO,MAINSCROLLNO,POSTDATE,FEFFDATE,ACTIVITYTYPE,CASHFLOWTYPE,VALUEDATE,BOOKTYPE,DRCR,VCRACCTID,MAINACCTID,MAINMODTYPE,VCRMODTYPE,TRNCURCD,FCYTRNAMT,LCYCONVRATE,LCYTRNAMT,INSTRBANKCD,INSTRBRANCHCD,INSTRTYPE,INSTRNO,INSTRDATE,TOKENNO,PARTICULARS,SYSGENVCR,SHTOTFLAG,SHCLRFLAG,ACTOTFLAG,ACCLRFLAG,MAKER,MAKERDATE,MAKERTIME,CHECKER1,CHECKER2,CHECKER3,CHECKER4,CHECKERDATE,CHECKERTIME,NOAUTHPENDING,NOAUTHOVER,POSTFLAG,AUTHFLAG,FEFFFLAG,CANCELEDFLAG,POSTAUTHFEFFCNCL,UPDTCHKID,PARTCLEARAMT,POSTTIME) VALUES (@LBRCODE,@ENTRYDATE,@BATCHCD,@SETNO,@SCROLLNO,@MAINSCROLLNO,@POSTDATE,@FEFFDATE,@ACTIVITYTYPE,@CASHFLOWTYPE,@VALUEDATE,@BOOKTYPE,@DRCR,@VCRACCTID,@MAINACCTID,@MAINMODTYPE,@VCRMODTYPE,@TRNCURCD,@FCYTRNAMT,@LCYCONVRATE,@LCYTRNAMT,@INSTRBANKCD,@INSTRBRANCHCD,@INSTRTYPE,@INSTRNO,@INSTRDATE,@TOKENNO,@PARTICULARS,@SYSGENVCR,@SHTOTFLAG,@SHCLRFLAG,@ACTOTFLAG,@ACCLRFLAG,@MAKER,@MAKERDATE,@MAKERTIME,@CHECKER1,@CHECKER2,@CHECKER3,@CHECKER4,@CHECKERDATE,@CHECKERTIME,@NOAUTHPENDING,@NOAUTHOVER,@POSTFLAG,@AUTHFLAG,@FEFFFLAG,@CANCELEDFLAG,@POSTAUTHFEFFCNCL,@UPDTCHKID,@PARTCLEARAMT,@POSTTIME)"
                'myCommand.Parameters[0].Value = 60; 
                ''110','15-MAR-12','TR-MOBDS','5','5','5','15-MAR-12','15-MAR-12','CR','CR','15-MAR-12','ZZ','C','DS      000000000000240700000000','DS      000000000000240700000000','47','47','INR','100','1','100','0','0','99','000000000000','15-MAR-12','0','DDS CR. From Agent','1','Y','Y','Y','Y','0','15-MAR-12','12203130','0','0','0','0','15-MAR-12','12203130','0','1','P','A','F','0','0','0','0','12203130')"
                cmd3.Prepare()
                datepara = Date.Now.ToString("dd-MMM-yy")
                'myCommand1.Parameters.Add("deptno", 20) 
                cmd3.Parameters.Add("@LBRCODE", lbr)
                cmd3.Parameters.Add("@ENTRYDATE", datepara)
                cmd3.Parameters.Add("@BATCHCD", "TR-MOBDS")
                cmd3.Parameters.Add("@SETNO", k)
                cmd3.Parameters.Add("@SCROLLNO", k)
                cmd3.Parameters.Add("@MAINSCROLLNO", k) 'VALUEDATE,BOOKTYPE,DRCR,VCRACCTID,MAINACCTID,MAINMODTYPE,VCRMODTYPE,TRNCURCD,FCYTRNAMT,
                cmd3.Parameters.Add("@POSTDATE", datepara)
                cmd3.Parameters.Add("@FEFFDATE", datepara)
                cmd3.Parameters.Add("@ACTIVITYTYPE", "CR")
                cmd3.Parameters.Add("@CASHFLOWTYPE", "CR")
                cmd3.Parameters.Add("@VALUEDATE", datepara)
                cmd3.Parameters.Add("@BOOKTYPE", "ZZ")
                cmd3.Parameters.Add("@DRCR", "C") 'LCYCONVRATE,LCYTRNAMT,INSTRBANKCD,INSTRBRANCHCD,INSTRTYPE,INSTRNO,INSTRDATE,TOKENNO,
                cmd3.Parameters.Add("@VCRACCTID", internalaccount)
                cmd3.Parameters.Add("@MAINACCTID", internalaccount)
                cmd3.Parameters.Add("@MAINMODTYPE", "47")
                cmd3.Parameters.Add("@VCRMODTYPE", "47")
                cmd3.Parameters.Add("@TRNCURCD", "INR")
                cmd3.Parameters.Add("@FCYTRNAMT", amount)
                cmd3.Parameters.Add("@LCYCONVRATE", "1")
                cmd3.Parameters.Add("@LCYTRNAMT", amount)
                cmd3.Parameters.Add("@INSTRBANKCD", "0")
                cmd3.Parameters.Add("@INSTRBRANCHCD", "0")
                cmd3.Parameters.Add("@INSTRTYPE", "99")
                cmd3.Parameters.Add("@INSTRNO", "000000000000")
                cmd3.Parameters.Add("@INSTRDATE", datepara)
                cmd3.Parameters.Add("@TOKENNO", "0") 'PARTICULARS,SYSGENVCR,SHTOTFLAG,SHCLRFLAG,ACTOTFLAG,ACCLRFLAG,MAKER,MAKERDATE,MAKERTIME,
                cmd3.Parameters.Add("@PARTICULARS", "DDS CR. From Agent")
                cmd3.Parameters.Add("@SYSGENVCR", "1")
                cmd3.Parameters.Add("@SHTOTFLAG", "Y")
                cmd3.Parameters.Add("@SHCLRFLAG", "Y")
                cmd3.Parameters.Add("@ACTOTFLAG", "Y")
                cmd3.Parameters.Add("@ACCLRFLAG", "Y")
                cmd3.Parameters.Add("@MAKER", "0") 'CHECKER1,CHECKER2,CHECKER3,CHECKER4,CHECKERDATE,CHECKERTIME,NOAUTHPENDING,
                cmd3.Parameters.Add("@MAKERDATE", datepara)
                cmd3.Parameters.Add("@MAKERTIME", Now.Hour & Now.Minute & Now.Second & Now.Millisecond)
                cmd3.Parameters.Add("@CHECKER1", "0")
                cmd3.Parameters.Add("@CHECKER2", "0")
                cmd3.Parameters.Add("@CHECKER3", "0")
                cmd3.Parameters.Add("@CHECKER4", "0") 'NOAUTHOVER,POSTFLAG,AUTHFLAG,FEFFFLAG,CANCELEDFLAG,POSTAUTHFEFFCNCL,UPDTCHKID,PARTCLEARAMT,POSTTIME
                cmd3.Parameters.Add("@CHECKERDATE", datepara)
                cmd3.Parameters.Add("@CHECKERTIME", Now.Hour & Now.Minute & Now.Second & Now.Millisecond)
                cmd3.Parameters.Add("@NOAUTHPENDING", "0")
                cmd3.Parameters.Add("@NOAUTHOVER", "1")
                cmd3.Parameters.Add("@POSTFLAG", "P")
                cmd3.Parameters.Add("@AUTHFLAG", "A")
                cmd3.Parameters.Add("@FEFFFLAG", "F")
                cmd3.Parameters.Add("@CANCELEDFLAG", " ") 'UPDTCHKID,PARTCLEARAMT,POSTTIME
                cmd3.Parameters.Add("@POSTAUTHFEFFCNCL", "0")
                cmd3.Parameters.Add("@UPDTCHKID", "0")
                cmd3.Parameters.Add("@PARTCLEARAMT", "0")
                cmd3.Parameters.Add("@POSTTIME", Now.Hour & Now.Minute & Now.Second & Now.Millisecond)



                Dim str As String = cmd3.CommandText
                cmd3.CommandType = CommandType.Text
                Try
                    Dim t1 As Integer = cmd3.ExecuteNonQuery()
                Catch ex As Exception
                    msg(ex.ToString)
                End Try
4

1 に答える 1

4

以前の質問で示したように、Oracle には Sql-Server とは異なるパラメーターの構文があります。したがって、:代わりに使用します@

例えば:

Using con = New OracleConnection(connectionString)
    Dim sql = "INSERT INTO d009040 (LBRCODE,ENTRYDATE,BATCHCD,SETNO,SCROLLNO,MAINSCROLLNO,POSTDATE,FEFFDATE,ACTIVITYTYPE,CASHFLOWTYPE,VALUEDATE,BOOKTYPE,DRCR,VCRACCTID,MAINACCTID,MAINMODTYPE,VCRMODTYPE,TRNCURCD,FCYTRNAMT,LCYCONVRATE,LCYTRNAMT,INSTRBANKCD,INSTRBRANCHCD,INSTRTYPE,INSTRNO,INSTRDATE,TOKENNO,PARTICULARS,SYSGENVCR,SHTOTFLAG,SHCLRFLAG,ACTOTFLAG,ACCLRFLAG,MAKER,MAKERDATE,MAKERTIME,CHECKER1,CHECKER2,CHECKER3,CHECKER4,CHECKERDATE,CHECKERTIME,NOAUTHPENDING,NOAUTHOVER,POSTFLAG,AUTHFLAG,FEFFFLAG,CANCELEDFLAG,POSTAUTHFEFFCNCL,UPDTCHKID,PARTCLEARAMT,POSTTIME) VALUES (:LBRCODE,:ENTRYDATE,:BATCHCD,:SETNO,:SCROLLNO,:MAINSCROLLNO,:POSTDATE,:FEFFDATE,:ACTIVITYTYPE,:CASHFLOWTYPE,:VALUEDATE,:BOOKTYPE,DRCR,:VCRACCTID,:MAINACCTID,:MAINMODTYPE,:VCRMODTYPE,:TRNCURCD,:FCYTRNAMT,:LCYCONVRATE,:LCYTRNAMT,:INSTRBANKCD,:INSTRBRANCHCD,:INSTRTYPE,:INSTRNO,:INSTRDATE,:TOKENNO,:PARTICULARS,:SYSGENVCR,:SHTOTFLAG,:SHCLRFLAG,:ACTOTFLAG,:ACCLRFLAG,:MAKER,:MAKERDATE,:MAKERTIME,:CHECKER1,:CHECKER2,:CHECKER3,:CHECKER4,:CHECKERDATE,:CHECKERTIME,:NOAUTHPENDING,:NOAUTHOVER,:POSTFLAG,:AUTHFLAG,:FEFFFLAG,:CANCELEDFLAG,:POSTAUTHFEFFCNCL,:UPDTCHKID,:PARTCLEARAMT,:POSTTIME)"
    Using cmd = New OracleCommand(sql, con)
        con.Open()
        cmd.Parameters.AddWithValue(":LBRCODE", LBRCODE)
        ' add the other parameters as well ... '
        dim result = cmd.ExecuteNonQuery()
    End Using
End Using

CommandType.Text の OracleCommand によって呼び出される SQL ステートメントで名前付きパラメーターを使用する場合、パラメーター名の前にコロン (:) を付ける必要があります。

http://msdn.microsoft.com/en-us/library/system.data.oracleclient.oraclecommand.parameters.aspx

于 2012-08-29T11:48:16.997 に答える