1

I'm updating an ancient codebase written in Delphi 7 using ODBC Express for database connectivity to Delphi Seattle 10 using FireDAC. Currently, ODBC Express OEDataset components are pointed at stored procs and defined with params at design-time, including an @Result param populated from the "Return" function of the Sybase SPs.

If I attempt a simple swap (with minimal adjustment) for FireDAC's TFDStoredProc component (defining params at design-time), I get an "invalid parameter type" error when I include the @Result parameter (DataType=ftInteger, ParamType=ptResult). Without the @Result parameter, the stored procedure executes fine, but then I can't access the "Return" value.

I've mucked about with ResourceOptions.UnifyParams, FetchItems.Items := [fiMeta], ExecFunc instead of ExecProc, leaving out the @Result param, etc etc.

I'm sure I'm missing something very obvious, but I've been banging my head on my desk for a day trying to figure this out. Does anybody have any advice?

Eclipsic
  • 11
  • 3
  • Did you see this? --> [Delphi: How to get the value of an output parameter of a stored procedure?](http://stackoverflow.com/questions/1242161/delphi-how-to-get-the-value-of-an-output-parameter-of-a-stored-procedure) – WhiteHat Dec 15 '15 at 20:58
  • Thanks for the info, but not what I'm looking for. In Sybase, SPs are declared like this: `create procedure NewKy( InKy integer input , NewKy output ) as` where NewKy is an output parameter (ParamType := ptOutput). But an SP also has an inherent result parameter (ParamType := ptResult) defined by the Return RowCnt line. It's the return parameter I'm looking to include/fetch. In ODBC Express, the Result parameter was defined in the component at design-time, but this doesn't seem to be working in FireDAC. – Eclipsic Dec 16 '15 at 13:59
  • You may be looking for the FDStoredProc.recordCount or .RowsAffected property. – Gary Mueller Dec 16 '15 at 17:47
  • In my code I am also using FDStoredProc.Params.ParamValues['@RETURN_VALUE']; but I haven't looked to see if my sp on the server is declaring @RETURN_VALUE – Gary Mueller Dec 16 '15 at 17:49
  • AlienHeadDiscs, do you declare that parameter as a ParamtType := ptResult? – Eclipsic Dec 16 '15 at 18:17

1 Answers1

0

As weird as it seems, the issue is simply that the ptResult parameter was added as the last parameter in the list (which is how it was done using ODBC Express). Moving the @Result param to the first position, and only the first position, fixes the issue. Now I'm going to have to scour the documentation to see where I missed that little tidbit...

Eclipsic
  • 11
  • 3