Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 60889
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T18:13:57+00:00 2026-05-10T18:13:57+00:00

Ok, this is a curly one. I’m working on some Delphi code that I

  • 0

Ok, this is a curly one. I’m working on some Delphi code that I didn’t write, and I’m encountering a very strange problem. One of my stored procedures’ parameters is coming through as null, even though it’s definitely being sent 1.

The Delphi code uses a TADOQuery to execute the stored procedure (anonymized):

 ADOQuery1.SQL.Text := 'exec MyStoredProcedure :Foo,:Bar,:Baz,:Qux,:Smang,:Jimmy';  ADOQuery1.Parameters.ParamByName('Foo').Value := Integer(someFunction());   // other parameters all set similarly  ADOQuery1.ExecSQL; 

Integer(SomeFunction()) currently always returns 1 – I checked with the debugger.

However, in my stored proc ( altered for debug purposes ):

create procedure MyStoredProcedure (     @Foo int, @Bar int, @Baz int,     @Qux int, @Smang int, @Jimmy varchar(20)  ) as begin     -- temp debug     if ( @Foo is null ) begin         insert into TempLog values ( 'oh crap' )     end     -- do the rest of the stuff here.. end 

TempLog does indeed end up with ‘oh crap’ in it (side question: there must be a better way of debugging stored procs: what is it?).

Here’s an example trace from profiler:

exec [MYDB]..sp_procedure_params_rowset N'MyStoredProcedure',1,NULL,NULL  declare @p3 int set @p3=NULL exec sp_executesql      N'exec MyStoredProcedure @P1,@P2,@P3,@P4,@P5,@P6',     N'@P1 int OUTPUT,@P2 int,@P3 int,@P4 int,@P5 int,@P6 int',     @p3 output,1,1,1,0,200 select @p3 

This looks a little strange to me. Notice that it’s using @p3 and @P3 – could this be causing my issue?

The other strange thing is that it seems to depend on which TADOConnection I use.

The project is a dll which is passed a TADOConnection from another application. It calls all the stored procedures using this connection.

If instead of using this connection, I first do this:

ConnectionNew := TADOQuery.Create(ConnectionOld.Owner); ConnectionNew.ConnectionString := ConnectionOld.ConnectionString; TADOQuery1.Connection := ConnectionNew; 

Then the issue does not occur! The trace from this situation is this:

exec [MYDB]..sp_procedure_params_rowset N'MyStoredProcedure',1,NULL,NULL  declare @p1 int set @p1=64 exec sp_prepare @p1 output,     N'@P1 int,@P2 int,@P3 int,@P4 int,@P5 int,@P6 varchar(20)',     N'exec MyStoredProcedure @P1,@P2,@P3,@P4,@P5,@P6',     1 select @p1  SET FMTONLY ON exec sp_execute 64,0,0,0,0,0,' ' SET FMTONLY OFF  exec sp_unprepare 64  SET NO_BROWSETABLE OFF  exec sp_executesql      N'exec MyStoredProcedure @P1,@P2,@P3,@P4,@P5,@P6',     N'@P1 int,@P2 int,@P3 int,@P4 int,@P5 int,@P6 varchar(20)',     1,1,1,3,0,'400.00' 

Which is a bit much for lil ol’ me to follow, unfortunately. What sort of TADOConnection options could be influencing this?

Does anyone have any ideas?

Edit: Update below (didn’t want to make this question any longer :P)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T18:13:58+00:00Added an answer on May 10, 2026 at 6:13 pm

    Ok, progress is made.. sort of.

    @Robsoft was correct, setting the parameter direction to pdInput fixed the issue.

    I traced into the VCL code, and it came down to TParameters.InternalRefresh.RefreshFromOleDB. This function is being called when I set the SQL.Text. Here’s the (abridged) code:

    function TParameters.InternalRefresh: Boolean;   procedure RefreshFromOleDB;     // ..         if OLEDBParameters.GetParameterInfo(ParamCount, PDBPARAMINFO(ParamInfo), @NamesBuffer) = S_OK then           for I := 0 to ParamCount - 1 do             with ParamInfo[I] do             begin               // ..               Direction := dwFlags and $F;       // here's where the wrong value comes from               // ..             end;      // ..   end;   // .. end; 

    So, OLEDBParameters.GetParameterInfo is returning the wrong flags for some reason.

    I’ve verified that with the original connection, (dwFlags and $F) is 2 (DBPARAMFLAGS_ISOUTPUT), and with the new connection, it’s 1 (DBPARAMFLAGS_ISINPUT).

    I’m not really sure I want to dig any deeper than that, for now at least.

    Until I have more time and inclination, I’ll just make sure all parameters are set to pdInput before I open the query.
    Unless anyone has any more bright ideas now..?

    Anyway, thanks everyone for your suggestions so far.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 154k
  • Answers 154k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer In SOAP4R, the target_actor attribute is read only but you… May 12, 2026 at 10:27 am
  • Editorial Team
    Editorial Team added an answer You're right. This is probably not thread safe. You might… May 12, 2026 at 10:27 am
  • Editorial Team
    Editorial Team added an answer You can always use the dd command to copy chunks… May 12, 2026 at 10:27 am

Related Questions

Ok, this is a curly one. I'm working on some Delphi code that I
Let's say that for some reason you need to write a macro: MACRO(X,Y) .
My aim is to create nested resources via one REST request. The REST requests
I'm using webrick to run my rails app in development mode. The page includes
I'm a total python noob so please bear with me. I want to have

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.