Pointers as Host Variables

Embedded SQL for C and SQL Server

Embedded SQL for C and SQL Server

Pointers as Host Variables

A C host variable, declared as a pointer to a void (void *p), is treated as a data buffer of unknown length. Your program must verify that enough memory is allocated to hold any output data received. You may also need to modify the generated .c code manually to specify the length of the variable. For example, if you declare the void *pChar variable, the precompiler generates a statement like the following.

Sqlasetv(2, 0, 462, (short)-1, (void far *)pChar, (void far *)0, (void far *)0L);

The third parameter of -1 indicates that this is a pointer. You may have to modify this length to indicate proper size of data contained in pChar. The .c source can then be compiled and linked as usual.