第11讲1--初始嵌入式SQL.pdf

上传人:奉*** 文档编号:4059864 上传时间:2021-01-13 格式:PDF 页数:20 大小:199.12KB
返回 下载 相关 举报
第11讲1--初始嵌入式SQL.pdf_第1页
第1页 / 共20页
第11讲1--初始嵌入式SQL.pdf_第2页
第2页 / 共20页
点击查看更多>>
资源描述

《第11讲1--初始嵌入式SQL.pdf》由会员分享,可在线阅读,更多相关《第11讲1--初始嵌入式SQL.pdf(20页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。

1、? An Introduction to Database System? ? ? ? ? ? ? An Introduction to Database System SQL? ?SQL? ? ? 1? 2? An Introduction to Database System ?SQL? ?SQL? 1 ?SQL 2 ?SQL? ? ? ?SQL 3 ? ?ODBC? An Introduction to Database System ?11?SQL ? ?4?8.1? An Introduction to Database System Video 11-1?SQL An Introd

2、uction to Database System ?SQL #include #include EXEC SQL BEGIN DECLARE SECTION; /*? */ char HSno9; char HSname20; char HSex2; int HSage; char Hdept20; EXEC SQL END DECLARE SECTION; /*? */ long SQLCODE; EXEC SQL INCLUDE sqlca; /*?SQL? */ int main() /*c? */ printf(Please input the sno:);/*? */ scanf(

3、%s, HSno); /* ?TEST?localhost? ?54321?SYSTEM/krms? */ EXEC SQL CONNECT TO TESTlocalhost:54321 AS CONN1 USER SYSTEM“ USING “manager; EXEC SQL SELECT Sno,Sname,Ssex,Sage,Sdept INTO:Hsno,:Hname,:Hsex,:Hage,:Hdept FROM Student WHERE Sno=:HSno; if (sqlca.sqlcode = 0) printf(n% - 9s% - 20s% - 2s% - 4s% -

4、20sn, Sno, Sname, Ssex, Sage, Sdept); printf(% - 9s% - 20s% - 2s% - 4s% - 20sn, Hsno, Hname, Hsex, HSage, Hdept); EXEC SQL DISCONNECT CONN1; return 0; An Introduction to Database System ?SQL? ? ?SQL?SQL? ? ? ?EXEC SQL? ?C? ? EXEC SQL ; ? ?EXEC SQL SELECT Sno,Sname,Ssex,Sage,Sdept INTO:Hsno,:Hname,:H

5、sex,:Hage,:Hdept FROM Student WHERE Sno=:givensno; An Introduction to Database System ?SQL? ? SQL? ? ? ? ? ? ? ? ?SQL ? ? ? ? ? ? ? ? (? ?SQL) ? ? ? ? ? ? ? An Introduction to Database System ? ? ? ?SQL? ? ? ? ? An Introduction to Database System 1 ? EXEC SQL CONNECT TO target AS connection-name USE

6、R user-name; ? target? ?: ?SQL? ?DEFAULT An Introduction to Database System ? EXEC SQL CONNECT TO target AS connection-name USER user-name; ? connect-name? ? ? ? EXEC SQL SET CONNECTION connection-name |DEFAULT; An Introduction to Database System 2 ? EXEC SQL BEGIN DECLARE SECTION; /*?*/ char Deptna

7、me20; char Hsno9; char Hsname20; char Hssex2; int HSage; int NEWAGE; EXEC SQL END DECLARE SECTION; /*?*/ long SQLCODE; EXEC SQL INCLUDE SQLCA; /*?SQL?*/ An Introduction to Database System 3 ?SQL? ? ?SQL? ? ? (CREATE) ? ? (GRANT,REVOKE?COMMIT?ROBACK) ? ? (UPDATE, INSERT, DELETE) ? ? (SELECT) An Intro

8、duction to Database System SELECT? ? ?8.2 ? EXEC SQL SELECT Sno,Sname,Ssex,Sage,Sdept INTO:Hsno,:Hname,:Hsex,:Hage,:Hdept FROM Student WHERE Sno=:givensno; /* ?INTO? */ /*? */ An Introduction to Database System SELECT? ? INTO?WHERE?HAVING? ? ? ? ? ?NULL ? ? ? ? ? ? ? ? ?11-3? An Introduction to Data

9、base System ? ? ?UPDATE?SET?WHERE? ? ?8.4 ?1? EXEC SQL UPDATE SC SET Grade=:newgrade /*?newgrade*/ WHERE Sno=:givensno AND Cno=?1?; /*?givensno*/ An Introduction to Database System 4 ? EXEC SQL DISCONNECT connection; An Introduction to Database System 5. ? ?8.1 ? EXEC SQL BEGIN DECLARE SECTION; char

10、 Deptname20; char HSNo9; char HSName20; char HSSex2; int HSAge; EXEC SQL END DECLARE SECTION; long SQLCODE; EXEC SQL INCLUDE SQLCA; ? ?SQL? An Introduction to Database System ? int main(void) /*C?*/ printf(“Please input the student number ); scanf(%s, Hsno); /*?Hsno?*/ EXEC SQL CONNECT TO TESTlocalh

11、ost:54321 AS CONN1 USER SYSTEM USING MANAGER; EXEC SQL SELECT Sno,Sname,Ssex,Sage,Sdept INTO:Hsno,:Hname,:Hsex,:Hage,:Hdept FROM Student WHERE Sno=:HSno; ?Test? ?SQL? An Introduction to Database System ? if (sqlca.sqlcode = 0) /* SQLCA?SQLCODE = 0 ? */ printf(n% - 9s% - 20s% - 2s% - 4s% - 20sn, Sno, Sname, Ssex, Sage, Sdept); printf(% - 9s% - 20s% - 2s% - 4s% - 20sn, Hsno, Hname, Hsex, HSage, Hdept); EXEC SQL DISCONNECT CONN1; ?

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 教育专区 > 大学资料

本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知淘文阁网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

工信部备案号:黑ICP备15003705号© 2020-2023 www.taowenge.com 淘文阁