C++ (Qt)QSqlQuery query;query.prepare( "select FIELD_1, FIELD_2 from SP_STORED_PROC( :PARAM_1, :PARAM_2 ) " );query.bindValue( ":PARAM_1", 666 );query.bindValue( ":PARAM_2", 999 );query.exec(); query.first(); // QSqlRecord rec = query.record(); qDebug() << query.value( rec.indexOf("FIELD_1") );qDebug() << query.value( rec.indexOf("FIELD_2") );
QSqlQuery query; query.setForwardOnly(true); query.prepare("{CALL fp_test(?,?,?)}"); query.addBindValue(strName); query.addBindValue(strValue,QSql::Out); query.addBindValue(n,QSql::Out); if (!query.exec()) {QMessageBox::information(0, QObject::tr("Error"), "Ошибка"); return 1; } strValue = query.boundValue(1).toString(); n = query.boundValue(2).toInt();; QMessageBox::information(0, QString().setNum(n), strValue);
QString strName = "QSql::In string"; QString strValue; strValue.reserve(51); int n = 0; QSqlQuery query; //query.setForwardOnly(true); query.prepare("{CALL fp_test(?,?,?)}"); query.bindValue("Name",strName); query.bindValue("Value", strValue,QSql::Out); query.bindValue("Number",n,QSql::Out); if (!query.exec()) { QMessageBox::information(0, QObject::tr("Error"), "Ошибка"); return 1; } strName = query.boundValue("Name").toString(); // "QSql::In string" strValue = query.boundValue("Value").toString(); // "test" n = query.boundValue("Number").toInt(); // 123