comp.lang.ada
 help / color / mirror / Atom feed
From: "Björn Lundin" <b.f.lundin@gmail.com>
Subject: Re: converting pointer to value
Date: Fri, 5 Mar 2021 12:57:20 +0100	[thread overview]
Message-ID: <s1t6b1$fp2$1@dont-email.me> (raw)
In-Reply-To: <s1t34k$q8q$1@dont-email.me>

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;
                               BufferLength     : in SQLLEN;
                               StrLen_Or_IndPtr : access SQLLEN)
                              return SQLRETURN is
       function BindParameter (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;
                               BufferLength     : in SQLLEN;
                               StrLen_Or_IndPtr : access SQLLen)
                              return SQLRETURN;
       pragma Import (Stdcall, BindParameter, "SQLBindParameter");
    begin
       return BindParameter (StatementHandle,
                             ParameterNumber,
                             InputOutputType,
                             ValueType,
                             ParameterType,
                             ColumnSize,
                             DecimalDigits,
                             Value,
                             BufferLength,
                             StrLen_Or_IndPtr);
    end SQLBindParameter;







/Björn


-- 
Björn

  reply	other threads:[~2021-03-05 11:57 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 [this message]
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