From: "Björn Lundin" <b.f.lundin@gmail.com>
Subject: Re: converting pointer to value
Date: Fri, 5 Mar 2021 12:02:43 +0100 [thread overview]
Message-ID: <s1t34k$q8q$1@dont-email.me> (raw)
In-Reply-To: <s1r5o1$5df$1@gioia.aioe.org>
Den 2021-03-04 kl. 18:35, skrev Dmitry A. Kazakov:
> On 2021-03-04 17:55, Shark8 wrote:
>
>>> type SQLPOINTER is private;
>> ....
>>> private
>>> type SQLPOINTER is new System.Storage_Elements.Integer_Address;
>>
>> And here we have SQLPOINTER, which is private, but which is something
>> of the same representation that Integer_Address has; let's assume that
>> the ADDRESS type is implementation-defined, and a private type.
>
> SQLPOINTER is System.Address.
>
>> What does this mean?
>> It means that we don't know what the size of ADDRESS (and thus
>> SQLPOINTER) actually is, but assuming you're on a 32- or 64-bit
>> machine it's likely 2 to 4 times as large as the 16-bit SQLSMALLINT--
>> which is a good indication that a simple UNCHECKED_CONVERSION is the
>> wrong answer.
>
> You need not to know that:
>
> declare
> P : SQLPOINTER := ...;
> A : System.Address;
> pragma Import (Ada, A);
> for A'Address use P'Address;
> T : My_Fancy_Object;
> pragma Import (Ada, My_Fancy_Object);
> for T'Address use A;
> begin
> ... -- Use T at P
>
so I tried this version:
procedure Exec (Statement_Handle : in Sqlhstmt) is
Rc : Sqlreturn := Sqlexecute (Statement_Handle);
Pvalue : aliased Sqlpointer;
Sent : Integer := 0;
Datalen : Integer := 14;
Buffer : String (1..10) := (others => ' ');
S_Ptr : Ptr_String;
A : System.Address;
pragma Import(Ada,A);
for A'Address use Pvalue'Address;
I : Sqlinteger ;
pragma Import(Ada,I);
for I'Address use A;
begin
--test for unset clob
Rc := Sqlparamdata (Statement_Handle,Pvalue'Access);
Text_Io.Put_Line ("SQLParamData1.2: " & I'Img );
SQLParamData1.2: 4790608
I'm thinking that I may be dealing with a pointer to a pointer here?
hmm, needs more testing. I changed the expected value from 5 to 7. Still
a bit off...
--
Björn
next prev parent reply other threads:[~2021-03-05 11:02 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-04 15:59 converting pointer to value Björn Lundin
2021-03-04 16:50 ` Dmitry A. Kazakov
2021-03-05 7:06 ` Björn Lundin
2021-03-05 7:44 ` Dmitry A. Kazakov
2021-03-05 9:10 ` Björn Lundin
2021-03-04 16:55 ` Shark8
2021-03-04 17:35 ` Dmitry A. Kazakov
2021-03-04 19:38 ` Shark8
2021-03-04 21:27 ` Dmitry A. Kazakov
2021-03-05 8:58 ` Björn Lundin
2021-03-05 8:54 ` Björn Lundin
2021-03-05 11:02 ` Björn Lundin [this message]
2021-03-05 11:57 ` Björn Lundin
2021-03-05 14:00 ` Dmitry A. Kazakov
2021-03-09 12:07 ` [SOLVED] " Björn Lundin
2021-03-04 20:09 ` Simon Wright
2021-03-04 21:00 ` Shark8
2021-03-05 8:59 ` Björn Lundin
2021-03-05 7:10 ` Björn Lundin
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox