Chapter 5 C Routines Reference
Set a shared variable value.
JagStatus JagSetSharedData (
JagSharedData * pData,
SQLPOINTER pValue,
SQLINTEGER len)
pData
The shared variable handle.
pValue
A buffer containing the new value.
len
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 |
---|---|
JAG_SUCCEED |
Success |
JAG_FAIL |
Failure |
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:
Note
JagSetSharedValue does not follow pointers
in structures when copying data. If the shared variable is a structure
that contains pointers, then only the addresses are copied, not
the memory contents at those addresses.
The code below calls JagSetSharedValue to save "Jaguar CTS" as a shared data value. Note that 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, "Jaguar CTS");
retcode = JagSetSharedValue(pData, buf, strlen(buf) + 1);
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, "Jaguar CTS");
/*
** 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);
JagGetSharedData, JagGetSharedDataByIndex, JagGetSharedValue, JagNewSharedData, JagNewSharedDataByIndex
"Share Data Between C Components" in the Jaguar CTS Programmer's Guide
Copyright © 2000 Sybase, Inc. All rights reserved. |
![]() |