欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  数据库

嵌入式的SQL程序设计

程序员文章站 2022-05-01 14:45:43
...

嵌入式的SQL程序设计 RED_CURSOR red_CURSOR CONNECT TO servername.databasename AS connection_name USER LOGIN.PASSWORD CONNECTION connection_name DISCONNECT connection_name SQL CONNECT TO red.book AS con1 USER sa; 38 EXEC SQL CONNECT TO red.t

嵌入式的SQL程序设计

RED_CURSOR red_CURSOR CONNECT TO servername.databasename AS connection_name USER LOGIN.PASSWORD CONNECTION connection_name DISCONNECT connection_name SQL CONNECT TO red.book AS con1 USER sa; 38 EXEC SQL CONNECT TO red.test AS con2 USER sa; 39 EXEC SQL DISCONNECT CON1 40 EXEC SQL DISCONNECT CON2 SQL BEGIN DECLARE SECTION 47 INT CompanyID SQL END DECLARE SECTION "WHERE CompanyID=:CompanID" SQL SELECT FROM Company 58 WHERE Address=:ADDRESS stmt_name FROM :hvar SQL BEGIN DECLARE SECTION "insert into company values(?,?)" companynameSQL END DECLARE SECTION PRINTF("输入单位代码:") 81 SCANF("%S",COMPANYID) 82 PRINTF("输入单位名称:") 83 scanf("%s",companyname) 84 EXEC SQL PREPARE stmt FROM :stmtcon 85 EXEC SQL EXECUTE stmt USING:COMPANYID,:COMPANYNAME SQL BEGIN DECLARE SECTION SQL END DECLARE SECTION 91 EXEC SQL SELECT COMPANYNAME INTO :COMPANYNAME cursor_name INSENSITIVE SCROLL CURSOR FOR select_stmt column_list 定义游标,并打开SQL COMPANYID,COMPANYNAME SQL OPEN C1 SQL BEGIN DECLARE SECTION COMPANYNAMESQL END DECLARE SECTION (SQLCODE==0) 122 { 123 EXEC SQL FETCH C1 INTO :COMPANYID,:COMPANYNAME 124 PRINTF("%S,%S",COMPANYID,COMPANYNAME) 125 } SQL BEGIN DECLARE SECTION "SELECT COMPANYID FROM COMPANY WHERE COMPANYNAME=?"; "北京怡神公司"; SECTION SQL SELECT_STATEMENT; SQL 139 PREPARE SELECT_STATEMENT FROM :SZCOMMAND SQL OPEN CON_CURSOR USING:SZCOMPANYNAME; 142 EXEC SQL FETCH CON_CURSOR INTO:SZCOMPANYID;