連續執行insert語句報錯,在plsql可正常運行,但寫入Delphi程序中就報錯,
General SQL error. ORA-00911:字元無效。
Debug了許久,始終找不到問題,終於透過 google 大師找到解答。
via http://www.lslnet.com/linux/f/docs1/i46/big5320278.htm
[Solution]
ORA-00911: invalid character
Cause: Special characters are valid only in certain places. If special characters other than $, _, and # are used in a name and the name is not enclosed in double quotation marks ("), this message will be issued. One exception to this rule is for database names; in this case, double quotes are stripped out and ignored.
Action: Remove the invalid character from the statement or enclose the object name in double quotation marks.
sSQL := 'INSERT INTO EMPLOYEES' + #13#10 +
' (EMP_EMPNO, EMP_DEPTNO, EMP_EMPNAME, EMP_JOB, EMP_PASSWORD,' + #13#10 +
' EMP_STARTDATE, EMP_ENDDATE, EMP_SEX, EMP_BLOOD, EMP_BIRDATE,' + #13#10 +
' EMP_IDNO, EMP_TELNO1, EMP_TELNO2,EMP_ADDR, EMP_MARRY)' + #13#10 +
'VALUES' + #13#10 +
' (:sEMP_EMPNO, :sEMP_DEPTNO, :sEMP_EMPNAME, :sEMP_JOB, :sEMP_PASSWORD,' + #13#10 +
' :sEMP_STARTDATE, :sEMP_ENDDATE, :sEMP_SEX, :sEMP_BLOOD, :sEMP_BIRDATE,' + #13#10 +
' :sEMP_IDNO, :sEMP_TELNO1, :sEMP_TELNO2, :sEMP_ADDR, :sEMP_MARRY);'
原來只是將組成的SQL語法裡的;分號拿掉,就可以正常運行了~~ ^__^。
因為從plsql developer直接將語法 special copy Delphi 方式,連分號也一併copy進去了。
沒有留言:
張貼留言