Figure 116 shows how to define the parameters in a stored procedure that uses the GENERAL linkage convention.
Figure 116. Stored Procedure - Using GENERAL Linkage Convention
#pragma options(RENT) #pragma runopts(PLIST(OS)) #include <stdlib.h> #include <stdio.h> /*****************************************************************/ /* Code for a C language stored procedure that uses the */ /* GENERAL linkage convention. */ /*****************************************************************/ main(argc,argv) int argc; /* Number of parameters passed */ char *argv[]; /* Array of strings containing */ /* the parameter values */ { long int locv1; /* Local copy of V1 */ char locv2[10]; /* Local copy of V2 */ /* (null-terminated) */ . . . /***************************************************************/ /* Get the passed parameters. */ /***************************************************************/ if(argc==3) /* Should get 3 parameters: */ { /* procname, V1, V2 */ locv1 = *(int *) argv[1]; /* Get local copy of V1 */ . . . strcpy(argv[2],locv2); /* Assign a value to V2 */ . . . } } |
Figure 117 shows how to define the parameters in a stored procedure that uses the GENERAL WITH NULLS linkage convention. In this case:
Figure 117. Stored Procedure - Using GENERAL WITH NULLS Linkage Convention
#pragma runopts(PLIST(OS))
#include <stdlib.h>
#include <stdio.h>
/*****************************************************************/
/* Code for a C language stored procedure that uses the */
/* GENERAL WITH NULLS linkage convention. *
/*****************************************************************/
main(argc,argv)
int argc; /* Number of parameters passed */
char *argv[]; /* Array of strings containing */
/* the parameter values */
{
long int locv1; /* Local copy of V1 */
char locv2[10]; /* Local copy of V2 */
/* (null-terminated) */
short int locind[2]; /* Local copy of indicator */
/* variable array */
short int *tempint; /* Used for receiving the */
/* indicator variable array */
.
.
.
/***************************************************************/
/* Get the passed parameters. */
/***************************************************************/
if(argc==4) /* Should get 4 parameters: */
{ /* procname, V1, V2, */
/* indicator variable array */
locv1 = *(int *) argv[1];
/* Get local copy of V1 */
tempint = argv[3]; /* Get pointer to indicator */
/* variable array */
locind[0] = *tempint;
/* Get 1st indicator variable */
locind[1] = *(++tempint);
/* Get 2nd indicator variable */
if(locind[0]<0) /* If 1st indicator variable */
{ /* is negative, V1 is null */
.
.
.
}
.
.
.
strcpy(argv[2],locv2);
/* Assign a value to V2 */
*(++tempint) = 0; /* Assign 0 to V2's indicator */
/* variable */
}
}