Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!maverick.ksu.ksu.edu!hoss!price From: price@helios.unl.edu (Chad Price) Newsgroups: comp.databases Subject: Re: ingres embedded SQL/C problem Message-ID: Date: 27 Jan 91 21:23:59 GMT References: <1991Jan27.023129.721@eng.ufl.edu> Sender: news@hoss.unl.edu (Network News Administer) Organization: University of Nebraska - Lincoln Lines: 64 tsao@helios.tcad.ee.ufl.edu (Tsao) writes: > Hello, everybody. I just started working with Ingres' embedded SQL >with C, and I have got the following problem: > I am trying to insert new data into a table, and I have compiled and >run the program without any error, but then I check the table, new data >is not there. > Any help will be greatly appreciated. > I am using Ingres SunOS(unix) version, release 6.3. > Following is the program I tried: >------------------------------------------------------------------ >/* this program is trying to use esql to insert data into a table >#include >main() >{ > exec sql include sqlca; >exec sql begin declare section; >/* Description of table testtbl from database vlsi */ > EXEC SQL DECLARE testtbl TABLE > (name char(20), > age integer); > struct testtbl_ { > char name[21]; > long age; > } testtbl; >exec sql end declare section; > exec sql connect 'vlsi'; > exec sql SAVEPOINT savept; > exec sql whenever sqlerror continue; > strncpy(tbl.name,"dude"); > tbl.age = 20L; > > exec sql insert into testtbl(name,age) > values (:tbl); > > exec sql ROLLBACK to savept; > exec sql disconnect; > I am unfamiliar with Ingres, however Informix uses the sqlca structure for error reporting. Unless you explicitly check for errors you will never know what when wrong. Thus - check the values fo the appropriate member of the sqlca structure after EVERY exec sql statement to ensure that it was completed without error. There appears to be no other way to determine what goes wrong when an esql c statement fails. chad price price@fergvax.unl.edu