DBE_OUTPUT
When DBE_OUTPUT.PUT_LINE is used to print the result obtained by the DBE_FILE.READ_LINE_NCHAR API, ensure that the UTF-8 character set encoding can be converted to the current database character set encoding. If the preceding conditions are met, the result can be properly output. DBE_OUTPUT.PRINT_LINE does not support this function.
Interface Description
Table 1 provides all interfaces supported by the DBE_OUTPUT package.
Interface |
Description |
---|---|
Outputs the specified text with newline characters. |
|
Outputs the specified text without newline characters. |
|
Sets the size of the output buffer. If the size is not specified, the buffer can contain a maximum of 20000 bytes. If the size is set to a value less than or equal to 2000 bytes, the buffer can contain a maximum of 2000 bytes. |
|
Disables the calling of PUT, PUT_LINE, NEW_LINE, GET_LINE and GET_LINES, and clears the output buffer. |
|
Enables the buffer, allows the calling of PUT, PUT_LINE, NEW_LINE, GET_LINE, and GET_LINES, and sets the buffer size. |
|
Obtains a line of data from the buffer with a newline character as the boundary. The obtained data is not output to the client. |
|
Obtains the character string of a specified number of lines in the buffer as a VARCHAR array. The obtained content is cleared from the buffer and is not output to the client. |
|
Places a line at the end of the buffer, places an end-of-line marker, and leaves a new line empty. |
|
Places an input string in the buffer without a newline character at the end. When the stored procedure ends, the line ending with the newline character is displayed. |
|
Places an input string in the buffer with a newline character at the end. When the stored procedure ends, the line ending with the newline character is displayed. |
- DBE_OUTPUT.PRINT_LINE
The stored procedure PRINT_LINE writes a line of text carrying a line end symbol in the buffer. The function prototype of DBE_OUTPUT.PRINT_LINE is as follows:
1 2
DBE_OUTPUT.PRINT_LINE ( format IN VARCHAR2);
- DBE_OUTPUT.PRINT
The stored procedure PRINT outputs the specified text to the front of the specified text without adding a newline character. The function prototype of DBE_OUTPUT.PRINT is as follows:
1 2
DBE_OUTPUT.PRINT ( format IN VARCHAR2);
- DBE_OUTPUT.ENABLE
The stored procedure ENABLE enables the buffer, allows the calling of PUT, PUT_LINE, NEW_LINE, GET_LINE, and GET_LINES, and sets the buffer size. The prototype of the DBE_OUTPUT.ENABLE function is as follows:
1 2 3
DBE_OUTPUT.ENABLE ( buffer_size IN INTEGER DEFAULT 20000 );
Table 5 DBE_OUTPUT.ENABLE parameters Parameter
Description
buffer_size
Upper limit of the buffer size, in bytes. If buffer_size is set to NULL, the default value is used.
- DBE_OUTPUT.GET_LINE
The stored procedure GET_LINE obtains a line of data from the buffer with a newline character as the boundary. The obtained data is not output to the client. The prototype of the DBE_OUTPUT.GET_LINE function is as follows:
1 2 3 4
DBE_OUTPUT.GET_LINE ( line OUT VARCHAR2, status OUT INTEGER );
Table 6 DBE_OUTPUT.GET_LINE parameters Parameter
Description
line
Indicates the obtained character string.
status
Indicates whether the calling is normal. If a character string is obtained, the value is 0. Otherwise, the value is 1.
- DBE_OUTPUT.GET_LINES
The stored procedure GET_LINES obtains the character string of a specified number of lines in the buffer as a VARCHAR array. The obtained content is cleared from the buffer and is not output to the client. The prototype of the DBE_OUTPUT.GET_LINES function is as follows:
1 2 3 4
DBE_OUTPUT.GET_LINES ( lines OUT VARCHAR[], numlines IN OUT INTEGER );
Table 7 DBE_OUTPUT.GET_LINES parameters Parameter
Description
lines
Outputs an array of multi-line strings read from the buffer.
numlines
Inputs the number of lines to be retrieved from the buffer. The output value is the number of lines actually retrieved. If the output value is less than the input value, there are no more lines in the buffer.
- DBE_OUTPUT.NEW_LINE
The stored procedure NEW_LINE places a line at the end of the buffer, places an end-of-line marker, and leaves a new line empty. The prototype of the DBE_OUTPUT.NEW_LINE function is as follows:
1
DBE_OUTPUT.NEW_LINE;
- DBE_OUTPUT.PUT
The stored procedure PUT places an input string in the buffer without a newline character at the end. When the stored procedure ends, the line ending with the newline character is displayed. The prototype of the DBE_OUTPUT.PUT function is as follows:
1 2
DBE_OUTPUT.PUT ( item IN VARCHAR2);
Table 8 DBE_OUTPUT.PUT parameters Parameter
Description
item
Character or string item to be placed in the buffer.
- DBE_OUTPUT.PUT_LINE
The stored procedure PUT_LINE places an input string in the buffer with a newline character at the end. When the stored procedure ends, the line ending with the newline character is displayed. The prototype of the DBE_OUTPUT.PUT_LINE function is as follows:
1 2
DBE_OUTPUT.PUT_LINE ( item IN VARCHAR2);
Table 9 DBE_OUTPUT.PUT_LINE parameters Parameter
Description
item
Character or string item to be placed in the buffer.
Examples
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
BEGIN DBE_OUTPUT.SET_BUFFER_SIZE(50); DBE_OUTPUT.PRINT('hello, '); DBE_OUTPUT.PRINT_LINE('database!');-- Output "hello, database!". END; / -- Test DISABLE: Disable the calling of PUT, PUT_LINE, NEW_LINE, GET_LINE, and GET_LINES. The PUT_LINE has no output. BEGIN dbe_output.disable(); dbe_output.put_line('1'); END; / -- Test ENABLE: Enable the calling of PUT, PUT_LINE, NEW_LINE, GET_LINE, and GET_LINES. The output of PUT_LINE is 1. BEGIN dbe_output.enable(); dbe_output.put_line('1'); END; / -- Test PUT: Place the input character string a in the buffer without adding a newline character at the end. a has no output. BEGIN dbe_output.enable(); dbe_output.put('a'); END; / -- Test NEW_LINE. Add a new line. The output is a. BEGIN dbe_output.enable(); dbe_output.put('a'); dbe_output.new_line; END; / -- Test GET_LINE: Obtain buffer data and save the data to variables and use PUT_LINE to output the data. DECLARE line VARCHAR(32672); status INTEGER := 0; BEGIN dbe_output.put_line('hello'); dbe_output.get_line(line, status); dbe_output.put_line('-----------'); dbe_output.put_line(line); dbe_output.put_line(status); END; / The expected result is as follows: ----------- hello 0 -- Test GET_LINE: Obtain multiple lines of content in the buffer and use PUT_LINE to output the content. DECLARE lines dbms_output.chararr; numlines integer; BEGIN dbe_output.put_line('output line 1'); dbe_output.put_line('output line 2'); dbe_output.put_line('output line 3'); numlines := 100; dbe_output.get_lines(lines, numlines); dbe_output.put_line('num: ' || numlines); dbe_output.put_line('get line 1: ' || lines(1)); dbe_output.put_line('get line 2: ' || lines(2)); dbe_output.put_line('get line 3: ' || lines(3)); END; / -- The expected result is as follows: num: 3 get line 1: output line 1 get line 2: output line 2 get line 3: output line 3 |
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot