SQLInsert + LAST_INSERT_ID() + Delphi 2007
Posted: Fri 16 May 2008 11:57
Hi!
I have a problem with getting ID value from autoincrement field during insertind data by TmyQuery.SQLInsert.
TmyQuery.SQL.Text = 'select ID, NAME, NOTE from table1'
TmyQuery.SQLInsert.Text = 'CALL P_TABLE1_INSERT(:NAME, :NOTE, @ID); SELECT CAST(@ID AS SIGNED) AS '@ID''
I use Delphi 2007 + MySQL v5.0.45 + MyDAC v5.10.
Server Part:
Table
Процедура
I cannot get ID value in out-parameter from stored proc!
Where is error?
Please help me with subject!
I have a problem with getting ID value from autoincrement field during insertind data by TmyQuery.SQLInsert.
TmyQuery.SQL.Text = 'select ID, NAME, NOTE from table1'
TmyQuery.SQLInsert.Text = 'CALL P_TABLE1_INSERT(:NAME, :NOTE, @ID); SELECT CAST(@ID AS SIGNED) AS '@ID''
I use Delphi 2007 + MySQL v5.0.45 + MyDAC v5.10.
Server Part:
Table
Code: Select all
CREATE TABLE `table1` (
`ID` int(16) NOT NULL AUTO_INCREMENT,
`NAME` varchar(255),
`NOTE` varchar(255),
PRIMARY KEY (`ID`),
UNIQUE KEY `ID` (`ID`),
UNIQUE KEY `CODE` (`NAME`)
)
Code: Select all
CREATE PROCEDURE `P_TABLE1_INSERT`(
IN pNAME varchar(255),
IN pNOTE varchar(255),
OUT pID int(16)
)
BEGIN
INSERT INTO table1
(NAME, NOTE)
VALUES
(pNAME, pNOTE);
set pID := LAST_INSERT_ID();
END;
Where is error?
Please help me with subject!