




已阅读5页,还剩28页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1 ALTIBASE开发培训 天津南开创元信息技术有限公司韩国Altibase公司 2 CONTENTS 1 AltibaseCLI 3 1 AltibaseCLI CLIOverviewCLIAPIGroupsBasicProgrammingStepsNoteswhenimplementingProgramsSample Basic 4 Overview 1 CallLevelInterfaceCLIIsStandard AltibaseCLIcomplieswithX OPENCLIstandardspecification Soyoucanfindeasilyusefulsampleanddocumentsex Altibase MSDN ODBC DB2 Informix Postgres Enablesyoutowritedatabaseindependentapplications 5 Overview 2 DifferencebetweenCLIandEmbeddedSQL Ex SQLExecDirect stmt deletefromt1 SQL NTS EXECSQLdeletefromT1 E SQL SESC ProC needsprecompilestep Belowtwothingsismypersonalopinions E SQLismoreeasyindevelopmentandsourcereadability InC Object OrientedStyledevelopmethod CLIcanbemoregoodchoicethanE SQL 6 Overview 3 CLIAPIFunctionsGroupsEnvironment ConnectionManagementex SQLAllocEnv SQLDriverConnect SQLStatementProcessingex SQLPrepare SQLExecute AttributeProcessingex SQLSetConnectAttr SQLSetStmtAttr MetaInformationProcessingex SQLTables CLIAPIGroups 1 Environment ConnectionManagement SQLStatementProcessing SQLAllocEnv SQLAllocConnect SQLAllocStmt SQLFreeEnv SQLFreeConnect SQLFreeStmt SQLDriverConnectSQLConnectSQLDisconnect SQLPrepare SQLBindParameter SQLExecute SQLNumResultColsSQLDescribeColSQLRowCountSQLGetData SQLBindColSQLFetchSQLExecDirectSQLEndTran 8 AttributeProcessing MetaInformationProcessing SQLSetEnvAttr SQLSetConnectAttr SQLSetStmtAttr ex ArrayInsert Update SQLTablesSQLColumnsSQLProcedures SQLPrimaryKeysSQLForeignKeysSQLStatistics CLIAPIGroups 2 SQLProcedureColumnsSQLSpecialColumnsSQLTablePrivilegs 9 SQLRETURNSQLAllocEnv SQLHENV env rc SQLAllocEnv Allocatesanenvironmenthandleandassociatedresources if rc SQL SUCCESS Environment ConnectionManagement 1 SQLRETURNSQLAllocConnect SQLHENVenv SQLHDBC dbc rc SQLAllocConnect henv Allocatesaconnectionhandleandassociatedresourcesif rc SQL SUCCESS SQLRETURNSQLAllocStmt SQLHDBCDBC SQLHSTMT stmt rc SQLAllocStmt Allocatesanewstatementhandleand associatesitwiththeconnectionspecifiedbytheconnectionhandle if rc SQL SUCCESS 10 SQLRETURNSQLFreeEnv SQLHENVenv SQLRETURNSQLFreeConnect SQLHDBCdbc SQLRETURNSQLFreeStmt SQLHSTMTstmt SQLSMALLINTfOption rc SQLFreeStmt hstmt SQL DROP Freesastatementhandleif rc SQL SUCCESS rc SQLDisconnect hdbc Closestheconnectionassociatedwiththedatabaseconnectionhandle if rc SQL SUCCESS printf DisconnectError n SQLFreeConnect hdbc Invalidatesandfreestheconnectionhandle SQLFreeEnv henv Invalidatesandfreestheenvironmenthandle Environment ConnectionManagement 2 11 SQLRETURNSQLDriverConnect SQLHDBCdbc SQLHWNDwindowHandle NotUsed SQLCHAR InConnectionString SQLSMALLINT length1 SQLCHAR OutConnectionString SQLSMALLINTbufferLength SQLSMALLINT strlength2Ptr SQLSMALLINT DriverCompletion charconnstr 100 sprintf connstr DSN s UID s PWD s CONNTYPE 1 PORT NO s server uid pwd port rc SQLDriverConnect hdbc NULL connstr SQL NTS NULL 0 NULL SQL DRIVER NOPROMPT if rc SQL SUCCESS Environment ConnectionManagement 3 12 sprintf sql SELECTENAMEFROMEMPLOYEEWHERENAME rc SQLPrepare hstmt1 sql SQL NTS SQLStatementProcessingExamples 1 SQLRETURNSQLPrepare SQLHSTMTstmt SQLCHAR sql SQLINTEGERsqlLength SQLRETURNupd execute intpos if chk stmt u NOT YET PREPARED rc upd prepare performancefactor if SQLExecute stmt u SQL SUCCESS unicom upd ins cli app1 cpp 13 SQLRETURNSQLBindParameter SQLHSTMTStatementHandle SQLSMALLINTParameterNumber SQLSMALLINTpType SQLSMALLINTcType SQLSMALLINTsqlType SQLINTEGERcolumnSize SQLSMALLINTscale numeric columnSize scale SQLPOINTERParameterValuePtr SQLINTEGERBufferLength sizeof ParameterValuePrt SQLINTEGER StrLen or IndPtr when 1meansNULLvalueSQL NULL DATA 1 SQLStatementProcessingExamples 2 rc SQLBindParameter hstmt1 1 SQL PARAM INPUT SQL C CHAR SQL VARCHAR ID LEN 0 id sizeof id NULL if rc SQL SUCCESS 14 Correcttypematchingismajorperformancefator integer smallint bigintdatatypesshowfasterperformancethannumeric Speciallyintheindexcolumn numerictypehavebigtypeconversioncost SQLStatementProcessingExamples 3 15 SQLRETURNSQLBindCol SQLHSTMTstmt SQLSMALLINTColumnNumber SQLSMALLINTTargetType SQLPOINTERTargetValuePtr SQLINTEGERBufferLength SQLINTEGER StrLen or IndPtr SQLRETURNSQLFetch SQLHSTMTstmt SQLStatementProcessingExamples 4 16 SQLExecDirect Thisisjustsample Don tuseSQLExecDirectforperformancehstmt2 selectid namefromemployee SQL NTS if SQL SUCCESS SQLBindCol hstmt2 1 SQL C CHAR id 8 NULL if SQL SUCCESS SQLBindCol hstmt2 2 SQL C CHAR name 30 SQLStatementProcessingExamples 5 2020 3 15 17 可编辑 BasicProgrammingSteps 1 CLIApplicationcontains InitializationTransactionProcessingTerminationDiagnosticMessageHandling 19 STEP1 CONNECTSQLAllocHandle env SQLAllocEnvSQLSetEnvAttrSQLAllocHandle dbc SQLAllocConnectSQLDriverConnectSQLSetConnectAttr setnon autocommit BasicProgrammingSteps STEP2 INITIALIZESQLAllocHandle stmt SQLAllocStmtSQLSetStmtAttr whenarraybinding BasicProgrammingSteps 2 20 STEP3 ExecuteMetaCatalogfunctionOrSQLExecute SQLExecDirect 1 SelectorMetaCatalog STEP4a FetchResultsSQLNumResultColsSQLDescribeColSQLBindColSQLFetchSQLGetData STEP4b FetchRowCountSQLRowCount Non array affectedresultnum 2 Update Delete Insert 3 Other BasicProgrammingSteps 3 21 STEP5 TRANSACTSQLEndTran STEP6 DISCONNECTSQLFreeHandle stmt SQLFreeStmtSQLDisconnectSQLFreeHandle dbc SQLFreeConnectSQLFreeHandle env SQLFreeEnv BasicProgrammingSteps 4 22 NotesWhenImplementingPrograms 1 Step1 Formulti threadprogram thefunctionideAllocErrorSpace shouldbecalledinthreadmainfunctionbeforeotherDBfunctions Formulti threadprogram thesameconnectionhandlemustnotbeusedonothertheads CLIAPIisnotsafeinSignal Don tuseSignal ifitisneeded thenusethread if 0 pthread create sample SQLCLI demo mt cpp 23 NotesWhenImplementingPrograms 2 Step2 InSQLBindCol orSQLBindParameter thelastparametervalueLength lStrLen or IndPtr isindicatorvariabletocheck NULLorNotNULL Step3 WhenyouexitaprogramwithoutexecutingtheCOMMITstatementinAUTOCOMMITOFFsession SQLstatementsthatyoucannotfinishareallROLLBACKed ButiftheprogramexitsafterexecutingtheSQLDisconnect theCOMMITstatementisperformed 24 Step4 InSQLFreeStmt RememberthedifferencebetweenSQL DROPandSQL CLOSE SQL DROPReleaseallresourceofthestatement Forreuse firstlySQLAllocStmtisneeded SQL CLOSECheckdemo ex2 cpp Thisisusedforreleasenon endedfetchresultonly NotesWhenImplementingPrograms 3 25 SQLFreeStmt stmt SQL CLOSE Ifacursorfetchedthelastrecordofaresultset SQL CLOSEcanbeomitted Howerver iftherearesomerecordstobefetchedbySQLFetch andSQLExecute isre executed invalidcusorerroroccurs sample SQLCLI demo ex2 cpp NotesWhenImplementingPrograms 4 26 include include include defineSQL LEN1000 defineMSG LEN1024SQLHENVenv Allocatesanenvironmenthandle SQLHDBCdbc Allocatesanconnectionhandle intconn flag intexecute type SQLRETURNalloc handle SQLRETURNdb connect voidfree handle SQLRETURNexecute select voidexecute err SQLHDBCaCon SQLHSTMTaStmt char q Sample Basic 1 27 intmain SQLRETURNrc env SQL NULL HENV dbc SQL NULL HDBC conn flag 0 execute type 1 Allocatesthehandle rc alloc handle if rc SQL SUCCESS free handle exit 1 rc db connect if rc SQL SUCCESS free handle exit 1 Sample Basic 1 Tasks switch execute type case1 rc execute select break case1 rc execute insert break case1 rc execute update break case1 rc execute delete break if rc SQL SUCCESS printf Successexecute free handle 28 voidexecute err SQLHDBCaCon SQLHSTMTaStmt char q SQLINTEGERSQLCODE SQLCHARSQLSTATE 7 SQLSMALLINTmsgLength SQLCHARerrMsg
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 重庆丰都县2025年上半年事业单位公开遴选试题含答案分析
- 毛皮市场:繁荣与机遇
- 河北省文安县2025年上半年事业单位公开遴选试题含答案分析
- 2025版石子行业绿色采购与销售战略合作协议
- 2025年度消防设备租赁与维护三方合作协议
- 2025版网络安全软件技术服务合同
- 2025定制加工合同范本:珠宝首饰定制加工合作协议
- 2025版新媒体内容运营与推广社会化媒体营销服务协议
- 2025版石材进出口贸易与金融服务合同
- 2025版彭园一处场地招租与电子商务平台合作协议
- 2023年版企业投资项目可行性研究报告编写参考大纲
- 陕西省中考数学历年(2016-2022年)真题分类汇编专题8四边形及答案
- 沈阳市双倍德化学厂锅炉改造项目环评报告
- GB/T 923-2009六角盖形螺母
- GB/T 35690-2017弱磁材料相对磁导率的测量方法
- 学会关心-教育的另一种模式课件
- JB∕T 13977-2020 液化天然气(LNG)低温潜液泵
- 口咽通气道的使用方法
- 消防火灾自动报警主机更换(增加)施工方案
- 山西省太原市小升初语文试卷(含答案)
- 质量管理统计工具(共102页).ppt
评论
0/150
提交评论