标签:
一些内置程序包
程序包名称 |
说明 |
STANDARD和DBMS_STANDARD |
定义和扩展PL/SQL语言环境 |
DBMS_LOB |
提供对 LOB数据类型进行操作的功能 |
DBMS_OUTPUT |
处理PL/SQL块和子程序输出调试信息 |
DBMS_RANDOM |
提供随机数生成器 |
DBMS_SQL |
允许用户使用动态 SQL |
DBMS_XMLDOM |
用DOM模型读写XML类型的数据 |
DBMS_XMLPARSER |
XML解析,处理XML文档内容和结构 |
DBMS_XMLQUERY |
提供将数据转换为 XML 类型的功能 |
DBMS_XSLPROCESSOR |
提供XSLT功能,转换XML文档 |
UTL_FILE |
用 PL/SQL 程序来读写操作系统文本文件 |
SET SERVEROUTPUT ON BEGIN DBMS_OUTPUT.PUT_LINE(‘打印三角形‘); FOR i IN 1..9 LOOP FOR j IN 1..i LOOP DBMS_OUTPUT.PUT(‘*‘); END LOOP for_j; DBMS_OUTPUT.NEW_LINE; END LOOP for_i; END;
DECLARE result CLOB; xmlstr VARCHAR2(32767); line VARCHAR2(2000); line_no INTEGER := 1; BEGIN result := DBMS_XMLQuery.getXml(‘SELECT empno, ename FROM employee‘); xmlstr := DBMS_LOB.SUBSTR(result,32767); LOOP EXIT WHEN xmlstr IS NULL; line := SUBSTR(xmlstr,1,INSTR(xmlstr,CHR(10))-1); DBMS_OUTPUT.PUT_LINE(line_no || ‘:‘ || line); xmlstr := SUBSTR(xmlstr,INSTR(xmlstr,CHR(10))+1); line_no := line_no + 1; END LOOP; END;
DBMS_RANDOM 包可用来生成8位的随机正负整数
SET SERVEROUTPUT ON DECLARE l_num NUMBER; counter NUMBER; BEGIN counter:=1; WHILE counter <= 10 LOOP l_num := DBMS_RANDOM.RANDOM; DBMS_OUTPUT.PUT_LINE(l_num); counter:=counter+1; END LOOP; END;
CREATE DIRECTORY TEST_DIR AS ‘C:\DEVELOP‘;
GRANT READ, WRITE ON DIRECTORY TEST_DIR TO SCOTT;
SET SERVEROUTPUT ON DECLARE input_file UTL_FILE.FILE_TYPE; input_buffer VARCHAR2(4000); BEGIN input_file := UTL_FILE.FOPEN(‘TEST_DIR‘, ‘employees.xml‘, ‘r‘); LOOP UTL_FILE.GET_LINE(input_file,input_buffer); DBMS_OUTPUT.PUT_LINE(input_buffer); END LOOP; UTL_FILE.FCLOSE(input_file); EXCEPTION WHEN NO_DATA_FOUND THEN DBMS_OUTPUT.PUT_LINE(‘------------------‘); END;
标签:
原文地址:http://www.cnblogs.com/hopeblog/p/5003835.html