JagSetInstanceData  JagSleep

Chapter 5: C Routines Reference



Set a shared variable value.


JagStatus JagSetSharedData (
            JagSharedData * pData,
            SQLPOINTER pValue,
            SQLINTEGER len)



The shared variable handle.


A buffer containing the new value.


The size (in bytes) of the value. If the value is a null-terminated string, you must include the length of the null terminator in the length of the string.


Return value

To indicate





Check the server’s log file for more information when JagSetSharedData fails.


The JagSetSharedValue method copies a value to a specified shared variable. You must have retrieved the shared variable reference before executing this method. You must pass a pointer to the value you want to copy to the shared variable. You must specify the size of the value.

There are two possible strategies for using shared data values:

Example storing data values directly

The code below calls JagSetSharedValue to save “tombstone” as a shared data value. The len parameter is passed as 1 byte more than the string length to ensure that the null-terminator is copied:

SQLCHAR buf[20];
JagSharedData  *pData

strcpy(buf, "tombstone");
retcode = JagSetSharedValue(pData, buf, strlen(buf) + 1);

Example storing pointers to shared data

The code below allocates a SQLCHAR pointer, then calls JagSetSharedValue to save the pointer as shared data.

SQLCHAR        *ptrToData;
JagSharedData  *pData

ptrToData = (SQLCHAR *)malloc(20); 
strcpy(ptrToData, "tombstone");

** Pass the address of the pointer to save the pointer; 
** the length of the shared data is the size of the 
** pointer

retcode = JagSetSharedValue(pData, 
                            &ptrToData, sizeof(ptrToData));

Here is code to retrieve the value that was set in the example above:

SQLCHAR        *ptrToData;
JagSharedData  *pData
SQLINTEGER     outlen;

retcode = JagGetSharedValue(pData, &ptrToData,
                            sizeof(ptrToData), &outlen);

See also

JagGetSharedData, JagGetSharedDataByIndex, JagGetSharedValue, JagNewSharedData, JagNewSharedDataByIndex

Appendix C, “Creating C Components,” in the EAServer Programmer’s Guide

Copyright © 2005. Sybase Inc. All rights reserved. JagSleep