From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Compiling GNATColl on Windows Date: Mon, 15 Dec 2014 23:37:10 +0100 Organization: cbb software GmbH Message-ID: <1ifoukt5d2s2z$.6d9y7y2fiufo$.dlg@40tude.net> References: <09729271-32e5-4d7e-999f-2299a9c975fd@googlegroups.com> <27f6331d-31d4-4626-9b41-327c49bcbb6e@googlegroups.com> <5988fe56-ed84-4a6b-b5dd-d453b3c3b2f6@googlegroups.com> <8e88a5bd-30ab-4a23-974f-6fbeff11fb8c@googlegroups.com> <9a7fe568-2d34-42be-b1be-ce0653af005b@googlegroups.com> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: hqKFxjbs7Ua2waAvqYcAsQ.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit X-Complaints-To: abuse@aioe.org User-Agent: 40tude_Dialog/2.0.15.1 X-Notice: Filtered by postfilter v. 0.8.2 Xref: news.eternal-september.org comp.lang.ada:24025 Date: 2014-12-15T23:37:10+01:00 List-Id: 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