Gar*_*ary -1 oracle coldfusion sql-insert
我试图将记录从Coldfusion插入Oracle DB 11(g),但错误日志显示ORA-00911:无效字符。我可以从Oracle DB中选择记录,但无法插入。
下面是我的代码。
<cfquery name="qOracleData" datasource="Oracle_Test">
Insert into postindept (deptid, propos_position, descr, sm_descr60, grade) values ('1','110000 ', '110000 ','510000 ' ,'10');
COMMIT;
</cfquery>
Run Code Online (Sandbox Code Playgroud)
Oracle每个查询仅支持一个语句。COMMIT;从insert语句中删除(您不需要,因为事务将自动提交)和结尾的分号。
另外,如果要插入数字值,则不应将它们作为字符串传递:
<cfquery name="qOracleData" datasource="Oracle_Test">
Insert into postindept (
deptid, propos_position, descr, sm_descr60, grade
) values (
1, 110000, 110000, 510000, 10
)
</cfquery>
Run Code Online (Sandbox Code Playgroud)
您可以使用bind参数:
<cfquery name="qOracleData" datasource="Oracle_Test">
Insert into postindept (
deptid,
propos_position,
descr,
sm_descr60,
grade
) values (
<cfqueryparam value = "1" cfsqltype = "CF_SQL_NUMERIC" />,
<cfqueryparam value = "110000" cfsqltype = "CF_SQL_NUMERIC" />,
<cfqueryparam value = "110000" cfsqltype = "CF_SQL_NUMERIC" />,
<cfqueryparam value = "510000" cfsqltype = "CF_SQL_NUMERIC" />,
<cfqueryparam value = "10" cfsqltype = "CF_SQL_NUMERIC" />
)
</cfquery>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
81 次 |
| 最近记录: |