Re: HELP!! ESQL/C - Pointers to structures as Host Variables
Posted in 1997
Topics: Connectivity: ESQL/C, 4GL & Embedded SQL
Sham, Vaidya wrote: > > Could someone tell me how to include a pointer to a structure as a SQL host > variable in an insert statement. Let me know if the following should work, I > would consider it a wate of resources having to peform a mamcpy into a local > structure and then use the structure itself... what i have below does not > compile ... am i missing something, am i plain stupid or do i hace to read > the manual???? ..... responses appreciated.. > > STRUCT *ptr_to_struct > > ptr_to_struct = function_call(); > > $ INSERT into TABLE_NAME > SET (a,b,c) (ptr_to_struct->value_of_a, ptr_to_struct->value_of_b, > ptr_to_struct->value_of_c); > > $ COMMIT WORK; > > Thanks > > Sham Vaidya Hi, yes I suggest, RTFM ;) First, use ANSI ESQL, it looks better :)) EXEC SQL BEGIN DECLARE SECTION; struct whatever { int col1; char col2[80]; } object_s, *object_ps; EXEC SQL END DECLARE SECTION; object_s.col1 = 9; strcpy( object_s.col2, "Hello,...." ); object_ps = &object_s; ... EXEC SQL INSERT INTO yourtable ( col1, col2 ) VALUES( :object_ps->col1, :object_ps->col2 ); ... ...works fine. Bye Stefan PS: Notice the colon in front of your host-variables. Some folks are using a $-sign. Old fashioned.