On 14-Jun-99 Michael Meskes wrote: > On Sun, Jun 13, 1999 at 07:24:52PM -0500, Brent Waldrop wrote: >> Does anyone know where this is thorough esql\c documentation. I am trying to > > Unfortunately there is no more than the man page and the sgml file > distributed with PostgreSQL. I just didn't find the time to write more. > >> compile previous examples i used with informix and they will not work for >> example when i do >> EXEC SQL declare democursor cursor for >> select fname,lname >> into :fname, :lname >> from employee >> where lname < :oneline; >> ---it bombs at the line with "into" in it saying there is a parse error >> and when i do this EXEC SQL fetch democursor; >> --it tells me that there is another parse error on this line >> is there any better documenation for esql/c than whats available in the >> programming manual so that i can figure out what is going on? > > To the best of my knowledge this is incorrect syntax. For instance Oracle > says: > > The SELECT statement associated with the cursor cannot include an INTO > clause. Rather, the INTO clause and list of output host variables are > part of the FETCH statement. > > I cannot find the text in the standard right now, but there also only FETCH > is listed with INTO. > > Please correct me if I'm wrong. I don't know if this makes you wrong, but Informix supports an INTO clause in a cursor declaration. It's one of the things I had to change while porting some applications from Informix ESQL/C to ECPG. Here's what Informix says about the INTO clause in their training materials for ESQL/C: You can use an INTO clause in the SELECT or use it in the FETCH; you must use it in one or the other. Right or wrong, it's definitely a part of their syntax. What's more, their parser does not flag this clause as being not compliant with ANSI SQL, as some of their other improvisations are. This isn't a criticism BTW, just an observation. There are enough other differences between these two embedded SQL implementations that anyone who supports both will have to keep separate source files anyway (at least for anything that's not a trivial application). So much for standards. ---------------------------------- Date: 15-Jun-99 Time: 10:45:53 Craig Orsinger (email: ) Logicon RDA Bldg. 8B28 "Just another megalomaniac with ideas above his 6th & F Streets station. The Universe is full of them." Ft. Lewis, WA 98433 - The Doctor ---------------------------------- On Tue, Jun 15, 1999 at 11:19:24AM -0700, Craig Orsinger wrote: > I don't know if this makes you wrong, but Informix supports > an INTO clause in a cursor declaration. It's one of the things I had to > change while porting some applications from Informix ESQL/C to ECPG. > Here's what Informix says about the INTO clause in their training > materials for ESQL/C: So you think we should add this? I have no idea at the moment if it causes problems with the parser but I will add this to my todo list. Michael -- Michael Meskes | Go SF 49ers! Th.-Heuss-Str. 61, D-41812 Erkelenz | Go Rhein Fire! Tel.: (+49) 2431/72651 | Use Debian GNU/Linux! Email: Michael.Meskes@gmx.net | Use PostgreSQL! > > I don't know if this makes you wrong, but Informix supports > > an INTO clause in a cursor declaration. It's one of the things I had to > > change while porting some applications from Informix ESQL/C to ECPG. > > Here's what Informix says about the INTO clause in their training > > materials for ESQL/C: > So you think we should add this? I have no idea at the moment if it causes > problems with the parser but I will add this to my todo list. I'd suggest *not* adding this non-SQL92 feature. afaik it adds no functionality, so why bother messing with it? btw, OpenIngres1.1 did not have this syntax either. - Thomas -- Thomas Lockhart lockhart@alumni.caltech.edu South Pasadena, California On Wed, Jun 16, 1999 at 02:18:13PM +0000, Thomas Lockhart wrote: > I'd suggest *not* adding this non-SQL92 feature. afaik it adds no > functionality, so why bother messing with it? btw, OpenIngres1.1 did > not have this syntax either. I agree. My only reason for maybe adding it was that I wasn't sure about SQL92. But if it definitely is not in SQL92 I think we shouldn't bother. But then we have some other compatibility hacks too. Michael -- Michael Meskes | Go SF 49ers! Th.-Heuss-Str. 61, D-41812 Erkelenz | Go Rhein Fire! Tel.: (+49) 2431/72651 | Use Debian GNU/Linux! Email: Michael.Meskes@gmx.net | Use PostgreSQL! On 16-Jun-99 Michael Meskes wrote: > On Wed, Jun 16, 1999 at 02:18:13PM +0000, Thomas Lockhart wrote: >> I'd suggest *not* adding this non-SQL92 feature. afaik it adds no >> functionality, so why bother messing with it? btw, OpenIngres1.1 did >> not have this syntax either. > > I agree. My only reason for maybe adding it was that I wasn't sure about > SQL92. But if it definitely is not in SQL92 I think we shouldn't bother. But > then we have some other compatibility hacks too. Informix can do this either way, according to their documentation. I'd say it's not that useful, either. There are other things that I'd prefer were done for compatibility with ESQL/C before this one. I can't find my notes on the subject, so I'll post a list later of things I've found that are incompatible between the two. Some are easy to fix, some are probably not. While we're on the subject of cursors and FETCH, Informix does cursors rather differently from the way PostgreSQL does. There are three different types defined: non-scroll, SCROLL (SELECT), and FOR UPDATE. The FETCH statement has no IN/OUT clause, since ESQL/C seems to be able to remember what type of cursor each one is. What makes this a porting challenge is that the ESQL/C parser will not accept and IN/OUT clause if it is there. SCROLL cursors, OTOH, have a position clause, which controls the direction the cursor is moved for the next fetch. Valid values in this field included FIRST/LAST/CURRENT/ABSOLUTE #/NEXT/PRIOR. This is why I was saying there are lots of incompatibilities in this area. Since Informix' is the only other embedded SQL I've worked with, I don't know how common this syntax is. Here the syntax rules of each: FETCH [position] [INTO variables] DECLARE SCROLL CURSOR [WITH HOLD] FOR DECLARE CURSOR FOR ; EXEC SQL FETCH INTO ; Here's how ECPG does the same thing: EXEC SQL DECLARE CURSOR FOR ; > EXEC SQL FETCH INTO ; Same with ORACLE. > Here's how ECPG does the same thing: > > EXEC SQL DECLARE CURSOR FOR