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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,ee0dc912649d50d4 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!news.glorb.com!meganewsservers.com!feeder2.on.meganewsservers.com!feed.cgocable.net!read2.cgocable.net.POSTED!53ab2750!not-for-mail From: "Warren W. Gay VE3WWG" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.2) Gecko/20040804 Netscape/7.2 (ax) X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Ada DB bindings and APQ References: <1km3c584awura$.y7djkir1ozya$.dlg@40tude.net> <_%6wd.154$jT5.98@read1.cgocable.net> In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: Date: Fri, 17 Dec 2004 06:13:47 -0500 NNTP-Posting-Host: 24.150.168.167 X-Complaints-To: abuse@cogeco.ca X-Trace: read2.cgocable.net 1103281966 24.150.168.167 (Fri, 17 Dec 2004 06:12:46 EST) NNTP-Posting-Date: Fri, 17 Dec 2004 06:12:46 EST Organization: Cogeco Cable Xref: g2news1.google.com comp.lang.ada:7026 Date: 2004-12-17T06:13:47-05:00 List-Id: Brian May wrote: >>>>>>"Warren" == Warren W Gay VE3WWG 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