Re: ESQL/C question
Posted in 1997
Do you have an ESQL/C manual? If not, get it! If so, the information you need is in it -- typically in Chapter 1 where it describes how to use host variables (host variables are C variables to you). I'm rather concerned that you don't know SQL -- that is going to make life very difficult for you as an ESQL/C programmer. Please learn SQL ASAP! As a rule of thumb, ESQL/C programming is harder than either C programming or SQL, so you need some mastery of both the base languages independently before you start pushing the envelope with ESQL/C. A major part of the answer to your question is that you'll need to sprinkle EXEC SQL BEGIN DECLARE SECTION; <your C variable declarataions> EXEC SQL END DECLARE SECTION; around your file. But you will also need to fix up your variable declarations. You actually cannot use a char variable in ESQL/C; you'd have to use a fixchar variable in an array of dimension 1: fixchar field[1]; You'll also need to look up EXECUTE PROCEDURE in the Informix Guide to SQL: Reference manual to see how that gets used. You'll also need to learn how to handle handle cursors (DECLARE, OPEN, FETCH, CLOSE, FREE). This is a long-winded (and polite) way of saying 'RTM'. Yours, Jonathan Leffler (johnl@informix.com) #include <disclaimer.h> PS: I decline to respond to messages with anti-spam in the return path. >From: dchamber@mindspring.com (Don Chambers) >Date: Thu, 10 Jul 1997 20:23:53 GMT >X-Informix-List-Id: <news.40331> > >I am a C programmer try to use ESQL/C. I have never used SQL. All I >have to do it call a stored procedure sending it one variable and >haveing 10 returned into a struct. > >Could someone please tell me how to do this? >Assuming this is the struct: > struct ABC { > char A; > char B; > } mystruct > > When I try to compile I get a message saying that field A does not >exist it struct MYSTRUCT. > >I then created variable to test the call such as: >char *buf1[]; >char *buf[2]; >but still could not get the variable to be filled correctly. > >I am trying to call the procedure SQL_FUNC sending the variable A and >haveing B,C,D returned. This is what I typed: > >EXEC SQL execute SQ_FUNC using :A > into :B :C :D > >Could someone please help me with this? > >dchamber@mindspring.com