From: "Warren W. Gay VE3WWG" <ve3wwg@NoSpam.cogeco.ca>
Subject: Re: Ada DB bindings and APQ
Date: Fri, 17 Dec 2004 06:13:47 -0500
Date: 2004-12-17T06:13:47-05:00 [thread overview]
Message-ID: <Oazwd.258$Wt5.165462@read2.cgocable.net> (raw)
In-Reply-To: <sa4vfb1r0a7.fsf@snoopy.apana.org.au>
Brian May wrote:
>>>>>>"Warren" == Warren W Gay VE3WWG <ve3wwg@NoSpam.cogeco.ca> writes:
>
>
> Warren> I like the neatness of this approach, but the danger is
> Warren> that you might do the "..." part on a row that might
> Warren> not exist. Though I suppose the Query_Type object could
> Warren> maintain enough state such that it can raise an exception
> Warren> if any "Values" were fetched from the row that is not there.
> Warren> Just a quibble: I'd prefer something like "No_Row(Q)" perhaps.
>
> Warren> An even neater loop is this, IMHO ;-)
>
> >> loop
> >> Fetch(Q);
> >> exit when No_More_Data(Q);
> >>
> >> ...
> >> end loop;
>
> How about
>
> Valid_Row : Boolean;
>
> loop
> Fetch(Q, Valid_Row);
> exit when not Valid_Row;
> ...
> end loop;
>
> Where Valid_Row is an out variable from Fetch.
>
> This would avoid breaking any existing software, and make it obvious
> that Valid_Row has to be checked.
I like that idea.
> Other questions that might be significant, especially to some of my
> proposed changes.
>
> 1. What happens if an unexpected exception occurs within the above
> loop, and it prevents continuing the loop. In fact, the code that
> handles the exception may not realize it occurred in middle of the
> fetch operation. Is there any way of recovering the database
> connection?
An unexpected error would raise SQL_Error (or somesuch). So
if you expect to recover from it, you must obviously be willing
to catch the exception at some level.
> 2. With Mysql what happens if I do this:
>
> declare
> Q1 : Root_Query_Type'Class := New_Query(C);
> Q2 : Root_Query_Type'Class := New_Query(C);
> begin
> Prepare(Q1, ...);
> Prepare(Q2, ...)
>
> Set_Fetch_Mode(Q1, Sequential_Fetch);
> Set_Fetch_Mode(Q2, Sequential_Fetch);
>
> Execute(Q1, C);
> Execute(Q2, C);
>
> loop
> Fetch(Q1);
> Fetch(Q2);
> ...
> end loop;
> end;
>
> Will this work, trigger an error, or will it kill the Mysql connection
> as requests are intermixed?
I haven't tried this, but I know that PostgreSQL is supposed
to support this, and I believe it will. Whether MySQL and Sybase
can, I am not sure.
In MySQL's case, what I believe happens is that any Q2 rows that
are skipped over to fetch rows for Q1, will just be loaded
into the C client memory for later use. But I have not taken
the time to test this.
--
Warren W. Gay VE3WWG
http://home.cogeco.ca/~ve3wwg
prev parent reply other threads:[~2004-12-17 11:13 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-12-12 17:42 Ada DB bindings and APQ Dmitry A. Kazakov
2004-12-14 7:25 ` Warren W. Gay VE3WWG
2004-12-14 17:37 ` Dmitry A. Kazakov
2004-12-14 18:29 ` Georg Bauhaus
2004-12-14 19:45 ` Dmitry A. Kazakov
2004-12-14 21:06 ` Georg Bauhaus
2004-12-15 8:19 ` Ole-Hjalmar Kristensen
2004-12-15 17:20 ` Dmitry A. Kazakov
2004-12-16 13:28 ` Georg Bauhaus
2004-12-17 13:23 ` Dmitry A. Kazakov
2004-12-14 23:26 ` Brian May
2004-12-15 17:43 ` Dmitry A. Kazakov
2004-12-15 21:54 ` Brian May
2004-12-15 4:05 ` Warren W. Gay VE3WWG
2004-12-15 18:26 ` Dmitry A. Kazakov
2004-12-16 2:53 ` Warren W. Gay VE3WWG
2004-12-18 16:43 ` Dmitry A. Kazakov
2004-12-18 20:36 ` Warren W. Gay VE3WWG
2004-12-18 22:21 ` Dmitry A. Kazakov
2004-12-19 0:53 ` Warren W. Gay VE3WWG
2004-12-19 12:21 ` Dmitry A. Kazakov
2004-12-20 5:33 ` Warren W. Gay VE3WWG
2004-12-20 20:01 ` Dmitry A. Kazakov
2004-12-20 20:54 ` Warren W. Gay VE3WWG
2004-12-14 22:40 ` Brian May
2004-12-15 3:23 ` Warren W. Gay VE3WWG
2004-12-15 15:01 ` Georg Bauhaus
2004-12-17 4:31 ` Brian May
2004-12-15 10:48 ` Brian May
2004-12-16 1:40 ` Brian May
2004-12-16 3:10 ` Warren W. Gay VE3WWG
2004-12-17 4:55 ` Brian May
2004-12-17 11:13 ` Warren W. Gay VE3WWG [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