strcpy(s,"%-");sprintf(s1,"%d",l);strcat(s,s1);
switch (fulda->sqlvar??(i??).sqltype)
{
case 384:
case 388:
case 392:
case 452:
{
strcat(s,"s ");
printf(s,fulda->sqlvar??(i??).sqldata);
break;
}
case 385:
case 389:
case 393:
case 453:
{
if(*fulda->sqlvar??(i??).sqlind<0)
{
for(j=0;j<l;j++)printf("_");
printf(" ");
}
else
{
strcat(s,"s ");
printf(s,fulda->sqlvar??(i??).sqldata);
}
break;
}
case 496:
{
strcat(s,"d ");
printf(s,*((long int*)fulda->sqlvar??(i??).sqldata));
break;
}
case 497:
{
if(*fulda->sqlvar??(i??).sqlind<0)
{
for(j=0;j<l;j++)printf("_");
printf(" ");
}
else
{
strcat(s,"d ");
printf(s,*((long int*)fulda->sqlvar??(i??).sqldata));
}
break;
}
case 500:
{
strcat(s,"d ");
printf(s,*((short int*)fulda->sqlvar??(i??).sqldata));
break;
}
case 501:
{
if(*fulda->sqlvar??(i??).sqlind<0)
{
for(j=0;j<l;j++)printf("_");
printf(" ");
}
else
{
strcat(s,"d ");
printf(s,*((short int*)fulda->sqlvar??(i??).sqldata));
}
break;
}
default:
{
for(j=0;j<l;j++)printf("?");
printf(" ");
}
}
}
printf("\n");
}
CLOSE_CUR1:
EXEC SQL CLOSE CUR1;
if (sqlca.sqlcode != 0)
{
printf("ERROR - SQL code returned non-zero for "
"close CUR1, received %d\n",sqlca.sqlcode);
return(-1);
}
EXEC SQL COMMIT;
for(i=0;i<fulda->sqld;i++)
{
free(fulda->sqlvar??(i??).sqldata);
free(fulda->sqlvar??(i??).sqlind);
}
free(fulda);
printf("\n");
}
/*****************************************************/
/* S007 */
/* Вызывает хранимую процедуру S008 procedure */
/*****************************************************/
#include <stdlib.h>
#include <stdio.h>
EXEC SQL INCLUDE SQLCA;
int main(void)
{
EXEC SQL BEGIN DECLARE SECTION;
char command??(120??);
char result??(240??);
short outcode;
short quantity;
EXEC SQL END DECLARE SECTION;
printf("\nWhich command would you like to execute?\n");
gets(command);
EXEC SQL CALL S008(:command,:result,:outcode,:quantity);
if (sqlca.sqlcode != 0)
{
printf("ERROR - SQL code returned non-zero for "
"call, received %d\n",sqlca.sqlcode);
exit(-1);
}
printf("\n%s\nOutcode=%d\nQuantity=%d"
"\n",result,outcode,quantity);
EXEC SQL COMMIT;
return 0;
}
/*********************************************************************/
/* S008 */
/* Пример хранимой процедуры */
/* */
/* INSERT INTO SYSIBM.SYSPROCEDURES */
/* (PROCEDURE, AUTHID, LUNAME, LOADMOD, LINKAGE, COLLID, */
/* LANGUAGE, ASUTIME, STAYRESIDENT, IBMREQD, RUNOPTS, */
/* PARMLIST,RESULT_SETS,WLM_ENV, */
/* PGM_TYPE,EXTERNAL_SECURITY,COMMIT_ON_RETURN) */
/* VALUES('S008', ' ', ' ', 'S008', ' ', 'S008', */
/* 'C', 0, ' ', 'N', ' ', */
/* 'CHAR(120) IN,CHAR(240) OUT,INTEGER OUT,INTEGER OUT', */
/* 0,' ','M','N','N'); */
Уважаемый посетитель!
Чтобы распечатать файл, скачайте его (в формате Word).
Ссылка на скачивание - внизу страницы.