fbout-body.sql 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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 <[email protected]>
  17. * and all contributors signed below.
  18. *
  19. * All Rights Reserved.
  20. * Contributor(s): ______________________________________.
  21. */
  22. set term !;
  23. recreate package body fb$out
  24. as
  25. begin
  26. procedure enable
  27. as
  28. begin
  29. rdb$set_context('USER_SESSION', 'fb$out.enabled', '1');
  30. end
  31. procedure disable
  32. as
  33. begin
  34. rdb$set_context('USER_SESSION', 'fb$out.enabled', null);
  35. end
  36. procedure put_line (line fb$out_type)
  37. as
  38. begin
  39. if (rdb$get_context('USER_SESSION', 'fb$out.enabled') = '1') then
  40. begin
  41. in autonomous transaction do
  42. begin
  43. insert into fb$out_table (line_num, content)
  44. values (next value for fb$out_seq, :line);
  45. end
  46. end
  47. end
  48. procedure clear
  49. as
  50. begin
  51. in autonomous transaction do
  52. delete from fb$out_table;
  53. end
  54. procedure get_lines returns (lines fb$out_type)
  55. as
  56. declare line fb$out_type;
  57. begin
  58. lines = '';
  59. in autonomous transaction do
  60. begin
  61. for select content from fb$out_table order by line_num into line
  62. do
  63. begin
  64. if (octet_length(lines) > 0) then
  65. lines = lines || ascii_char(13) || ascii_char(10);
  66. lines = lines || :line;
  67. end
  68. end
  69. execute procedure clear;
  70. end
  71. end!
  72. set term ;!