home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / database / ingres / 1021 < prev    next >
Encoding:
Text File  |  1992-07-29  |  3.1 KB  |  97 lines

  1. Newsgroups: comp.databases.ingres
  2. Path: sparky!uunet!usc!wupost!gumby!destroyer!sol.ctr.columbia.edu!news.columbia.edu!usenet
  3. From: alan@curta.cc.columbia.edu (Alan Crosswell)
  4. Subject: Re: select * with a 3-way join having same column names in ESQL/C
  5. Message-ID: <1992Jul29.170445.15047@news.columbia.edu>
  6. Sender: usenet@news.columbia.edu (The Network News)
  7. Nntp-Posting-Host: curta.cc.columbia.edu
  8. Organization: Columbia University
  9. References: <1992Jul29.092836.27821@walter.cray.com>
  10. Date: Wed, 29 Jul 1992 17:04:45 GMT
  11. Lines: 84
  12.  
  13. In article <1992Jul29.092836.27821@walter.cray.com> djm@dagmar.cray.com  
  14. (Dave Miller) writes:
  15. > In article <1992Jul29.000202.23983@news.columbia.edu>,  
  16. alan@curta.cc.columbia.edu (Alan Crosswell) writes:
  17. > In the fetch, you are just retrieving into the three columns specified.   
  18. Again
  19. > this is perfectly legal, since it is allowable to have more columns that  
  20. are
  21. > selected than are retrieved into.  The extra columns are just skipped.
  22. > At runtime, there might be some type conversion problems (as you noted)  
  23. that
  24. > would result in errors.  The runtime routines do the best job they can  
  25. of doing
  26. > the conversion.  If the "hosts" table has 3 or more columns, all of your  
  27. result
  28. > rows would be from that table, probably not what you intended.
  29. > Dave Miller
  30. > Cray Research, Inc.
  31. > EXEC SQL include <std.disclaimer>
  32.  
  33. Dave, the fetch is into three *structs*, not three variables.  So,
  34. the fetch *should* expand into the same number of columns as the
  35. select does.
  36.  
  37. However, kudos to Chris Amidei who teaches Ingres for ASK/Ingres for
  38. suggesting this which seems to work right:
  39.  
  40.     exec sql declare x cursor for
  41.               select h.*, hw.*, i.*
  42.                 from hosts h, hwaddr hw, ip i
  43.                where h.hname = i.hname
  44.                  and i.ipaddr = hw.ipaddr;
  45.  
  46. I can now go back to fetching into :hosts, :hwaddr, :ip!
  47.  
  48. /a
  49. PS: For further edification, the structs generated by dclgen are:
  50.  
  51. /* Description of table ip from database network */
  52.   EXEC SQL DECLARE ip TABLE
  53.         (hname  vchar(50) not null,
  54.          ipaddr vchar(15) not null,
  55.          ipcolate       integer1 not null);
  56.  
  57.   struct ip_ {
  58.         char    hname[51];
  59.         char    ipaddr[16];
  60.         short   ipcolate;
  61.   } ip;
  62.  
  63. /* Description of table hwaddr from database network */
  64.   EXEC SQL DECLARE hwaddr TABLE
  65.         (ipaddr vchar(15) not null,
  66.          type   vchar(10) not null,
  67.          hwaddr vchar(12) not null);
  68.  
  69.   struct hwaddr_ {
  70.         char    ipaddr[16];
  71.         char    type[11];
  72.         char    hwaddr[13];
  73.   } hwaddr;
  74.  
  75. /* Description of table hosts from database network */
  76.   EXEC SQL DECLARE hosts TABLE
  77.         (hname  vchar(50) not null,
  78.          htype  vchar(15) not null,
  79.          hos    vchar(15) not null,
  80.          hdept  vchar(10) not null,
  81.          hreg   c8 not null);
  82.  
  83.   struct hosts_ {
  84.         char    hname[51];
  85.         char    htype[16];
  86.         char    hos[16];
  87.         char    hdept[11];
  88.         char    hreg[9];
  89.   } hosts;
  90.  
  91. (Another dclgen/ESQL plug: it has enabled me to stop using that awful OSL
  92.  language since the one nice thing it did for me was allow me not to have
  93.  to enumerate all the columns as I did in my EQUEL/C retrieve statements.)
  94.