comp.lang.ada
 help / color / mirror / Atom feed
From: "Björn Lundin" <b.f.lundin@gmail.com>
Subject: converting pointer to value
Date: Thu, 4 Mar 2021 16:59:45 +0100	[thread overview]
Message-ID: <s1r05i$d1$1@dont-email.me> (raw)

Hi!
I am trying to implement clob handling towards a database
using the ODBC binding at <http://gnade.sourceforge.net/>

The ODBC API itself is somewhat awkward for this, but I have some Ada 
issues as well.

In one call I do the binding of data to a bind variable.

   insert into table A vales (?,?)

where the '?' are my bind variables in the sql.

Now, when data is small I call bindcol via

   Gnu.Db.Sqlcli.Sqlbindparameter

and put the wanted value into the binding.

But with CLOBs, there are too much data, so instead of setting
the actual data, one is to indicate which column to put the
data into - at a later time.

So then I call exec, it indicates by resultcode
that no all values are present.

I then get to call

     Rc := Sqlparamdata (Statement_Handle,Pvalue'Access);

with spec like this to find out what column misses value.
This is the column mentioned above

    function SQLParamData (StatementHandle : SQLHSTMT;
                           pValue          : access SQLPOINTER)
                          return SQLRETURN;

so I get back the column in pValue.
pValue is declared as
     Pvalue : aliased Sqlpointer;

I did put in a SQLINTEGER into the previous call, and want that back.

I also have the definitions
    type SQLPOINTER is private;

    type SQLINTEGER   is range -(2 ** 31) .. +(2 ** 31) - 1;
    for SQLINTEGER'Size use 32;
....
private
    type SQLPOINTER is new System.Storage_Elements.Integer_Address;

and there is a utility functions

    function To_Address (P : SQLPOINTER) return System.Address;


And here's my problem

from the call
     Rc := Sqlparamdata (Statement_Handle,Pvalue'Access);
how do get Pvalue as an integer value?

Running it in debug in GPS I hoover over the variable
and I see the correct value
(the one I feed into it earlier) but how
do I get a hold of it?

this code looks like

    type SQLSMALLINT  is range -(2 ** 15) .. +(2 ** 15) - 1;
    for SQLSMALLINT'Size use 16;

    type SQLRETURN is new SQLSMALLINT;


   procedure Exec (Statement_Handle : in Sqlhstmt) is
     RC :  SQLRETURN := SQLExecute (Statement_Handle);
     Pvalue : aliased Sqlpointer;
     Rc2 :  SQLRETURN := 0;
    begin
     Text_Io.Put_Line ("Exec: " & Rc'Img);

     Rc2 := Sqlparamdata (Statement_Handle,Pvalue'Access);
     Text_Io.Put_Line ("SQLParamData1: " & Rc2'Img );

     how to get the Pvalue as an SQLRETURN?


-- 
Björn

             reply	other threads:[~2021-03-04 15:59 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-04 15:59 Björn Lundin [this message]
2021-03-04 16:50 ` converting pointer to value 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
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