我想在表中使用BeginTrans ... CommitTrans插入多行。
下面的代碼片段:使用VB6在Oracle中插入多行
For i = 1 To 5
SQL = SQL & "Insert into TestTable(Field1,Field2,Field3) Values ('Col" & i & "','Col" & i + 1 & "','Col" & i + 2 & "')" & vbCrLf
Next i
conn.BeginTrans
conn.Execute SQL
conn.CommitTrans
和下面是SQL編寫的使用循環
Insert into TestTable(Field1,Field2,Field3) Values ('Col1','Col2','Col3')
Insert into TestTable(Field1,Field2,Field3) Values ('Col2','Col3','Col4')
Insert into TestTable(Field1,Field2,Field3) Values ('Col3','Col4','Col5')
Insert into TestTable(Field1,Field2,Field3) Values ('Col4','Col5','Col6')
Insert into TestTable(Field1,Field2,Field3) Values ('Col5','Col6','Col7')
當我運行conn.CommitTrans
我得到ORA-00911:無效字符
如果我修改SQL as
Insert into TestTable(Field1,Field2,Field3) Values ('Col1','Col2','Col3');
Insert into TestTable(Field1,Field2,Field3) Values ('Col2','Col3','Col4');
Insert into TestTable(Field1,Field2,Field3) Values ('Col3','Col4','Col5');
Insert into TestTable(Field1,Field2,Field3) Values ('Col4','Col5','Col6');
Insert into TestTable(Field1,Field2,Field3) Values ('Col5','Col6','Col7');
I得到ORA-00933:SQL命令未正確結束。
如果我進一步更新並替換「;」與「/」再次得到相同的錯誤
任何幫助,非常感謝。
ThanX提前...