📄 嵌入式sql.c
字号:
#line 179 "C:\\PROGRA~1\\MICROS~2\\VC98\\INCLUDE\\stdlib.h"
extern int errno;
extern unsigned long _doserrno;
#line 182 "C:\\PROGRA~1\\MICROS~2\\VC98\\INCLUDE\\stdlib.h"
extern char * _sys_errlist[];
extern int _sys_nerr;
#line 221 "C:\\PROGRA~1\\MICROS~2\\VC98\\INCLUDE\\stdlib.h"
extern int __argc;
extern char ** __argv;
extern wchar_t ** __wargv;
#line 227 "C:\\PROGRA~1\\MICROS~2\\VC98\\INCLUDE\\stdlib.h"
extern char ** _environ;
extern wchar_t ** _wenviron;
#line 235 "C:\\PROGRA~1\\MICROS~2\\VC98\\INCLUDE\\stdlib.h"
#line 236 "C:\\PROGRA~1\\MICROS~2\\VC98\\INCLUDE\\stdlib.h"
extern char * _pgmptr;
extern wchar_t * _wpgmptr;
#line 241 "C:\\PROGRA~1\\MICROS~2\\VC98\\INCLUDE\\stdlib.h"
#line 243 "C:\\PROGRA~1\\MICROS~2\\VC98\\INCLUDE\\stdlib.h"
extern int _fmode;
extern int _fileinfo;
extern unsigned int _osver;
extern unsigned int _winver;
extern unsigned int _winmajor;
extern unsigned int _winminor;
__declspec(noreturn) void __cdecl abort(void);
__declspec(noreturn) void __cdecl exit(int);
#line 266 "C:\\PROGRA~1\\MICROS~2\\VC98\\INCLUDE\\stdlib.h"
#line 270 "C:\\PROGRA~1\\MICROS~2\\VC98\\INCLUDE\\stdlib.h"
int __cdecl abs(int);
#line 272 "C:\\PROGRA~1\\MICROS~2\\VC98\\INCLUDE\\stdlib.h"
int __cdecl atexit(void (__cdecl *)(void));
double __cdecl atof(const char *);
int __cdecl atoi(const char *);
long __cdecl atol(const char *);
void * __cdecl bsearch(const void *, const void *, size_t, size_t,
int (__cdecl *)(const void *, const void *));
void * __cdecl calloc(size_t, size_t);
div_t __cdecl div(int, int);
void __cdecl free(void *);
char * __cdecl getenv(const char *);
char * __cdecl _itoa(int, char *, int);
char * __cdecl _i64toa(__int64, char *, int);
char * __cdecl _ui64toa(unsigned __int64, char *, int);
__int64 __cdecl _atoi64(const char *);
#line 291 "C:\\PROGRA~1\\MICROS~2\\VC98\\INCLUDE\\stdlib.h"
#line 294 "C:\\PROGRA~1\\MICROS~2\\VC98\\INCLUDE\\stdlib.h"
long __cdecl labs(long);
#line 296 "C:\\PROGRA~1\\MICROS~2\\VC98\\INCLUDE\\stdlib.h"
ldiv_t __cdecl ldiv(long, long);
char * __cdecl _ltoa(long, char *, int);
void * __cdecl malloc(size_t);
int __cdecl mblen(const char *, size_t);
size_t __cdecl _mbstrlen(const char *s);
int __cdecl mbtowc(wchar_t *, const char *, size_t);
size_t __cdecl mbstowcs(wchar_t *, const char *, size_t);
void __cdecl qsort(void *, size_t, size_t, int (__cdecl *)
(const void *, const void *));
int __cdecl rand(void);
void * __cdecl realloc(void *, size_t);
int __cdecl _set_error_mode(int);
void __cdecl srand(unsigned int);
double __cdecl strtod(const char *, char **);
long __cdecl strtol(const char *, char **, int);
unsigned long __cdecl strtoul(const char *, char **, int);
int __cdecl system(const char *);
#line 318 "C:\\PROGRA~1\\MICROS~2\\VC98\\INCLUDE\\stdlib.h"
char * __cdecl _ultoa(unsigned long, char *, int);
int __cdecl wctomb(char *, wchar_t);
size_t __cdecl wcstombs(char *, const wchar_t *, size_t);
wchar_t * __cdecl _itow (int, wchar_t *, int);
wchar_t * __cdecl _ltow (long, wchar_t *, int);
wchar_t * __cdecl _ultow (unsigned long, wchar_t *, int);
double __cdecl wcstod(const wchar_t *, wchar_t **);
long __cdecl wcstol(const wchar_t *, wchar_t **, int);
unsigned long __cdecl wcstoul(const wchar_t *, wchar_t **, int);
wchar_t * __cdecl _wgetenv(const wchar_t *);
int __cdecl _wsystem(const wchar_t *);
int __cdecl _wtoi(const wchar_t *);
long __cdecl _wtol(const wchar_t *);
wchar_t * __cdecl _i64tow(__int64, wchar_t *, int);
wchar_t * __cdecl _ui64tow(unsigned __int64, wchar_t *, int);
__int64 __cdecl _wtoi64(const wchar_t *);
#line 343 "C:\\PROGRA~1\\MICROS~2\\VC98\\INCLUDE\\stdlib.h"
#line 346 "C:\\PROGRA~1\\MICROS~2\\VC98\\INCLUDE\\stdlib.h"
#line 347 "C:\\PROGRA~1\\MICROS~2\\VC98\\INCLUDE\\stdlib.h"
char * __cdecl _ecvt(double, int, int *, int *);
__declspec(noreturn) void __cdecl _exit(int);
#line 357 "C:\\PROGRA~1\\MICROS~2\\VC98\\INCLUDE\\stdlib.h"
char * __cdecl _fcvt(double, int, int *, int *);
char * __cdecl _fullpath(char *, const char *, size_t);
char * __cdecl _gcvt(double, int, char *);
unsigned long __cdecl _lrotl(unsigned long, int);
unsigned long __cdecl _lrotr(unsigned long, int);
void __cdecl _makepath(char *, const char *, const char *, const char *,
const char *);
#line 366 "C:\\PROGRA~1\\MICROS~2\\VC98\\INCLUDE\\stdlib.h"
_onexit_t __cdecl _onexit(_onexit_t);
void __cdecl perror(const char *);
int __cdecl _putenv(const char *);
unsigned int __cdecl _rotl(unsigned int, int);
unsigned int __cdecl _rotr(unsigned int, int);
void __cdecl _searchenv(const char *, const char *, char *);
void __cdecl _splitpath(const char *, char *, char *, char *, char *);
#line 375 "C:\\PROGRA~1\\MICROS~2\\VC98\\INCLUDE\\stdlib.h"
void __cdecl _swab(char *, char *, int);
wchar_t * __cdecl _wfullpath(wchar_t *, const wchar_t *, size_t);
void __cdecl _wmakepath(wchar_t *, const wchar_t *, const wchar_t *, const wchar_t *,
const wchar_t *);
void __cdecl _wperror(const wchar_t *);
int __cdecl _wputenv(const wchar_t *);
void __cdecl _wsearchenv(const wchar_t *, const wchar_t *, wchar_t *);
void __cdecl _wsplitpath(const wchar_t *, wchar_t *, wchar_t *, wchar_t *, wchar_t *);
#line 392 "C:\\PROGRA~1\\MICROS~2\\VC98\\INCLUDE\\stdlib.h"
#line 393 "C:\\PROGRA~1\\MICROS~2\\VC98\\INCLUDE\\stdlib.h"
void __cdecl _seterrormode(int);
void __cdecl _beep(unsigned, unsigned);
void __cdecl _sleep(unsigned long);
#line 401 "C:\\PROGRA~1\\MICROS~2\\VC98\\INCLUDE\\stdlib.h"
#line 404 "C:\\PROGRA~1\\MICROS~2\\VC98\\INCLUDE\\stdlib.h"
int __cdecl tolower(int);
#line 413 "C:\\PROGRA~1\\MICROS~2\\VC98\\INCLUDE\\stdlib.h"
int __cdecl toupper(int);
#line 416 "C:\\PROGRA~1\\MICROS~2\\VC98\\INCLUDE\\stdlib.h"
#line 418 "C:\\PROGRA~1\\MICROS~2\\VC98\\INCLUDE\\stdlib.h"
#line 430 "C:\\PROGRA~1\\MICROS~2\\VC98\\INCLUDE\\stdlib.h"
char * __cdecl ecvt(double, int, int *, int *);
char * __cdecl fcvt(double, int, int *, int *);
char * __cdecl gcvt(double, int, char *);
char * __cdecl itoa(int, char *, int);
char * __cdecl ltoa(long, char *, int);
_onexit_t __cdecl onexit(_onexit_t);
int __cdecl putenv(const char *);
void __cdecl swab(char *, char *, int);
char * __cdecl ultoa(unsigned long, char *, int);
#line 446 "C:\\PROGRA~1\\MICROS~2\\VC98\\INCLUDE\\stdlib.h"
#line 448 "C:\\PROGRA~1\\MICROS~2\\VC98\\INCLUDE\\stdlib.h"
#pragma pack(pop)
#line 457 "C:\\PROGRA~1\\MICROS~2\\VC98\\INCLUDE\\stdlib.h"
#line 459 "C:\\PROGRA~1\\MICROS~2\\VC98\\INCLUDE\\stdlib.h"
#line 3 "b.sqc"
#line 3
/*
EXEC SQL INCLUDE sqlca;
*/
#line 3
int main()
{
#line 7
/*
EXEC SQL BEGIN DECLARE SECTION;
*/
#line 7
char sno[5];
char sname[10];
int status;
char city[10];
short cityInd;
#line 16
/*
EXEC SQL END DECLARE SECTION;
*/
#line 16
printf("This is my Embedded SQL for C application\n");
#line 20
/*
EXEC SQL CONNECT TO 8BC1D82B889C4FF.xixi USER sa.;
*/
#line 20
#line 20
{
#line 20
sqlastrt((void far *)pid, (void far *)0, (struct tag_sqlca far *)sqlca);
#line 20
sqlxcall(30, 1, 0, 0, 43, (char far *)" CONNECT TO 8BC1D82B889C4FF.xixi USER sa. ");
#line 20
SQLCODE = sqlca->sqlcode;
#line 20
sqlastop((void far *)0L);
#line 20
}
#line 21
if (SQLCODE == 0)
{
printf("Connection to SQL Server established\n");
}
else
{
printf("ERROR: Connection to SQL Server failed\n");
return (1);
}
#line 34
/*
EXEC SQL create table provider (
sno char(5) primary key,
sname char(10) not null,
status int,
city char(10)
);
*/
#line 39
#line 34
{
#line 34
sqlastrt((void far *)pid, (void far *)0, (struct tag_sqlca far *)sqlca);
#line 34
sqlxcall(24, 2, 0, 0, 104, (char far *)" create table provider ( sno char(5) primary key, sname char(10) not null, status int, city char(10) ) ");
#line 34
SQLCODE = sqlca->sqlcode;
#line 34
sqlastop((void far *)0L);
#line 34
}
#line 40
#line 41
/*
EXEC SQL insert into provider values('S1','精益','20','天津');
*/
#line 41
#line 41
{
#line 41
sqlastrt((void far *)pid, (void far *)0, (struct tag_sqlca far *)sqlca);
#line 41
sqlxcall(24, 3, 0, 0, 55, (char far *)" insert into provider values('S1','精益','20','天津') ");
#line 41
SQLCODE = sqlca->sqlcode;
#line 41
sqlastop((void far *)0L);
#line 41
}
#line 42
#line 42
/*
EXEC SQL insert into provider values('S2','胜锡','10','北京');
*/
#line 42
#line 42
{
#line 42
sqlastrt((void far *)pid, (void far *)0, (struct tag_sqlca far *)sqlca);
#line 42
sqlxcall(24, 4, 0, 0, 55, (char far *)" insert into provider values('S2','胜锡','10','北京') ");
#line 42
SQLCODE = sqlca->sqlcode;
#line 42
sqlastop((void far *)0L);
#line 42
}
#line 43
#line 43
/*
EXEC SQL insert into provider values('S3','东方红','30','天津');
*/
#line 43
#line 43
{
#line 43
sqlastrt((void far *)pid, (void far *)0, (struct tag_sqlca far *)sqlca);
#line 43
sqlxcall(24, 5, 0, 0, 57, (char far *)" insert into provider values('S3','东方红','30','天津') ");
#line 43
SQLCODE = sqlca->sqlcode;
#line 43
sqlastop((void far *)0L);
#line 43
}
#line 44
#line 44
/*
EXEC SQL insert into provider values('S4','丰泰盛','20','天津');
*/
#line 44
#line 44
{
#line 44
sqlastrt((void far *)pid, (void far *)0, (struct tag_sqlca far *)sqlca);
#line 44
sqlxcall(24, 6, 0, 0, 57, (char far *)" insert into provider values('S4','丰泰盛','20','天津') ");
#line 44
SQLCODE = sqlca->sqlcode;
#line 44
sqlastop((void far *)0L);
#line 44
}
#line 45
#line 45
/*
EXEC SQL insert into provider values('S5','为民','30','上海');
*/
#line 45
#line 45
{
#line 45
sqlastrt((void far *)pid, (void far *)0, (struct tag_sqlca far *)sqlca);
#line 45
sqlxcall(24, 7, 0, 0, 55, (char far *)" insert into provider values('S5','为民','30','上海') ");
#line 45
SQLCODE = sqlca->sqlcode;
#line 45
sqlastop((void far *)0L);
#line 45
}
#line 46
#line 46
/*
EXEC SQL insert into provider values('S6','通天','25',null);
*/
#line 46
#line 46
{
#line 46
sqlastrt((void far *)pid, (void far *)0, (struct tag_sqlca far *)sqlca);
#line 46
sqlxcall(24, 8, 0, 0, 53, (char far *)" insert into provider values('S6','通天','25',null) ");
#line 46
SQLCODE = sqlca->sqlcode;
#line 46
sqlastop((void far *)0L);
#line 46
}
#line 47
#line 48
/*
EXEC SQL WHENEVER SQLERROR GOTO error;
*/
#line 48
#line 49
/*
EXEC SQL WHENEVER NOT FOUND GOTO done;
*/
#line 49
#line 51
/*
EXEC SQL DECLARE providerCursor CURSOR FOR
SELECT sname, city
FROM provider;
*/
#line 53
#line 55
/*
EXEC SQL OPEN providerCursor ;
*/
#line 55
#line 55
{
#line 55
sqlastrt((void far *)pid, (void far *)0, (struct tag_sqlca far *)sqlca);
#line 55
sqlxcall(26, 9, 0, 0, 65, (char far *)"/* providerCursor 9 nohold */ SELECT sname, city FROM provider ");
#line 55
SQLCODE = sqlca->sqlcode;
#line 55
#line 55
if(sqlca->sqlcode < 0) {
#line 55
sqlastop((void far *)0L);
#line 55
goto error;
#line 55
}
#line 55
if(sqlca->sqlcode == 100) {
#line 55
sqlastop((void far *)0L);
#line 55
goto done;
#line 55
}
sqlastop((void far *)0L);
#line 55
}
#line 56
for ( ; ; ) {
#line 59
/*
EXEC SQL FETCH providerCursor INTO :sname,:city:cityInd;
*/
#line 59
#line 59
{
#line 59
sqlastrt((void far *)pid, (void far *)0, (struct tag_sqlca far *)sqlca);
#line 59
sqlaaloc(1, 2, 9, (void far *)0);
#line 59
sqlasetv(1, 0, 462,(short) SQLLENMAX(sizeof(sname)),(void far *)&sname, (void far *)0,0L);
#line 59
sqlasetv(1, 1, 463,(short) SQLLENMAX(sizeof(city)),(void far *)&city, (void far *)&cityInd,0L);
#line 59
sqlxcall(25, 9, 0, 1, 52, (char far *)" FETCH providerCursor INTO : ,: : ");
#line 59
SQLCODE = sqlca->sqlcode;
#line 59
#line 59
if(sqlca->sqlcode < 0) {
#line 59
sqlastop((void far *)0L);
#line 59
goto error;
#line 59
}
#line 59
if(sqlca->sqlcode == 100) {
#line 59
sqlastop((void far *)0L);
#line 59
goto done;
#line 59
}
sqlastop((void far *)0L);
#line 59
}
#line 60
printf ("Sname:%s ",sname);
if ( cityInd< 0)
printf ("City:NULL\n");
else
printf ("City:%s\n",city);
}
error:
printf ("SQL error %d\n",sqlca->sqlcode);
done:
#line 72
/*
EXEC SQL WHENEVER SQLERROR continue;
*/
#line 72
#line 73
/*
EXEC SQL CLOSE providerCursor;
*/
#line 73
#line 73
{
#line 73
sqlastrt((void far *)pid, (void far *)0, (struct tag_sqlca far *)sqlca);
#line 73
sqlxcall(20, 9, 0, 0, 23, (char far *)" CLOSE providerCursor ");
#line 73
SQLCODE = sqlca->sqlcode;
#line 73
#line 73
if(sqlca->sqlcode == 100) {
#line 73
sqlastop((void far *)0L);
#line 73
goto done;
#line 73
}
sqlastop((void far *)0L);
#line 73
}
#line 74
#line 74
/*
EXEC SQL COMMIT WORK RELEASE;
*/
#line 74
#line 74
{
#line 74
sqlastrt((void far *)pid, (void far *)0, (struct tag_sqlca far *)sqlca);
#line 74
sqlxcall(21, 0, 0, 0, 22, (char far *)" COMMIT WORK RELEASE ");
#line 74
SQLCODE = sqlca->sqlcode;
#line 74
#line 74
if(sqlca->sqlcode == 100) {
#line 74
sqlastop((void far *)0L);
#line 74
goto done;
#line 74
}
sqlastop((void far *)0L);
#line 74
}
#line 75
#line 77
/*
EXEC SQL DISCONNECT ALL;
*/
#line 77
#line 77
{
#line 77
sqlastrt((void far *)pid, (void far *)0, (struct tag_sqlca far *)sqlca);
#line 77
sqlxcall(36, 10, 0, 0, 17, (char far *)" DISCONNECT ALL ");
#line 77
SQLCODE = sqlca->sqlcode;
#line 77
#line 77
if(sqlca->sqlcode == 100) {
#line 77
sqlastop((void far *)0L);
#line 77
goto done;
#line 77
}
sqlastop((void far *)0L);
#line 77
}
#line 78
return 0;
}
long SQLCODE;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -