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…
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 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…
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.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编程之四: 把游标说透(不怕做不到,只怕想不到) 继上两篇:ORACLE PL/SQL编程之八:把触发器说透 ORACLE PL/SQL编程之六:把过程与函数说透(穷追猛打,把根儿都拔起!) 得到了大家的强力支持,感谢.接下来再下猛药,介绍下一篇,大家一定要支持与推荐呀~!我也才有动力写后面的. 本篇主要内容如下: 4.1 游标概念 4.1.1 处理显式游标 4.1.2 处理…
游标--数据的缓存区 游标:类似集合,可以让用户像操作数组一样操作查询出来的数据集,实质上,它提供了一种从集合性质的结果中提取单条记录的手段. 可以将游标形象的看成一个变动的光标,他实质上是一个指针,在一段Oracle存放数据查询结果集或者数据操作结果集的内存中,这个指针可以指向结果集任何一条记录. 游标分静态游标和REF游标两类,静态游标包含显式游标和隐式游标. 显式游标: 在使用之前必须有明确的游标声明和定义,这样的游标定义会关联数据查询语句,通常会返回一行或多行.打开游标后,用户可以利用游…
数据类型划分 在Oracle之中所提供的数据类型,一共分为四类: 标量类型(SCALAR,或称基本数据类型) 用于保存单个值,例如:字符串.数字.日期.布尔: 标量类型只是作为单一类型的数据存在,有的只能够在PL/SQL中使用. 复合类型(COMPOSITE) 复合类型可以在内部存放多种数值,类似于多个变量的集合, 例如:记录类型.嵌套表.索引表.可变数组等都称为复合类型: 引用类型(REFERENCE) 用于指向另一不同的对象,例如:REF CURSOR.REF: LOB类型 大数据类型,最多…
1.TCP连接的建立方法 客户端在建立一个TCP连接时一般需要两步,而服务器的这个过程需要四步,具体见下面的比较. 步骤 TCP客户端 TCP服务器 第一步 建立socket对象  建立socket对象 第二步 调用connect()建立一个和服务器的连接 设置socket选项(可选) 第三步 无 绑定到一个端口(也可以是一个指定的网卡) 第四步 无 侦听连接 下面具体来讲这四步的建立方法: 第一步,建立socket对象:这里与客户端一样,依然是: s=socket.socket(socket.…