comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: converting pointer to value
Date: Fri, 5 Mar 2021 15:00:41 +0100	[thread overview]
Message-ID: <s1tdi8$npq$1@gioia.aioe.org> (raw)
In-Reply-To: s1t6b1$fp2$1@dont-email.me

On 2021-03-05 12:57, Björn Lundin wrote:
> Den 2021-03-05 kl. 12:02, skrev Björn Lundin:
> 
>>
>> 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...
>>
> 
> The way I put the value 5 or 7 into the API is
> 
> procedure Bind_Parameter(Statement    : in out Statement_Type;
>                             Column_Index : in Positive;
>                             Value        : in CLOB;
>                             Null_Value   : in Boolean := False) is
>      A : Bind_Parameter_Type;
>      L : Sqlulen := Sqlulen(Length(Value));
>      Rc : Sqlreturn := 0;
>      Local_Length : Sqllen ;
>    begin
> 
>      Local_Length := Sqllen(Sqllen(-100) -Sqllen(L)); 
> --Sqllen'(SQL_LEN_DATA_AT_EXEC_OFFSET  - L);
> 
>      A.String_Pointer := new String'(To_String(Value) & Ascii.Nul);
> 
>      if Null_Value then
>        A.Length_Pointer := new Sqllen'(Sql_Null_Data);
>      else
>        A.Length_Pointer := new Sqllen'(Local_Length);
>      end if;
> 
>       Rc := gnu.Db.Sqlcli.Sqlbindparameter
>           (Statementhandle  => Statement.Get_Handle,
>            Parameternumber  => Sql_Parameter_Number (Column_Index),
>            Inputoutputtype  => Sql_Param_Input,
>            Valuetype        => Sql_C_Char,
>            Parametertype    => Sql_Char,
>            Columnsize       => L,
>            Decimaldigits    => 0,
>            Value            => 7,         --<-- here
>            Bufferlength     => 0,
>            Strlen_Or_Indptr => A.Length_Pointer);
> 
>    exception
>      when  Gnu.Db.Sqlcli.Table_Not_Found => raise Sql.No_Such_Object;
>    end Bind_Parameter;
> 
> 
>    where Bind_parameter_Type contains
>      Length_Pointer : aliased PTR_SQLLEN := null;
>      String_Pointer : aliased PTR_STRING := null;
> 
> 
> and PTR_types defined as
> type PTR_STRING is access all String;
> Type PTR_SQLLEN is access all SQLLEN;
> 
> and SQLLEN is a signed 64-bit integer
> 
> and SQLBindParameter looks like
> 
> 
> function SQLBindParameter (StatementHandle  : in SQLHSTMT;
>                                ParameterNumber  : in SQL_Parameter_Number;
>                                InputOutputType  : in SQL_Parameter_Type;
>                                ValueType        : in SQL_C_DATA_TYPE;
>                                ParameterType    : in SQL_DATA_TYPE;
>                                ColumnSize       : in SQLULEN;
>                                DecimalDigits    : in SQLSMALLINT;
>                                Value            : in SQLINTEGER;

This looks wrong because SQLINTEGER is 32-bit. Why do not you use 
Package System.Storage_Elements.Integer_Address instead, in order to 
place an integer there? It must be SQL_DATA_AT_EXEC which is -1, not 7. 
Alternatively you could use ptrdiff_t from Interfaces.C, because ARM is 
kind of ambiguous whether Integer_Address is signed.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

  reply	other threads:[~2021-03-05 14:00 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
2021-03-05 11:57       ` Björn Lundin
2021-03-05 14:00         ` Dmitry A. Kazakov [this message]
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