Category : Databases and related files
Archive   : DBATOOLS.ZIP
Filename : DCLC.PC

 
Output of file : DCLC.PC contained in archive : DBATOOLS.ZIP
/*
NAME
DCLC :
FUNCTION
To test including output of DCLGEN in a C pgm.
NOTES

To create table DCLGEN:

$ DCLGEN SCOTT/TIGER EMP GET
$ SQLPLUS
START DCLGEN
EXIT

To build/run DCLC (on 780 VMS w/ Prod Oracle):

$ PCC INAME=DCLC.PC
$ CC DCLC
$ @SYS$ORACLE:LOUTL DCLC DCLC,SYS$ORACLE:SQLLIB/LIB DCLC S
$ DCLGEN SCOTT/TIGER EMP C
$ RUN DCLC

*/

EXEC SQL BEGIN DECLARE SECTION;
VARCHAR usr[20];
VARCHAR pwd[1];
EXEC SQL INCLUDE emp.c;
EXEC SQL END DECLARE SECTION;
EXEC SQL INCLUDE SQLCA;

main()
{
EXEC SQL WHENEVER SQLERROR GOTO sql_err;

strcpy(usr.arr,"SCOTT/TIGER");
usr.len = strlen(usr.arr);
pwd.len = 0;

EXEC SQL CONNECT :usr IDENTIFIED BY :pwd;

EXEC SQL DECLARE C1 CURSOR FOR SELECT EMPNO,ENAME,JOB,MGR,
HIREDATE,SAL,COMM,DEPTNO
FROM EMP;
EXEC SQL OPEN C1;
EXEC SQL WHENEVER NOT FOUND GOTO notfound;

for ( ; ; )
{
EXEC SQL FETCH C1 INTO :empno,:ename,:job,:mgr,
:hiredate,:sal,:comm,:deptno;
printf("EMPNO : %d\n", empno);
printf("ENAME : %.10s\n", ename);
printf("JOB : %.9s\n", job);
printf("MGR : %d\n", mgr);
printf("HIREDATE : %.9s\n", hiredate);
printf("SAL : %6.2f\n", sal);
printf("COMM : %6.2f\n", comm);
printf("DEPTNO : %d\n", deptno);
putchar('\n');
}

notfound:;
EXEC SQL COMMIT WORK RELEASE;
exit(1);

sql_err:
printf("%.70s (%d)", sqlca.sqlerrm.sqlerrmc, -sqlca.sqlcode);
EXEC SQL ROLLBACK WORK RELEASE;
exit(2);
}


  3 Responses to “Category : Databases and related files
Archive   : DBATOOLS.ZIP
Filename : DCLC.PC

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/