2012-04-13 14 views
0

Ich habe diese TabelleC++ mysql gespeicherte Prozedur Fehlercode 1327

create table utilizator(
     utilizatorId bigint not null auto_increment primary key, 
     loghin varchar(500), 
     password varchar(50) not null, 
     tip bigint not null, 
     persoanaId bigint not null, 
     evenimentId bigint not null); 

und diesen Code in C++

string vU="demo",vP="1234"; 
Driver * vDriver = get_driver_instance(); 
auto_ptr<Connection> vCon(vDriver->connect(getHost(),getUser() , getPassword())); 
vCon->setSchema(getDB()); 
auto_ptr<Statement> vStmt(vCon->createStatement()); 

vStmt->execute("DROP PROCEDURE IF EXISTS fLoghin"); 
vStmt->execute("CREATE PROCEDURE fLoghin(in pUser varchar(200),in pPass varchar(200),out pUId int,out pTip int,out pEId int) BEGIN select utilizatorId into pUId ,tip into pTip,evenimentId into pEId from utilizator where loghin=pUser and password=pPass ; END ; "); 
vStmt->execute("CALL fLoghin("+vU+","+vP+", @out1,@out2,@out3)"); 

auto_ptr<ResultSet > res(vStmt->executeQuery("SELECT @out1,@out2,@out3 AS _reply")); 
    while (res->next()) 
     cout << "... @output = " << res->getString("_reply") << endl; 

In Zeile vStmt-> execute ("CREATE PROCEDURE ... ich dieser Fehler

ERR: Undeclared variable: tip (MySQL error code: 1327, SQLState: 42000) 
+1

welche Art der Abfrage ist, dass: 'wählen utilizatorId in Puid, Spitze in pTIP, evenimentId in PEiD von utilizator' –

+0

haben Sie Recht, wenn ich versuche,' vStmt-> Ausführen ("DROP PROCEDURE IF EXISTS fLoghin"); vStmt-> execute ("CREATE PROCEDURE flogin (in pUser varchar (200), in pPass varchar (200), aus pUId int, aus pTip int, aus pEId int) BEGIN wähle utilizatorId aus utilizator where loghin = pUser und password = pPass in pUID; ENDE; "); 'das ist Arbeit, aber ich kann das nicht mit einem ausgewählten tun? – xnl96

+0

Was sollte die Auswahlabfrage tun? –

Antwort

1

Versuchen

CREATE PROCEDURE fLoghin(in pUser varchar(200), 
         in pPass varchar(200), 
         out pUId int, 
         out pTip int, 
         out pEId int) 
BEGIN 
    select pUId = utilizatorId, pTip = tip, pEId = evenimentId 
    from utilizator 
    where loghin=pUser and password=pPass ; 
END ; 

Ich kann jetzt nicht überprüfen. Vielleicht müssen Sie sich wie ein @ vor Ihrer Variablen setzen

@PUId = utilizatorId ... 
Verwandte Themen