ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/public/ibx/trunk/examples/ibstoredproc/fbout-body.sql
Revision: 158
Committed: Thu Mar 1 11:23:33 2018 UTC (6 years, 1 month ago) by tony
Content type: application/sql
File size: 1885 byte(s)
Log Message:
Repository resync

File Contents

# Content
1 /*
2 * The contents of this file are subject to the Initial
3 * Developer's Public License Version 1.0 (the "License");
4 * you may not use this file except in compliance with the
5 * License. You may obtain a copy of the License at
6 * http://www.ibphoenix.com/main.nfs?a=ibphoenix&page=ibp_idpl.
7 *
8 * Software distributed under the License is distributed AS IS,
9 * WITHOUT WARRANTY OF ANY KIND, either express or implied.
10 * See the License for the specific language governing rights
11 * and limitations under the License.
12 *
13 * The Original Code was created by Adriano dos Santos Fernandes
14 * for the Firebird Open Source RDBMS project.
15 *
16 * Copyright (c) 2009 Adriano dos Santos Fernandes <adrianosf@gmail.com>
17 * and all contributors signed below.
18 *
19 * All Rights Reserved.
20 * Contributor(s): ______________________________________.
21 */
22
23 set term !;
24
25
26 recreate package body fb$out
27 as
28 begin
29 procedure enable
30 as
31 begin
32 rdb$set_context('USER_SESSION', 'fb$out.enabled', '1');
33 end
34
35 procedure disable
36 as
37 begin
38 rdb$set_context('USER_SESSION', 'fb$out.enabled', null);
39 end
40
41 procedure put_line (line fb$out_type)
42 as
43 begin
44 if (rdb$get_context('USER_SESSION', 'fb$out.enabled') = '1') then
45 begin
46 in autonomous transaction do
47 begin
48 insert into fb$out_table (line_num, content)
49 values (next value for fb$out_seq, :line);
50 end
51 end
52 end
53
54 procedure clear
55 as
56 begin
57 in autonomous transaction do
58 delete from fb$out_table;
59 end
60
61 procedure get_lines returns (lines fb$out_type)
62 as
63 declare line fb$out_type;
64 begin
65 lines = '';
66
67 in autonomous transaction do
68 begin
69 for select content from fb$out_table order by line_num into line
70 do
71 begin
72 if (octet_length(lines) > 0) then
73 lines = lines || ascii_char(13) || ascii_char(10);
74
75 lines = lines || :line;
76 end
77 end
78
79 execute procedure clear;
80 end
81 end!
82
83
84 set term ;!