Re: Silly question -- with an answer (long)
Posted in 1998
David Kosenko wrote: > > Also sprach "Leffler, Jonathan" <jleffler@visa.com> : > :I'm trying to add the INFO statement to my general purpose SQL > :command interpreter, SQLCMD, and that forces me into wondering > :exactly how to handle all the following table names, in both > :MODE ANSI and non-ANSI databases (when the program does not know > :whether it is currently connected to a MODE ANSI or a non-ANSI > :database): > > Why not simply use sqlca.sqlwarn structure to determine if the > database is mode ANSI or not? If it is, then you handle the > various special conditions for ANSI dbs; otherwise, you can > ignore them. Or have I missed the point? Hi David, The primary reason for not doing as you suggest is that the program would also have to keep track of which connections exist, which connection is current, and the type of database the current connection is connected to. None of this is completely impossible, but it means putting an extra data structure into the program, plus tracking of both implicit connections created via the DATABASE, CREATE DATABASE, ROLLFORWARD DATABASE and START DATABASE statements (which are destroyed by CLOSE DATABASE, of course) and of the explicit connections created with CONNECT TO, SET CONNECTION (which are destroyed with DISCONNECT, of course). There are issues with tracking DORMANT connections, too, but that probably reduces to treating the DORMANT connection as a SET CONNECTION to no specific connection at all. And, even when you've done the tracking, you still have to know how to handle table names in each type of database, and how to handle the unquoted owner names. It marginally simplifies life if you know which type of database you are connected too, but to cover the MODE ANSI case at all means you have to understand most of what is in the article. So, no, you didn't miss the point; yes, it would alter the balance a little if I knew the current connection -- but the main changes would be that (1) the code which does an ORDER BY and selects the first returned row would fetch the only row and would not need an ORDER BY clause, and (2) the disjoint union would be replaced by a simpler statements (I'm not immediately sure whether it would be one or two simpler statements; I think it would need two, one with Owner = USER for MODE ANSI databases and one without an Owner criterion for non-ANSI databases. Yours, Jonathan Leffler (jleffler@earthlink.net) #include <many-aliases.h>