comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Compiling GNATColl on Windows
Date: Mon, 15 Dec 2014 23:37:10 +0100
Date: 2014-12-15T23:37:10+01:00	[thread overview]
Message-ID: <1ifoukt5d2s2z$.6d9y7y2fiufo$.dlg@40tude.net> (raw)
In-Reply-To: m6nl8c$25m$1@dont-email.me

On Mon, 15 Dec 2014 22:55:18 +0100, Björn Lundin wrote:

> If it is just postgres you want,
> I use this
> https://dl.dropboxusercontent.com/u/26175828/sql-pg.zip
> 
> It's based on an old binding from Samuel Tardieu,
> on which I put another layer on a somewhat higher
> abstraction layer.
> 
> For just reading...
> 
>     Stm : Sql.Statement_Type;
>     T : Sql.Transaction_Type;
>     Sql.Connect(Db_Name => "My_Db" => user ...);
>     Stm.Prepare("select COL1,COL2 from MY_TABLE where a = :A and b = :B");
>     T.Start;
>     Stm.Set("A",Some_Value);
>     Stm.Set("B",another_value);
>     --Open a cursor at the backend - This executes the query
>     Stm.Open_Cursor;
>     Stm.Fetch(End_Of_Set);
>     If not End_of_set then
>       Stm.Get("COL1",Some_Variable);
>       Stm.Get("COL2",Some_Other_Variable);
>     end if;
>     Stm.close_cursor();
>     T.Commit();
>     Sql.Close_Session;
> 
>     use Some_Variable and Some_Other_Variable

Roughly same in ODBC:

declare
   Environment : aliased ODBC_Environment;
   Connection : aliased ODBC_Connection (Environment'Access);
begin
   Connect (Connection, "My_DB", "Myself", ...);
   declare
      Command : aliased ODBC_Command (Connection'Access);
   begin
      Prepare (Command, "SELECT COL1,COL2 FROM ...");
      Execute (Command);
      Fetch (Command);
      Some_Variable := Get (Command'Access, 1, On_Error);
      Some_Other_Variable := Get (Command'Access, 2, Always);
   end;
end;

No need to fiddle with cursors explicitly and nothing to commit, if only
reading.

ODBC has a lot of problems, but it usually is simpler than native clients.

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


  reply	other threads:[~2014-12-15 22:37 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-15 13:06 Compiling GNATColl on Windows mhardeman25
2014-12-15 13:25 ` Michael Hardeman
2014-12-15 15:47   ` David Botton
2014-12-15 15:49     ` David Botton
2014-12-15 16:10       ` Michael Hardeman
2014-12-15 21:55         ` Björn Lundin
2014-12-15 22:37           ` Dmitry A. Kazakov [this message]
2014-12-15 23:14             ` Björn Lundin
2014-12-16  8:48             ` Björn Lundin
2014-12-16 10:10               ` Dmitry A. Kazakov
2014-12-16 10:21                 ` Björn Lundin
2014-12-15 23:00           ` Björn Lundin
2014-12-15 16:09     ` Michael Hardeman
2014-12-15 19:46 ` Shark8
2014-12-16 17:50   ` Michael Hardeman
2014-12-16 20:27     ` 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