Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions contrib/ivorysql_ora/ivorysql_ora_merge_sqls
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
src/datatype/datatype
src/builtin_functions/builtin_functions
src/builtin_functions/dbms_output
src/sysview/sysview
src/xml_functions/xml_functions
53 changes: 53 additions & 0 deletions contrib/ivorysql_ora/src/builtin_functions/dbms_output--1.0.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/***************************************************************
*
* DBMS_OUTPUT package - Basic implementation
*
* This is a simplified implementation that wraps RAISE INFO.
* It does not implement full Oracle DBMS_OUTPUT functionality
* (no buffering, no GET_LINE/GET_LINES, always enabled).
*
***************************************************************/

-- Create DBMS_OUTPUT package specification
CREATE OR REPLACE PACKAGE dbms_output IS
PROCEDURE put_line(a VARCHAR2);
PROCEDURE put(a VARCHAR2);
PROCEDURE new_line;
PROCEDURE enable(buffer_size INTEGER DEFAULT NULL);
PROCEDURE disable;
END dbms_output;

-- Create DBMS_OUTPUT package body
CREATE OR REPLACE PACKAGE BODY dbms_output IS

-- Simple implementation: just use RAISE INFO
PROCEDURE put_line(a VARCHAR2) IS
BEGIN
RAISE INFO '%', a;
END put_line;

PROCEDURE put(a VARCHAR2) IS
BEGIN
-- Note: This doesn't actually buffer, just outputs immediately
RAISE INFO '%', a;
END put;

PROCEDURE new_line IS
BEGIN
RAISE INFO ' ';
END new_line;

-- These are no-ops in this simple implementation
PROCEDURE enable(buffer_size INTEGER DEFAULT NULL) IS
BEGIN
-- Output is always enabled
NULL;
END enable;

PROCEDURE disable IS
BEGIN
-- Cannot actually disable output in this implementation
NULL;
END disable;

END dbms_output;
34 changes: 34 additions & 0 deletions src/oracle_test/regress/expected/ora_package.out
Original file line number Diff line number Diff line change
Expand Up @@ -6278,6 +6278,40 @@ call test_pkg.test_p1(NULL, 23);
(1 row)

DROP package test_pkg;
--test hello_pkg: basic package with initialization block
-- Package Specification
CREATE OR REPLACE PACKAGE hello_pkg IS
PROCEDURE say_hello;
END hello_pkg;
/
-- Package Body (implementation)
CREATE OR REPLACE PACKAGE BODY hello_pkg IS
PROCEDURE say_hello IS
BEGIN
DBMS_OUTPUT.PUT_LINE('Hello, World!');
END say_hello;
BEGIN
-- Optional initialization block
-- This runs once, the first time the package is referenced in a session
DBMS_OUTPUT.PUT_LINE('hello_pkg loaded');
END hello_pkg;
/
-- Test calling the procedure
DECLARE
BEGIN
hello_pkg.say_hello();
END;
/
INFO: hello_pkg loaded
INFO: Hello, World!
-- Call it again to verify init block only runs once
DECLARE
BEGIN
hello_pkg.say_hello();
END;
/
INFO: Hello, World!
DROP PACKAGE hello_pkg;
--clean data
RESET ivorysql.allow_out_parameter_const;
DROP FUNCTION test_event_trigger;
Expand Down
38 changes: 38 additions & 0 deletions src/oracle_test/regress/sql/ora_package.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6094,6 +6094,44 @@ call test_pkg.test_p1(NULL, 23);

DROP package test_pkg;

--test hello_pkg: basic package with initialization block
-- Package Specification
CREATE OR REPLACE PACKAGE hello_pkg IS
PROCEDURE say_hello;
END hello_pkg;
/

-- Package Body (implementation)
CREATE OR REPLACE PACKAGE BODY hello_pkg IS

PROCEDURE say_hello IS
BEGIN
DBMS_OUTPUT.PUT_LINE('Hello, World!');
END say_hello;

BEGIN
-- Optional initialization block
-- This runs once, the first time the package is referenced in a session
DBMS_OUTPUT.PUT_LINE('hello_pkg loaded');
END hello_pkg;
/

-- Test calling the procedure
DECLARE
BEGIN
hello_pkg.say_hello();
END;
/

