PL-SQL(存储过程培训).ppt

PL-SQL(存储过程培训).ppt

ID:48088393

大小:244.00 KB

页数:42页

时间:2020-01-14

PL-SQL(存储过程培训).ppt_第1页
PL-SQL(存储过程培训).ppt_第2页
PL-SQL(存储过程培训).ppt_第3页
PL-SQL(存储过程培训).ppt_第4页
PL-SQL(存储过程培训).ppt_第5页
资源描述:

《PL-SQL(存储过程培训).ppt》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库

1、ProgramminginOracle withPL/SQLProceduralLanguageExtensiontoSQLPL/SQLAllowsusinggeneralprogrammingtoolswithSQL,forexample:loops,conditions,functions,etc.ThisallowsalotmorefreedomthangeneralSQL,andislighter-weightthanJDBC.WewritePL/SQLcodeinaregularfile,forexamplePL.sql,andloaditw

2、ith@PLinthesqlplusconsole.PL/SQLBlocksPL/SQLcodeisbuiltofBlocks,withauniquestructure.TherearetwotypesofblocksinPL/SQL:AnonymousBlocks:havenoname(likescripts)canbewrittenandexecutedimmediatelyinSQLPLUScanbeusedinatrigger2.NamedBlocks:ProceduresFunctionsAnonymousBlockStructure:DEC

3、LARE(optional)/*Hereyoudeclarethevariablesyouwilluseinthisblock*/BEGIN(mandatory)/*Hereyoudefinetheexecutablestatements(whattheblockDOES!)*/EXCEPTION(optional)/*Hereyoudefinetheactionsthattakeplaceifanexceptionisthrownduringtherunofthisblock*/END;(mandatory)/Alwaysputanewlinewit

4、honlya/attheendofablock!(ThistellsOracletoruntheblock)Acorrectcompletionofablockwillgeneratethefollowingmessage:PL/SQLproceduresuccessfullycompletedDECLARESyntaxExamplesidentifier[CONSTANT]datatype[NOTNULL][:=

5、DEFAULTexpr];DeclarebirthdayDATE;ageNUMBER(2)NOTNULL:=27;nameVARCHAR2

6、(13):='Levi';magicCONSTANTNUMBER:=77;validBOOLEANNOTNULL:=TRUE;NoticethatPL/SQLincludesallSQLtypes,andmore…DeclaringVariableswiththe %TYPEAttributeExamplesDECLAREsnameSailors.sname%TYPE;fav_boatVARCHAR2(30);my_fav_boatfav_boat%TYPE:='Pinta';...AccessingcolumnsnameintableSailorsA

7、ccessinganothervariableDeclaringVariableswiththe %ROWTYPEAttributeDeclareavariablewiththetypeofaROWofatable.Andhowdoweaccessthefieldsinreserves_record?reserves_recordReserves%ROWTYPE;reserves_record.sid:=9;Reserves_record.bid:=877;AccessingtableReservesCreatingaPL/SQLRecordAreco

8、rdisatypeofvariablewhichwecandefine(like‘struct’inCor‘object’inJava)DECLARETYPEsailor_record_typeISRECORD(snameVARCHAR2(10),sidVARCHAR2(9),ageNUMBER(3),ratingNUMBER(3));sailor_recordsailor_record_type;...BEGINSailor_record.sname:=‘peter’;Sailor_record.age:=45;…CreatingaCursorWec

9、reateaCursorwhenwewanttogooveraresultofaquery(l

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。