curt3028@oce.orst.edu (Curt Vandetta) (09/30/89)
Howdy Folks, I have a question about esql, I'm working with RTI INGRES 5.0/0.6, but this question should be independent of the Database system. I want to write a function that will return n attributes from a table. The way I'm structuring it you would pass to this function the name of the table and a bitmask that says which attributes you want. I can see two ways of doing this, but I'm looking for more. 1) You could code every combination of attributes that could be requested. Which is not at all what I want to do. 2) You can select every attribute in the table and then mask out the ones that the user wants and return them. Number 2 is far better, but this Database will eventually grow into a networked Database, and selecting every attribute will put to much of a demand on the network. What I would like (and can't find any documentation that says I can or can't do it) is to make the embedded select statement select a variable for it's attributes. Example: Currently in Ingres you would say: exec sql select attribute1, attribute2,... What I want is to say: exec sql select Variable where Variable is declared to be an array of char *'s or just an array of attributes seperated by white spaces. It would be up the programmer (me) to build Variable and verify that it had legal attributes in it. IS THIS POSSIBLE? or do you have any better ideas? Thanks in advance, Curt
lindahl@violet.berkeley.edu (Ken Lindahl 642-0866) (10/03/89)
In article <12785@orstcs.CS.ORST.EDU> curt3028@oce.orst.edu (Curt Vandetta) writes: > <TEXT DELETED> > I have a question about esql, I'm working with RTI INGRES 5.0/0.6, > but this question should be independent of the Database system. > > I want to write a function that will return n attributes from a > table. The way I'm structuring it you would pass to this function > the name of the table and a bitmask that says which attributes > you want. I can see two ways of doing this, but I'm looking for > more. > > <TEXT DELETED> > > What I want is to say: > > exec sql select Variable > > where Variable is declared to be an array of char *'s or just > an array of attributes seperated by white spaces. It would be > up the programmer (me) to build Variable and verify that it > had legal attributes in it. IS THIS POSSIBLE? or do you have > any better ideas? I had to deal with this issue for an application that we built here. You need Embedded _Dynamic_ SQL (EDSQL?) be able to specify the attributes in the select at run time. RTI INGRES 5.x does not support EDSQL. I've been told (by RTI) that INGRES 6.x does support EDSQL, but I haven't upgraded yet so this is unconfirmed. However, Embedded QUEL (EQUEL) in INGRES 5 does allow this kind of dynamic behavior in retrieve statements. My solution was to initially code using EQUEL, and switch to ESQL when we go to INGRES 6 (we're waiting for the SPARCstation version to be released). For our application, the SQL select and QUEL retrieve statements are similar enough that I think (hope) the switch will not be too painful. Ken Lindahl lindahl@violet.berkeley.edu Advanced Technology Planning, Information Systems and Technology University of California at Berkeley