home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.databases.ingres
- Path: sparky!uunet!usc!wupost!gumby!destroyer!sol.ctr.columbia.edu!news.columbia.edu!usenet
- From: alan@curta.cc.columbia.edu (Alan Crosswell)
- Subject: Re: select * with a 3-way join having same column names in ESQL/C
- Message-ID: <1992Jul29.170445.15047@news.columbia.edu>
- Sender: usenet@news.columbia.edu (The Network News)
- Nntp-Posting-Host: curta.cc.columbia.edu
- Organization: Columbia University
- References: <1992Jul29.092836.27821@walter.cray.com>
- Date: Wed, 29 Jul 1992 17:04:45 GMT
- Lines: 84
-
- In article <1992Jul29.092836.27821@walter.cray.com> djm@dagmar.cray.com
- (Dave Miller) writes:
- >
- > In article <1992Jul29.000202.23983@news.columbia.edu>,
- alan@curta.cc.columbia.edu (Alan Crosswell) writes:
- >
- > In the fetch, you are just retrieving into the three columns specified.
- Again
- > this is perfectly legal, since it is allowable to have more columns that
- are
- > selected than are retrieved into. The extra columns are just skipped.
- > At runtime, there might be some type conversion problems (as you noted)
- that
- > would result in errors. The runtime routines do the best job they can
- of doing
- > the conversion. If the "hosts" table has 3 or more columns, all of your
- result
- > rows would be from that table, probably not what you intended.
- >
- > Dave Miller
- > Cray Research, Inc.
- > EXEC SQL include <std.disclaimer>
-
- Dave, the fetch is into three *structs*, not three variables. So,
- the fetch *should* expand into the same number of columns as the
- select does.
-
- However, kudos to Chris Amidei who teaches Ingres for ASK/Ingres for
- suggesting this which seems to work right:
-
- exec sql declare x cursor for
- select h.*, hw.*, i.*
- from hosts h, hwaddr hw, ip i
- where h.hname = i.hname
- and i.ipaddr = hw.ipaddr;
-
- I can now go back to fetching into :hosts, :hwaddr, :ip!
-
- /a
- PS: For further edification, the structs generated by dclgen are:
-
- /* Description of table ip from database network */
- EXEC SQL DECLARE ip TABLE
- (hname vchar(50) not null,
- ipaddr vchar(15) not null,
- ipcolate integer1 not null);
-
- struct ip_ {
- char hname[51];
- char ipaddr[16];
- short ipcolate;
- } ip;
-
- /* Description of table hwaddr from database network */
- EXEC SQL DECLARE hwaddr TABLE
- (ipaddr vchar(15) not null,
- type vchar(10) not null,
- hwaddr vchar(12) not null);
-
- struct hwaddr_ {
- char ipaddr[16];
- char type[11];
- char hwaddr[13];
- } hwaddr;
-
- /* Description of table hosts from database network */
- EXEC SQL DECLARE hosts TABLE
- (hname vchar(50) not null,
- htype vchar(15) not null,
- hos vchar(15) not null,
- hdept vchar(10) not null,
- hreg c8 not null);
-
- struct hosts_ {
- char hname[51];
- char htype[16];
- char hos[16];
- char hdept[11];
- char hreg[9];
- } hosts;
-
- (Another dclgen/ESQL plug: it has enabled me to stop using that awful OSL
- language since the one nice thing it did for me was allow me not to have
- to enumerate all the columns as I did in my EQUEL/C retrieve statements.)
-