当前位置:网站首页>Kingbasees plug-in DBMS of Jincang database_ OUTPUT
Kingbasees plug-in DBMS of Jincang database_ OUTPUT
2022-06-25 11:07:00 【Thousands of sails pass by the side of the sunken boat_】
Catalog
5. DBMS_OUTPUT The system package supports entering information into the buffer
6. DBMS_OUTPUT The system package supports getting information from the buffer
7. DBMS_OUTPUT The system package supports the client to display buffer information
1. summary
DBMS_OUTPUT System packages can provide the ability to write text lines to a buffer 、 Functions for later extraction and display . Mainly used for debugging PL/SQL Program , Or in Ksql Display information and reports in client commands , For example, we can write a simple anonymous pl/sql Block , The block can use this package to display some information for some purpose .
DBMS_OUTPUT The system package does not support PG Pattern .
2. Limit
DBMS_OUTPUT Row and buffer size limits :
- The maximum row size is 32767 byte .
- The default buffer size is 20000 byte . The minimum is 2000 byte , The greatest is infinite .
3. Enable
Grammar format :
DBMS_OUTPUT.ENABLE(buffer_size IN INTEGER DEFAULT 20000);
Function description :
This procedure allows you to call PUT、PUT_LINE、NEW_LINE、GET_LINE and GET_LINES Etc .
Parameter description :
buffer_size: The maximum buffer size is 1000000 byte , The minimum is 2000 byte , The default is 20000 byte . take buffer_size Set to null, There will be no limit on the buffer size .
Instructions :
- If it's not activated DBMS_OUTPUT package , Calls to these procedures will be ignored .
- If there are multiple calls to enable , that buffer_size The last specified value .
- When set serveroutput on When it is turned on, it is not necessary to call enable and disable The process .
- The cache setting size range is 2000 to 1000000, If buffer_size The value is less than 2000, Then for 2000; If buffer_size The value of exceeds 1000000, Then for 1000000; If the data size of the input buffer exceeds the maximum value set by the buffer , Will report an error directly .
Example :
call dbms_output.enable();
call dbms_output.enable(NULL);
call dbms_output.enable(3000);
4. Ban
Grammar format :
DBMS_OUTPUT.DISABLE();
Function description :
This procedure disables access to PUT、PUT_LINE、NEW_LINE、GET_LINE and GET_LINES And so on , And clear the buffer .
Instructions :
- If it's time to DBMS_OUTPUT Packages are disabled , So all of its subroutines (subprogram) Will be ignored . This allows users to design applications , Enable these subroutines only if the client program can process this information .
- If set serveroutput off Time to call disable The process , Next time you call another procedure , Must call enable The process .
5. DBMS_OUTPUT The system package supports entering information into the buffer
5.1. Append content to the buffer
Grammar format :
DBMS_OUTPUT.PUT(item IN VARCHAR2);
Function description :
This process is used to append part of the content to Buffer The last line in .
Instructions :
- When adding content, you can use put Process input , If you want to input in a whole line, you'd better use put_line The process .
- If the length of a single line exceeds the limit, an error will be reported , Or if the input data exceeds the set value of the cache, an error will be reported .
- Pay attention to calling PUT or PUT_LINE Of PL/SQL Before the end of the program unit , Yes PUT or PUT_LINE The specified content will not be output .
- When calling PUT_LINE Line breaks will be automatically added to the procedure , If you use PUT To construct the bank , Then it must be used manually NEW_LINE Procedure to add line breaks .GET_LINE and GET_LINES The procedure does not return a line that does not end with a newline character .
Example :
set serveroutput on
\set SQLTERM /
begin
dbms_output.put('test1');
dbms_output.new_line();
dbms_output.put('test2');
end;
/
5.2. Append single line information to the buffer
Grammar format :
DBMS_OUTPUT.PUT_LINE(item IN VARCHAR2);
Function description :
This stored procedure is used to send a message to Buffer A new line of information is added to the .
Instructions :
- If the input data exceeds the set value of the buffer, an error will be reported .
- GET_LINE and GET_LINES Do not return lines that are not terminated with a newline character .
Example :
set serverout on
call dbms_output.put_line('hi' || chr(10) || 'hello'||chr(10) || '
world');
/
5.3. Append a new row to the buffer
Grammar format :
DBMS_OUTPUT.NEW_LINE();
Function description :
The stored procedure adds a line break to the buffer , Generate a new line .
Instructions :
- A new row is generated every time it is called .
Example :
set serverout on
begin
dbms_output.put('test1');
dbms_output.new_line();
dbms_output.put('test2');
dbms_output.new_line();
dbms_output.new_line();
dbms_output.put_line('test3');
end;
/
6. DBMS_OUTPUT The system package supports getting information from the buffer
6.1. Get the first line of information
Grammar format :
DBMS_OUTPUT.GET_LINE(line OUT VARCHAR2, status OUT INTEGER);
Function description :
The process starts from buffer Get single line information in , The information added first is obtained first , After acquisition buffer This information in will be deleted .
Parameter and return value instructions :
- line: Will get buffer A line of information in , But does not include the last line break .
- status: If the call succeeds, it returns 0, If the call fails, it returns 1.
Instructions :
call GET_LINE or GET_LINES After successfully obtaining the content , In the next call PUT, PUT_LINE or NEW_LINE Any cache that is not fetched before the process will be discarded , To avoid misunderstanding .
Example :
set serverout on
\set SQLTERM /
declare
line varchar2(120);
status integer;
begin
dbms_output.put('hello');
dbms_output.put_line('world');
dbms_output.get_line(line, status);
dbms_output.put_line(line || status);
end;
/
6.2. Get multi line information
Grammar format :
PROCEDURE get_lines(lines OUT CHARARR, numlines IN OUT integer);
PROCEDURE get_lines(lines OUT DBMSOUTPUT_LINESARRAY, numlines IN OUT
integer);
Function description :
This stored procedure is used to retrieve data from Buffer Get a multi row array from , After acquisition buffer This information in will be deleted .
Description of parameters and return values :
- CHARARR( In package type ):TYPE CHARARR IS TABLE OF VARCHAR2(32767) INDEX BY INT;
- DBMSOUTPUT_LINESARRAY( Out of package type ):TYPE DBMSOUTPUT_LINESARRAY IS VARRAY(2147483647) OF VARCHAR2(32767);
- lines: Returns the row array of buffered information . The maximum length of each row in the array is 32767 byte .
- numlines: When the number of rows in the cache is greater than or equal to the number of rows retrieved , Returns the number of rows retrieved ; When the number of rows in the cache is less than the number of rows retrieved , Returns the number of rows in the cache .
Instructions :
- After getting the information , If the input procedure is called next time , Any rows that are not retrieved will be discarded , To avoid confusion with the next message .
- CHARARR type numlines Parameters : When no parameter is specified or this parameter is less than or equal to 0, Don't get content , And back to numlines by 0; When this parameter is greater than 0, If the number of rows in the cache is greater than or equal to the number of rows retrieved , Returns the number of rows retrieved ; If the number of rows in the cache is less than the number of rows retrieved , Returns the number of rows in the cache .
- DBMSOUTPUT_LINESARRAY type numlines Parameters : When no parameter is specified , Get all contents by default , And back to numlines To get the number of rows ; When this parameter is less than 0, Will be an error ; When the parameter is greater than or equal to 0 when , If the number of rows in the cache is greater than or equal to the number of rows retrieved , Returns the number of rows retrieved , When the number of rows in the cache is less than the number of rows retrieved , Returns the number of rows in the cache .
Example :
set serverout on
DECLARE
v_data dbms_output.CHARARR;
numlines integer := 2;
BEGIN
dbms_output.put_line('TEST 1');
dbms_output.put_line('TEST 2');
dbms_output.put_line('TEST 3');
dbms_output.get_lines(v_data, numlines);
dbms_output.put_line(v_data(1));
dbms_output.put_line(v_data(2));
end;
/
DECLARE
v_data DBMSOUTPUT_LINESARRAY;
numlines integer := 2;
BEGIN
dbms_output.put_line('TEST 1');
dbms_output.put_line('TEST 2');
dbms_output.get_lines(v_data, numlines);
dbms_output.put_line(numlines);
dbms_output.put_line(v_data(1));
dbms_output.put_line(v_data(2));
end;
/
7. DBMS_OUTPUT The system package supports the client to display buffer information
7.1. The client command starts the output function
Grammar format :
set serverout[put] on[;]
Function description :
- Enable DBMS_OUTPUT System package functions .
- The cache size is set to unlimited .
- Can replace enable The process , That is, you don't need enable The process .
- Client output cache messages .
Instructions :
set serverout[put] Follow ‘on’ or ‘on;’, When you enter an unrelated command, you will be prompted with a command error .
Example :
set serverout on
create or replace procedure protest_A_1 is
begin
dbms_output.put_line('....test1');
dbms_output.put_line('....test2');
end;
/
declare
v_status integer := 0;
v_data varchar2(100);
begin
protest_A_1();
dbms_output.put_line('test3');
dbms_output.get_line(v_data, v_status);
dbms_output.put_line('v_data: ' ||v_data || 'v_status: ' ||v_status);
dbms_output.put_line('test4');
end;
/
7.2. The client command disables the output function
Grammar format :
set serverout[put] off[;]
Function description :
- Ban DBMS_OUTPUT System package functions .
- Clear cache .
- Can replace disable The process , That is, you don't need disable The process .
Instructions :
set serverout[put] Follow ‘off’ or ‘off;’, When you enter an unrelated command, you will be prompted with a command error .
Example :
set serverout off
call dbms_output.put_line('hi' || chr(10) || 'hello'||chr(10) || '
world');
/
边栏推荐
- 【文件包含漏洞-03】文件包含漏洞的六种利用方式
- June 24, 2022: golang multiple choice question, what does the following golang code output? A:1; B:3; C:4; D: Compilation failed. package main import ( “fmt“ ) func mai
- Output reading: apply what you have learned
- 《天天数学》连载52:二月二十日
- 网易开源的分布式存储系统 Curve 正式成为 CNCF 沙箱项目
- zabbix分布式系统监控
- Google Earth engine (GEE) - evaluate enables one click batch download of all single images in the research area (some areas in Shanghai)
- Learn to learn self-study [learning to learn itself is more important than learning anything]
- 金仓数据库 KingbaseES 插件DBMS_UTILITY
- GaussDB others内存比较高的场景
猜你喜欢
ES 学习
【观察】ObjectScale:重新定义下一代对象存储,戴尔科技的重构与创新
软件测试 避免“试用期被辞退“指南,看这一篇就够了
Shen Ying, China Academy of communications and communications: font open source protocol -- Introduction to ofl v1.1 and analysis of key points of compliance
网络远程访问的方式使用树莓派
[file containing vulnerability-03] six ways to exploit file containing vulnerabilities
Oracle彻底卸载的完整步骤
FPGA displays characters and pictures based on VGA
Technical practice and development trend of video conference all in one machine
【文件包含漏洞-04】经典面试题:已知某网站仅存在本地文件包含漏洞时,如何GetShell?
随机推荐
服务端渲染
3 Questions par jour (3) - vérifier l'existence d'entiers et de leurs doubles
Introduction to socket UDP and TCP
撸一个随机数生成器
报名开启|飞桨黑客马拉松第三期如约而至,久等啦
金仓KFS数据级联场景部署
金仓数据库 KingbaseES 插件DBMS_OUTPUT
Nuxtjs actual combat case
Dell technology performs the "fast" formula and plays ci/cd
【图像融合】基于形态学分析结合稀疏表征实现图像融合附matlab代码
MySQL synchronous data configuration and shell script implementation
每日3題(3)-檢查整數及其兩倍數是否存在
Growth: how to think deeply and learn
What are the functions of arm64 assembly that need attention?
keep-alive
CSRF攻击
Sign up to open the third session of the "flying oar hacker marathon". It's been a long time
Google Earth Engine (Gee) - evaluate réalise le téléchargement en un clic de toutes les images individuelles dans la zone d'étude (certaines parties de Shanghai)
每日3题(2)- 找出数组中的幸运数
scrapy+scrapyd+gerapy 爬虫调度框架