• 4168阅读
  • 0回复

Regarding ODBC Procedure Example Error [复制链接]

上一主题 下一主题
离线yooi
 
只看楼主 正序阅读 楼主  发表于: 2008-11-26
— 本帖被 XChinux 执行加亮操作(2008-11-30) —
Binding values to a stored procedure:
This code calls a stored procedure called AsciiToInt(), passing it a character through its in parameter, and taking its result in the out parameter.
    QSqlQuery query;
    query.prepare("CALL AsciiToInt(?, ?)");
    query.bindValue(0, "A");
    query.bindValue(1, 0, QSql::Out);
    query.exec();
    int i = query.boundValue(1).toInt(); // i is 65

此例子中有一个地方的错误 会导致执行错误
仔细看就知道 ODBC调用Procedure的时候 应该写成 { call procedureName(par ....) }
上面的那句需要改成 { CALL AsciiToInt(?, ?) }
这样保证执行无误
快速回复
限100 字节
 
上一个 下一个