Re: SQLCODE
Posted in 1994
Topics: SQL Development & Query Writing, Error Codes & Troubleshooting, Connectivity: ESQL/C, 4GL & Embedded SQL, Migration, Import/Export & Data Conversion
>Hi, >I am looking for some examples using dynamic (prepaired ) statements for >insert and update. Is it possible (like in demo3.ec) to use sqlda for this >purpose (i didn't tried it yet ...). Are there any publications ??? Yes it is possible to use sqlda for insert/update/delete. say for e.g. you have a table t1 with columns c1,c2,c3 and c4, and if you want to create a dynamic insert statement for this table struct sqlda *insda; $char stmt[200]; allocate sufficient memory and set sqld to # of parameters (i.e. ? in your statements) and set sqltype ,sqllen for each parameters point sqldata to the allocated buffer and set sqlind to null (refer Esql-C 4.0 Manual, Ch-2, (Non-)Parameterized Non-select statements) one way of allocating space and setting all values for 'insda' is to prepare a select statement (you might waste one cursor variable) with same columns as in the insert statement as follows sprintf (stmt,"select c1,c2,c3,c4 from t1"); $prepare sel_id from $stmt; $describe sel_id into insda; allocate space for the insda as given in demo3.ec (step-1, step-2 and step-3) set all insda->sqlvar[?].sqldata appropriately to the values you want to insert sprintf (stmt,"insert into t1 values (?,?,?,?)"); $prepare ins_id from $stmt; $execute ins_id using descriptor insda; You can use the same technique for where clause parameters in case of delete / Update statements. Hope this helps. Questions? send e-mail. +---------------------------+--------------------------+ | G.T.Madavan, | e-mail: gtmad@smi.mn.org | | Systems Migration Inc., | Phone : (612) 890-0040 | | Burnsville, MN, U.S.A | Fax : (612) 890-0966 | +---------------------------+--------------------------+ >PS With ESQL-C 4.10 and msc8.0 sqlca.sqlcode never contained any meanigfull > values IF i use the large Modell Librarys. Any comment on this Problem ?? > Next Week i have to write some Windows examples. Are there _any_ known problems > (ESQL-C 4.10 with visual c++ (msc8.0) ) ? > Sorry No idea. >THANX IN ADVANCE > >hb > >--------------------------------------------------------- >oops >--------------------------------------------------------- >