Question:
In a TQuery component, I use the SQL property to call up a stored procedure which is kept on a MSSQL server. The string used is ‘Execute [nameofproc] :param1, :param2, etc.
However I am trying to return a value from the stored proc using an ‘OUTPUT’ parameter. How can I read this value from Delphi? The SQL help suggests using a ‘param = retvar output’ syntax, but Delphi is not happy when I add this into the execute statement.
Answer:
For most SQL operations, you can get away with using a TQuery; that is, if they’re strictly one-way. For other SQL operations, you need to use the TStoredProc. TStoredProc has facilities built in for singleton return values.