Re: Cardinality Violation
Posted in 1999
On Mon, Oct 04, 1999 at 02:33:57PM +0530, george wrote: > Hi, > > In my ESQL/C code there is a part where I insert a record into a table > having a serial column). I require the serial id of the column I just > inserted. I obtained this by getting the dbinfo(sqlca.sqlerrd1) value. > > EXEC SQL INSERT INTO t_genacct_cntl (run_dt, run_stat_cd, step_num, > beg_dtime, tot_rec_ct) VALUES (TODAY, 'P', 0, CURRENT YEAR TO SECOND, > :intcount); > EXEC SQL SELECT DBINFO ('sqlca.sqlerrd1') INTO :intcntlid FROM > t_genacct_cntl; > > When I run my program the first time, it works fine, but when I run it the > second time, the program gets to this part and returns a Cardinality > Violation. Why is this so? And what can I do to solve this? > > INFORMIX-OnLine Version 7.20.UC2 > > Thanks, > George Mathew > Senior Software Engineer > I.T.Solutions I didn't work with ESQL/C for a while but why don't you use just the sqlca record (so, to get the last serial value you have to get the value from sqlca.sqlerrd[1]). Your example worked first time because you had no records in t_genacct_cntl table. The second time after insert you had two records in the table and in this case to get values from a table you have to declare a cursor and then to fetch values using this cursor. Of course you can use the method that you have tried, but in this case you should use something like: SELECT dbinfo('sqlca.sqlerrd1') INTO :intcntlid FROM systables WHERE tabid=1 And this select statetment will return exactly one row. Hope this helps, Octav -- Octav Chiriac Phone: (373) 2 22 99 67 NetInfo S.R.L. Fax: (373) 2 21 36 59 Chisinau (373) 2 22 84 88 Moldova, Republic of mailto:com@netinfo-moldova.com