int main(int argc, char *argv[]){ IBPP::Database db1; db1 = IBPP::DatabaseFactory("localhost", "D:\\projects\\test\\realtyad.fdb", "sysdba", "masterkey"); db1->Connect(); IBPP::Transaction tr1 = IBPP::TransactionFactory(db1, IBPP::amWrite, IBPP::ilConcurrency, IBPP::lrWait); tr1->Start(); IBPP::Statement st1 = IBPP::StatementFactory(db1, tr1); st1->Execute("insert into R (NAME, PHONE1) values ('John Doe', '58-29-58') returning ID"); tr1->Commit(); int test_id; st1->Get(1, test_id); std::cout << "returned id is " << test_id << std::endl; db1->Disconnect(); return 0;}
bool QIBaseResult::gotoNext(QSqlCachedResult::ValueCache& row, int rowIdx){ ISC_STATUS stat = 0; // Stored Procedures are special - they populate our d->sqlda when executing, // so we don't have to call isc_dsql_fetch if (d->queryType == isc_info_sql_stmt_exec_procedure) { // the first "fetch" shall succeed, all consecutive ones will fail since // we only have one row to fetch for stored procedures
if (rp->iSt->IsNull(i)) { // null value QVariant v; v.convert(qIBPPTypeName(rp->iSt->ColumnType(i))); row[idx] = v; continue; }
Value: QVariant(, )
QSqlQuery q("INSERT INTO SYS$ACTIONS(ID,CAPTION) VALUES(NULL,'CAPTION') RETURNING ID",db); while(q.next()) qDebug() << "Value: " << q.value(0);
строки 681-697 bool stat = true; if (IBPP::stExecProcedure == rp->iSt->Type()) { if (0 != rowIdx) stat = false; } else try { stat = rp->iSt->Fetch(); } catch (IBPP::Exception& e) { rp->setError("Could not fetch next item", e, QSqlError::StatementError); return false; }строка 410 iss = (iSt->Type() == IBPP::stSelect || (iSt->Type() == IBPP::stExecProcedure && 0 < iSt->Columns()));
QSqlQuery q("INSERT INTO SYS$ACTIONS(ID,CAPTION) VALUES(NULL,'CAPTION') RETURNING ID",db); QSqlQuery q("SELECT ID FROM SYS$ACTIONS",db); while(q.next()) qDebug() << "Value: " << q.value(0);
SET TERM ^ ;CREATE OR ALTER PROCEDURE SYS$UIDGENERATOR ( UIDNAME VARCHAR(40))RETURNS ( UID BIGINT)ASDECLARE VARIABLE TEMPUID BIGINT;begin SELECT VAL FROM SYS$UIDS WHERE ID = :UIDNAME INTO :TEMPUID; UPDATE SYS$UIDS SET VAL = :TEMPUID + 1 WHERE ID = :UIDNAME; UID = :TEMPUID; SUSPEND;end^SET TERM ; ^GRANT SELECT,UPDATE ON SYS$UIDS TO PROCEDURE SYS$UIDGENERATOR;GRANT EXECUTE ON PROCEDURE SYS$UIDGENERATOR TO SYSDBA;
CREATE TABLE SYS$UIDS ( ID VARCHAR(40), VAL BIGINT DEFAULT 0 NOT NULL);