我遇到了一个Oracle问题,到目前为止我无法找到原因.下面的查询适用于Oracle SQL开发人员,但在.NET中运行时会抛出:
ORA-01008:并非所有变量都绑定
我试过了:
SELECT rf.myrow floworder, rf.stage, rf.prss,
rf.pin instnum, rf.prid, r_history.rt, r_history.wt
FROM
(
SELECT sub2.myrow, sub2.stage, sub2.prss, sub2.pin, sub2.prid
FROM (
SELECT sub.myrow, sub.stage, sub.prss, sub.pin,
sub.prid, MAX(sub.target_rn) OVER (ORDER BY sub.myrow) target_row
,sub.hflag
FROM (
WITH floc AS
(
SELECT flow.prss, flow.seq_num
FROM rpf@mydblink flow
WHERE flow.parent_p = :lapp
AND flow.prss IN (
SELECT r_priprc.prss
FROM r_priprc@mydblink r_priprc
WHERE priprc = :lot_priprc
)
AND rownum = 1
)
SELECT …
Run Code Online (Sandbox Code Playgroud) 我使用以下方法通过使用jdbc计算工资单,但"ORA-01008:并非所有变量绑定"错误都没有删除.
有什么好主意吗?
我正在使用以下代码
public double getPayroll(){
ResultSet rs = null;
ResultSet rs1 = null;
ResultSet rs2 = null;
Connection conn = null;
PreparedStatement pstmt = null;
try {
conn = getDBConnection();
double dailyPay=0,basicPay=0,payroll2=0;
int houseRent=0,convAllow=0,noOfPresents=0,empId=0;
String q = "select e_id from employee";
pstmt = conn.prepareStatement(q);
rs = pstmt.executeQuery();
while (rs.next()) {
empId=rs.getInt(1);
String q1 = "select count(att_status) from attendance where att_status='p'";
pstmt = conn.prepareStatement(q1);
rs1 = pstmt.executeQuery(q1);
while(rs1.next()){
noOfPresents=rs1.getInt(1);
String q2 = "select e_salary,e_house_rent,e_conv_allow from employee where e_id=?";
pstmt = …
Run Code Online (Sandbox Code Playgroud) 我正在使用System.Data.OracleClient
它按名称进行参数绑定,并验证CommandText和Parameters是否同步:
public string CommandText { get; set; }
public IEnumerable<OracleParameter> Parameters { get; set; }
private void VerifyThatAllParametersAreBound()
{
var variableNames = Regex.Matches(CommandText, ":\\w+")
.Cast<Match>().Select(m => m.Value).ToArray();
var parameteterNames = Parameters.Select(p => p.ParameterName).ToArray();
var unboundVariables = variableNames.Except(parameteterNames).ToArray();
if (unboundVariables.Length > 0)
{
throw new Exception("Variable in CommandText missing parameter: "
+ string.Join(", ", unboundVariables) + ".");
}
var unboundParameters = parameteterNames.Except(variableNames).ToArray();
if (unboundParameters.Length > 0)
{
throw new Exception("Parameter that is not used in CommandText: "
+ string.Join(", …
Run Code Online (Sandbox Code Playgroud) 服务器: 64位Windows 2008上的Oracle 11.2g服务器
客户端: Windows XP SP3,ASP.Net 4.0,Visual Studio 2010,C#上的Oracle 11g客户端
输入大小为XML~ 1,206,500个字符(根据我将拥有的最大数据计算).
Web应用程序生成oracle存储过程用于更新数据库中的表的XML.由于XML大小非常大,因此选择的存储过程参数类型是CLOB而不是LONG,因为LONG具有32760个字符的限制.
使用CLOB作为参数类型会抛出错误"ORA-01008:并非所有变量绑定"对于相同的存储过程代码,该代码完全适用于参数类型LONG(和XML长度<32760)
OracleCommand DbUpdateCommand = null;
OracleLob tempLOB = null;
DbUpdateCommand.CommandText = "declare xx clob; begin dbms_lob.createtemporary(xx, false, 0); :tempclob := xx; end;";
DbUpdateCommand.Parameters.Add(new OracleParameter("tempclob", OracleType.Clob)).Direction = ParameterDirection.Output;
DbUpdateCommand.ExecuteNonQuery();
//Assign the value to the LOB
tempLOB = (OracleLob)DbUpdateCommand.Parameters[0].Value;
tempLOB.BeginBatch(OracleLobOpenMode.ReadWrite);
//Convert the string to byte array to write to LOB
UnicodeEncoding encoding = new UnicodeEncoding();
byte[] renewalDetailXMLBytes = encoding.GetBytes(renewalDetailXML);
tempLOB.Write(renewalDetailXMLBytes, 0, renewalDetailXMLBytes.Length); …
Run Code Online (Sandbox Code Playgroud)