From: Ludovic Brenta <ludovic@ludovic-brenta.org>
Subject: Re: Gnade/ODBC example - please help
Date: Fri, 1 Aug 2008 06:37:32 -0700 (PDT)
Date: 2008-08-01T06:37:32-07:00 [thread overview]
Message-ID: <e93cf706-dfda-458d-b236-e0845c968b38@j22g2000hsf.googlegroups.com> (raw)
In-Reply-To: 4962abea-7622-45b3-a121-49286c636421@2g2000hsn.googlegroups.com
Hubert Walter wrote:
> And now my problem: This example shows how to pass integer parameter
> to the query and get string and float from the database.
> I trying to pass to the query string and the boolean (...WHERE NAME =
> name AND IsVisible = visible...) and I can't. I have no idea how to
> rewrite this example.
The example already covers getting Strings from the database. To bind
a String into a query, you simply call the procedure
GNU.DB.SQLCLI.SQLBindParameter where the Value parameter has type
"access String" (line 765 in gnu-db-sqlcli.ads). This would look like:
Some_String : aliased String := "this is the string I want to bind
into the prepared statement";
Length : aliased SQLINTEGER := Some_String'Length;
SQLPrepare (StatementHandle, "SELECT * FROM T WHERE NAME = ? AND
IS_VISIBLE = ?);
SQLBindParameter
(StatementHandle,
ParameterNumber => 1,
Value => Some_String'Access,
Length => Lengh'Access);
As for Booleans, I think the best option is to instantiate
GNU.DB.SQLCLI.EnumBinding (line 866 in gnu-db-sqlcli.ads) using
Boolean as the parameter, like so:
package Boolean_Binding is new GNU.DB.SQLCLI.EnumBinding (Enum =>
Boolean);
Indicator : aliased SQLINTEGER;
Boolean_Binding.SQLBindParameter
(StatementHandle,
ParameterNumber => 2,
Value => Some_Boolean'Access,
SQLIndicator => Indicator'Access);
Hope this helps
--
Ludovic Brenta.
prev parent reply other threads:[~2008-08-01 13:37 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-01 12:18 Gnade/ODBC example - please help azdakiel
2008-08-01 13:10 ` Dmitry A. Kazakov
2008-08-01 13:37 ` Ludovic Brenta [this message]
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox