QT 4 - MySql 5.1 - QtSql tárolt eljárás

Fórumok

Sziasztok!

Nem találom a megoldást, lehet-e egyáltalán?

Ha a tárolt eljárás a paraméterein (Out, InOut) kívül táblát vagy táblákat is ad vissza,
akkor azt hogy a manóba tudom kinyerni? (persze prepared query!!)

(.Net alatt ez tökéletesen működik)

Hozzászólások

Siman a result-on keresztul probaltad mar?
--

Ki oda vagyik, hol szall a galamb, elszalasztja a kincset itt alant. | Gentoo Portal 

Naná, hogy próbáltam de a nagy semmit adja vissza, hibaüzenet nélkül.

Odáig eljutottam, hogy a prepared query nélkül közvetlenül tuszkolom akkor jó, de ha prepared query-vel üres result (a paraméterek rendben jönnek, tehát jól lefut):

OK:

sql = "CALL sp_test(@1, @2)";
query->exec(sql);

> query->result()->d->isSel = true
> query->result()->active() = true
> query->result()->size() = 10

NEM OK:

sql = "CALL sp_test(:A, @2)";

query->prepare(sql);
query->bindValue(":A", 0, QSql::In);
query->exec();

> query->result()->d->isSel = false
> query->result()->active() = true
> query->result()->size() = -1

Én anno mikor ilyet cseszegettem utoljára ugyanúgy adta vissza a resultot mint egy sima select * from whatever, ellentétben a delphivel, amiben képtelenség volt eljárást meghívni.

Esetleg ez lehet a gond?

"MySQL 5 introduces stored procedure support at the SQL level, but no API to control IN, OUT and INOUT parameters. Therefore, parameters have to be set and read using SQL commands instead of QSqlQuery::bindValue()."

Szia,

Kimásoltam az "Assistant"-ból

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
Note that unbound parameters will retain their values.
Stored procedures that uses the return statement to return values, or return multiple result sets, are not fully supported. For specific details see SQL Database Drivers (lent bemásolva a MySQL rész).
Warning: You must load the SQL driver and open the connection before a QSqlQuery is created. Also, the connection must remain open while the query exists; otherwise, the behavior of QSqlQuery is undefined.
See also QSqlDatabase, QSqlQueryModel, QSqlTableModel, and QVariant.

SQL Database Drivers:
QMYSQL Stored Procedure Support (QMYSQL for MySQL 4 and higher)
MySQL 5 introduces stored procedure support at the SQL level, but no API to control IN, OUT and INOUT parameters. Therefore, parameters have to be set and read using SQL commands instead of QSqlQuery::bindValue().
Example stored procedure:
create procedure qtestproc (OUT param1 INT, OUT param2 INT)
BEGIN
set param1 = 42;
set param2 = 43;
END
Source code to access the OUT values:
QSqlQuery q;
q.exec("call qtestproc (@outval1, @outval2)");
q.exec("select @outval1, @outval2");
q.next();
qDebug() << q.value(0) << q.value(1); // outputs "42" and "43"
Note: @outval1 and @outval2 are variables local to the current connection and will not be affected by queries sent from another host or connection.

Attila, Perger
-----------------------------------------------------
"Az a szoftver, amelyiket nem fejlesztik, az halott!"

Köszi, de ez sem segített, nem látom a szövegben konkrétan azt ami a problémámról szól.
(nyilván én vagyok értetlen)

A kódrészletem alapján működik a bind IN, az SQL @var INOUT,OUT, és a result is, csak egyszerre nem.

Ez az én bénaságom vagy a driver bénasága?

Számomra a "are not fully supported", az hogy a bind nem kezeli az OUT-ot, ez elég nagy gáz de mindegy. Ha megy a Bind IN és megy a table result, a kettő együtt miért zárná ki egymást?
Az idézett szövegben ez hol van?

Oke, en mar sejtem mit akart mondani: a Qt olyan procokat tamogat, ami a resultsetet beleteszi egy OUT valtozoba, es ezt mar el tudod kerni SELECT-tel. Tehat nem siman csak elkiabalsz egy SELECT-et, hanem a SELECT eredmenyet bele kell tenned egy OUT valtozoba, es - mivel ez elmeletileg egy tranyon belul fut - utana mar el tudod kerni ugy, hogy SELECT @outvar.

(Nem sok stored prochoz volt kozom, igy az egeszet csak nagy altalanossagokban ertem, nezd el nekem, ha valahol nem voltam szabatos).
--

Ki oda vagyik, hol szall a galamb, elszalasztja a kincset itt alant. | Gentoo Portal