From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: * X-Spam-Status: No, score=1.0 required=3.0 tests=BAYES_20,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.5-pre1 Path: eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: =?UTF-8?Q?Bj=c3=b6rn_Lundin?= Newsgroups: comp.lang.ada Subject: converting pointer to value Date: Thu, 4 Mar 2021 16:59:45 +0100 Organization: A noiseless patient Spider Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Thu, 4 Mar 2021 15:59:46 -0000 (UTC) Injection-Info: reader02.eternal-september.org; posting-host="7eb822142ffa8fefee28c55fc709bee2"; logging-data="417"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19z76mAbSekhJT4EKKhZ5y1" User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:78.0) Gecko/20100101 Thunderbird/78.6.1 Cancel-Lock: sha1:KOqJau8wrshsrgUVMHDcwuvIRGQ= Content-Language: en-US X-Mozilla-News-Host: snews://news.eternal-september.org:563 Xref: reader02.eternal-september.org comp.lang.ada:61464 List-Id: Hi! I am trying to implement clob handling towards a database using the ODBC binding at 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