-- Call it again to verify init block only runs once
DECLARE
BEGIN
hello_pkg.say_hello();
END;
/

DROP PACKAGE hello_pkg;

--clean data
RESET ivorysql.allow_out_parameter_const;
DROP FUNCTION test_event_trigger;
Expand Down
3 changes: 2 additions & 1 deletion src/pl/plisql/src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ ORACLE_REGRESS_OPTS = --dbname=$(PL_TESTDB)
REGRESS = plisql_array plisql_call plisql_control plisql_copy plisql_domain \
plisql_record plisql_cache plisql_simple plisql_transaction \
plisql_trap plisql_trigger plisql_varprops plisql_nested_subproc \
plisql_nested_subproc2 plisql_out_parameter plisql_type_rowtype
plisql_nested_subproc2 plisql_out_parameter plisql_type_rowtype \
plisql_dbms_output

# where to find ora_gen_keywordlist.pl and subsidiary files
TOOLSDIR = $(top_srcdir)/src/tools
Expand Down
188 changes: 188 additions & 0 deletions src/pl/plisql/src/expected/plisql_dbms_output.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
--
-- Tests for DBMS_OUTPUT package
--
-- Test 1: PUT_LINE basic functionality
BEGIN
DBMS_OUTPUT.PUT_LINE('Test message 1');
END;
/
INFO: Test message 1
-- Test 2: PUT_LINE with variable
DECLARE
v_number NUMBER := 42;
v_text VARCHAR2(100) := 'Hello World';
BEGIN
DBMS_OUTPUT.PUT_LINE('Number: ' || v_number);
DBMS_OUTPUT.PUT_LINE('Text: ' || v_text);
END;
/
INFO: Number: 42
INFO: Text: Hello World
-- Test 3: Multiple PUT_LINE calls
BEGIN
DBMS_OUTPUT.PUT_LINE('Line 1');
DBMS_OUTPUT.PUT_LINE('Line 2');
DBMS_OUTPUT.PUT_LINE('Line 3');
END;
/
INFO: Line 1
INFO: Line 2
INFO: Line 3
-- Test 4a: PUT procedure
BEGIN
DBMS_OUTPUT.PUT('Part 1');
END;
/
INFO: Part 1
-- Test 4b: Multiple PUT calls
BEGIN
DBMS_OUTPUT.PUT('Part 1');
DBMS_OUTPUT.PUT(' Part 2');
END;
/
INFO: Part 1
INFO: Part 2
-- Test 4c: NEW_LINE procedure
BEGIN
DBMS_OUTPUT.NEW_LINE;
END;
/
ERROR: syntax error at end of input
LINE 3: END
^
QUERY: BEGIN
DBMS_OUTPUT.NEW_LINE;
END
-- Test 5a: ENABLE procedure
BEGIN
DBMS_OUTPUT.ENABLE(20000);
END;
/
-- Test 5b: ENABLE with PUT_LINE
BEGIN
DBMS_OUTPUT.ENABLE(20000);
DBMS_OUTPUT.PUT_LINE('After enable');
END;
/
INFO: After enable
-- Test 5c: DISABLE procedure
BEGIN
DBMS_OUTPUT.DISABLE;
END;
/
ERROR: syntax error at end of input
LINE 3: END
^
QUERY: BEGIN
DBMS_OUTPUT.DISABLE;
END
-- Test 5d: DISABLE with PUT_LINE
BEGIN
DBMS_OUTPUT.DISABLE;
DBMS_OUTPUT.PUT_LINE('After disable');
END;
/
ERROR: syntax error at end of input
LINE 3: DBMS_OUTPUT.PUT_LINE('After disable');
^
QUERY: BEGIN
DBMS_OUTPUT.DISABLE;
DBMS_OUTPUT.PUT_LINE('After disable');
END
-- Test 6: DBMS_OUTPUT in function
CREATE OR REPLACE FUNCTION test_dbms_output_func(p_msg VARCHAR2) RETURN NUMBER IS
BEGIN
DBMS_OUTPUT.PUT_LINE('Function says: ' || p_msg);
RETURN 1;
END;
/
DECLARE
v_result NUMBER;
BEGIN
v_result := test_dbms_output_func('Hello from function');
DBMS_OUTPUT.PUT_LINE('Result: ' || v_result);
END;
/
INFO: Function says: Hello from function
INFO: Result: 1
DROP FUNCTION test_dbms_output_func;
-- Test 7: DBMS_OUTPUT in procedure
CREATE OR REPLACE PROCEDURE test_dbms_output_proc(p_msg VARCHAR2) IS
BEGIN
DBMS_OUTPUT.PUT_LINE('Procedure says: ' || p_msg);
END;
/
BEGIN
test_dbms_output_proc('Hello from procedure');
END;
/
INFO: Procedure says: Hello from procedure
DROP PROCEDURE test_dbms_output_proc;
-- Test 8: DBMS_OUTPUT in package
CREATE OR REPLACE PACKAGE test_output_pkg IS
PROCEDURE show_message(p_msg VARCHAR2);
END test_output_pkg;
/
CREATE OR REPLACE PACKAGE BODY test_output_pkg IS
PROCEDURE show_message(p_msg VARCHAR2) IS
BEGIN
DBMS_OUTPUT.PUT_LINE('Package says: ' || p_msg);
END show_message;
BEGIN
-- Package initialization block
DBMS_OUTPUT.PUT_LINE('Package initialized');
END test_output_pkg;
/
BEGIN
test_output_pkg.show_message('Hello from package');
END;
/
INFO: Package initialized
INFO: Package says: Hello from package
DROP PACKAGE test_output_pkg;
-- Test 9: NULL handling
BEGIN
DBMS_OUTPUT.PUT_LINE(NULL);
DBMS_OUTPUT.PUT_LINE('After NULL');
END;
/
INFO: <NULL>
INFO: After NULL
-- Test 10: Empty string
BEGIN
DBMS_OUTPUT.PUT_LINE('');
DBMS_OUTPUT.PUT_LINE('After empty string');
END;
/
INFO: <NULL>
INFO: After empty string
-- Test 11: Long string
DECLARE
v_long VARCHAR2(1000) := RPAD('A', 500, 'B');
BEGIN
DBMS_OUTPUT.PUT_LINE(v_long);
END;
/
INFO: ABBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
--
-- Oracle DBMS_OUTPUT Package Methods (per Oracle 12c documentation):
-- 1. ENABLE(buffer_size) - Enable output with buffer size
-- 2. DISABLE - Disable output and purge buffer
-- 3. PUT(text) - Place partial line in buffer
-- 4. PUT_LINE(text) - Place complete line in buffer
-- 5. NEW_LINE - Put end-of-line marker in buffer
-- 6. GET_LINE(line, status) - Retrieve single line from buffer
-- 7. GET_LINES(lines, numlines) - Retrieve multiple lines from buffer
--
-- IvorySQL Current Implementation Status:
-- ✓ PUT_LINE(text) - Works (outputs via RAISE INFO)
-- ✓ PUT(text) - Works (outputs via RAISE INFO)
-- ✗ NEW_LINE - Syntax error (no-arg procedure call)
-- ✓ ENABLE(buffer_size) - Works (no-op)
-- ✗ DISABLE - Syntax error (no-arg procedure call)
-- ✗ GET_LINE(line, status) - Not implemented
-- ✗ GET_LINES(lines, numlines) - Not implemented
--
-- Note:
-- - Output is immediate (no buffering)
-- - NEW_LINE and DISABLE fail due to PL/iSQL parser limitation with no-arg procedures
8 changes: 2 additions & 6 deletions src/pl/plisql/src/expected/plisql_nested_subproc2.out
Original file line number Diff line number Diff line change
Expand Up @@ -3987,7 +3987,7 @@ begin
end;
/
INFO: var1 = 2
--raise error no dbms_output
--test dbms_output
declare
var1 integer;
begin
Expand All @@ -3996,11 +3996,7 @@ begin
end;
/
INFO: var1 = 2
ERROR: schema "dbms_output" does not exist
LINE 1: CALL dbms_output.put_line('xiexie')
^
QUERY: CALL dbms_output.put_line('xiexie')
CONTEXT: PL/iSQL function inline_code_block line 5 at CALL
INFO: xiexie
create or replace function test.test_f(id integer) return integer is
var1 integer;
function test_f(id integer) return integer;
Expand Down
Loading