Control Structures of PL/SQL Control structures are probably the most useful (and important) part of PL/pgSQL.With PL/pgSQL's control structures, you can manipulate PostgreSQL data in a very flexible and powerful way. 1.Returning From a Function RETU…
Trigger Procedures PL/pgSQL can be used to define trigger procedures on data changes or database events. A trigger procedure is created with the CREATE FUNCTION command, declaring it as a function with no arguments and a return type of trigger (for d…
1 PL/pgSQL Under the Hood This part discusses some implementation details that are frequently important for PL/pgSQL users to know. 1.1 Variable Substitution SQL statements and expressions within a PL/pgSQL function can refer to variables and paramet…
Cursors Rather than executing a whole query at once, it is possible to set up a cursor that encapsulates the query, and then read the query result a few rows at a time. A more interesting usage is to return a reference to a cursor that a function has…
1.Structure of PL/pgSQL The structure of PL/pgSQL is like below: [ <<label>> ] [ DECLARE declarations ] BEGIN statements END [ label ]; A label is only needed if you want to identify the block for use in an EXIT statement, or to qualify the na…
Errors and Messages 1. Reporting Errors and Messages Use the RAISE statement to report messages and raise errors. RAISE [ level ] 'format' [, expression [, ... ]] [ USING option = expression [, ... ] ]; RAISE [ level ] condition_name [ USING option =…
原文:ORACLE PL/SQL编程之八:把触发器说透 ORACLE PL/SQL编程之八: 把触发器说透 大家一定要评论呀,感谢!光发表就花了我将近一个下午. 本篇主要内容如下: 8.1 触发器类型 8.1.1 DML触发器 8.1.2 替代触发器 8.1.3 系统触发器 8.2 创建触发器 8.2.1 触发器触发次序 8.2.2 创建DML触发器 8.2.3 创建替代(INSTEAD OF)触发器 8.2.3 创建系统事件触发器 8.2.4 系统触发器事件属性 8.2.5 使用触发器谓词 8…
异常处理 异常产生所带来的问题: 使用EXCEPTION程序块进行异常处理: 实现用户自定义异常. 使用异常可以保证在程序中出现运行时异常时程序可以正常的执行完毕: 用户可以使用自定义异常进行操作. 异常简介 在程序开发之中经常会由于设计错误.编码错误.硬件故障或其他原因引起程序的运行错误.虽然不可能预测所有错误,但在程序中可以规划处理某些类型的错误.在PL/SQL程序中的异常处理机制使得在出现某些错误的时候程序仍然可以执行.比如内部溢出或者零除等等. 用户可以处理的只有运行时异常,而对于编译的…
1._rowid 类似Oracle的rowid mysql> ; +-------+----+----------------+-------------+---------------+------------+ | rowid | ID | Name | CountryCode | District | Population | +-------+----+----------------+-------------+---------------+------------+ | | | K…
1.MySQL的历史,一些相关概念. 2.MySQL数据类型 *通常一个页内可以存放尽可能多的行,那么数据库的性能就越好,选择一个正确的数据类型至关重要. 1>UNSIGNED类型: 将数字类型无符号化. 2>ZEROFILL: 可以格式化整形显示,一旦启用该属性,MySQL数据库为列自动添加UNSIGNED属性.0填充. 3>日期和时间类型 日期数据类型占用空间的情况 类型 起始范围 结束范围 DATETIME 1000-01-01 00:00:00 9999-12-31 23:59:…