---
title: "PL/SQL基础总结"
author: "lanrikey"
date: "2016-12-22T10:19:34Z"
tags: []
categories: ["非技术"]
slug: "pl-sql"
draft: false
lastmod: "2016-12-22T10:36:55Z"
id: 2346679
url: "https://lanrikey.iteye.com/blog/2346679"
---

总结第一次全面写pl/sql基础 

 

1、“=” 是比较，“:=”是赋值，

2.sys\_refcursor 返回结果集类型之一，动态sql打开（可以查看对应文章），

 EXECUTE IMMEDIATE get\_count\_sql INTO n\_countA,n\_countP; 动态sql执行 count类型SQL ：select count（\*） from table;

3.动态sql字符串拼接单引号问题：2个单引号 ：trunc(sysdate,'||'''YYYY'''||') 等译trunc(sysdate,'yyyy');

4.    --自定义接受类型；

    type my\_record is record(  

      n\_lossno gcpolicypaidhistorytemp.lossno%type,

      n\_lossseqno gcpolicypaidhistorytemp.lossseqno%type,

      n\_upload gcpolicypaidhistorytemp.upload%type); 

    my\_rec my\_record;

5.异常信息打印

    exception when others then

       v\_backtrace := dbms\_utility.format\_error\_backtrace;

        dbms\_output.put\_line(v\_backtrace);

http://www.yiibai.com/plsql/plsql\_cursors.html 这个基础教程很好