Procedure for sharing data  Lock and unlock collections

Appendix C: Creating C Components

Create shared variables and collections

The component must create the collection before it can create shared variables.

  1. Create a collection and return a reference to the collection using the JagNewCollection routine. The component object must have a reference to a collection before calling any other routines on the collection.

  2. Create a shared variable in a collection and return a reference to the shared variable using the JagNewSharedData or JagNewSharedDataByIndex routine. The component instance must have a reference to a shared variable to access the contents of that shared variable.


Create collections

To create a new collection, call the JagNewCollection routine. This routine:

Lock level must be set to one of the following:

JAG_LOCKCOLLECTION – allows locks to be set on collections

JAG_LOCKDATA – does not allow locks to be set on collections


Create shared variables in collections

To create a new shared variable, call the JagNewSharedData or JagNewSharedDataByIndex routine. These routines create a shared variable value initialized to NULL. JagNewSharedData creates a new shared variable or returns a reference to an existing shared variable by name. JagNewSharedDataByIndex creates a new shared variable or returns a reference to an existing shared variable by index number. A shared variable created by index can only be retrieved or updated by index. Similarly, a shared variable created by name can only be retrieved or updated by name. Since a reference is returned, you do not need to follow these routines with the JagGetSharedData or JagGetSharedDataByIndex routine.

For both routines, *pExists is set to:





Copyright © 2005. Sybase Inc. All rights reserved. Lock and unlock collections

View this book as PDF