0
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);
,這代碼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;
在行vStmt->執行(「CREATE PROCEDURE ...我得到這個錯誤
ERR: Undeclared variable: tip (MySQL error code: 1327, SQLState: 42000)
什麼樣的查詢是:'選擇utilizatorId到PUID,尖端插入PTIP,evenimentId到PEID從utilizator' – 2012-04-13 12:00:21
你有權利,如果我嘗試' vStmt->執行(「DROP程序如果存在fLoghin」); vStmt->執行(「CREATE PROCEDURE fLoghin(在pUser VARCHAR(200),在pPass VARCHAR(200),出PUID INT,出PTIP INT,出PEID INT)BEGIN從utilizator選擇utilizatorId其中loghin = pUser和口令= pPass到pUId; END;「); 「這是工作,但我不能用一個選擇做到這一點? – xnl96 2012-04-13 12:06:58
選擇查詢應該做什麼? – 2012-04-13 12:10:46