I have a stored procedure that returns a parameter. On my datamodule, I have TUniStoredProc, and the generated SQL code in the component looks like this:
This is the Delphi code in the application:CALL spfundsrc_I(:Pdocumenttitle, :Pdocument_id, @NewID); SELECT CAST(@NewID AS SIGNED) AS '@NewID'
Code: Select all
begin
// :Pdoc_filenm, :Pdoc_data, @NewID
datamod.uspspdocument_I.ParamByName('Pdoc_filenm').AsString := ExtractFileName(ADocumentFile);
datamod.uspspdocument_I.ParamByName('Pdoc_data').LoadFromFile(ADocumentFile, ftBlob);
datamod.uspspdocument_I.Prepared := True; // <--- Error occurs here!
datamod.uspspdocument_I.ExecProc;
Result := datamod.uspspdocument_I.ParamByName('NewID').AsInteger;
end;
This is the MySQL stored procedure:---------------------------
Debugger Exception Notification
---------------------------
Project XXXXXXXX.exe raised exception class EMySqlException with message '
#42000You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT CAST(@NewID AS SIGNED) AS '@NewID'' at line 1'.
---------------------------
Break Continue Help
---------------------------
Code: Select all
CREATE PROCEDURE spdocument_I(Pdoc_filenm VarChar(255), Pdoc_data BLOB, OUT NewID Integer)
NO SQL
BEGIN
INSERT INTO tbdocument (
doc_filenm,
doc_data)
VALUES (
Pdoc_filenm,
Pdoc_data);
SET NewID = LAST_INSERT_ID();
END
/
Hope you can suggest how I can call this stored procedure and also get the NewID return parameter value after its completed?