Protocol Compatibility Migration Guide
Protocol Compatibility Migration Guide
Overview
This guide helps migrate applications from Oracle 23ai or SQL Server 2022 to HeliosDB while maintaining 95%+ compatibility.
Oracle to HeliosDB Migration
Connection String Changes
Before (Oracle)
jdbc:oracle:thin:@hostname:1521:ORCLAfter (HeliosDB with Oracle protocol)
jdbc:oracle:thin:@hostname:1521:heliosdbNo application code changes required - HeliosDB speaks Oracle TNS protocol.
Automatic SQL Translation
HeliosDB automatically translates Oracle-specific SQL to standard SQL:
DUAL Table
-- Oracle syntax (automatically handled)SELECT SYSDATE FROM DUAL;
-- HeliosDB internal translationSELECT CURRENT_TIMESTAMP;NVL to COALESCE
-- Oracle syntax (automatically handled)SELECT NVL(salary, 0) FROM employees;
-- HeliosDB internal translationSELECT COALESCE(salary, 0) FROM employees;DECODE to CASE
-- Oracle syntaxSELECT DECODE(status, 'A', 'Active', 'I', 'Inactive', 'Unknown')FROM employees;
-- Automatically translated to standard CASEPL/SQL Migration
Cursor Handling
Oracle PL/SQL (fully supported)
DECLARE CURSOR emp_cursor IS SELECT * FROM employees WHERE dept_id = 10; emp_rec employees%ROWTYPE;BEGIN OPEN emp_cursor; LOOP FETCH emp_cursor INTO emp_rec; EXIT WHEN emp_cursor%NOTFOUND; -- Process record END LOOP; CLOSE emp_cursor;END;✓ HeliosDB Support: 96% compatible
- All cursor attributes supported (%FOUND, %NOTFOUND, %ROWCOUNT, %ISOPEN)
- BULK COLLECT supported
- REF CURSOR (weak and strong) supported
Exception Handling
Oracle PL/SQL (fully supported)
BEGIN SELECT salary INTO v_salary FROM employees WHERE emp_id = 999;EXCEPTION WHEN NO_DATA_FOUND THEN v_salary := 0; WHEN TOO_MANY_ROWS THEN RAISE_APPLICATION_ERROR(-20001, 'Multiple records found'); WHEN OTHERS THEN DBMS_OUTPUT.PUT_LINE('Error: ' || SQLERRM);END;✓ HeliosDB Support: 95% compatible
- All standard exceptions supported
- Custom exception support
- Exception propagation across blocks
Hierarchical Queries
Oracle CONNECT BY (fully supported)
SELECT employee_id, manager_id, LEVEL, SYS_CONNECT_BY_PATH(name, '/') AS pathFROM employeesSTART WITH manager_id IS NULLCONNECT BY NOCYCLE PRIOR employee_id = manager_idORDER SIBLINGS BY name;✓ HeliosDB Support: 93% compatible
- CONNECT BY PRIOR fully supported
- START WITH clause supported
- NOCYCLE keyword for cycle detection
- LEVEL pseudo-column
- SYS_CONNECT_BY_PATH function
- CONNECT_BY_ROOT operator
- CONNECT_BY_ISLEAF pseudo-column
- ORDER SIBLINGS BY clause
Advanced Functions
String Functions
-- All fully supportedSELECT INSTR('hello world', 'world'), -- Position 7 SUBSTR('hello', -3, 3), -- 'llo' (negative position) LPAD('Page 1', 10, '*.'), -- '*.*.*Page 1' TRANSLATE('2KRW229', '0123456789', '----'), -- ResultFROM DUAL;Analytic Functions
-- Fully supportedSELECT employee_id, salary, RANK() OVER (ORDER BY salary DESC) AS rank, DENSE_RANK() OVER (ORDER BY salary DESC) AS dense_rank, LAG(salary, 1, 0) OVER (ORDER BY hire_date) AS prev_salary, LEAD(salary, 1, 0) OVER (ORDER BY hire_date) AS next_salaryFROM employees;XMLType and JSON
XMLType
-- Create XMLDECLARE xml_doc XMLType;BEGIN xml_doc := XMLType('<employees><employee id="1">John</employee></employees>');
-- Extract value SELECT xml_doc.extract('/employees/employee/text()') FROM DUAL;
-- Check existence IF xml_doc.existsNode('/employees/employee[@id="1"]') = 1 THEN -- Node exists END IF;END;✓ HeliosDB Support: 90% compatible
- XMLType creation and storage
- extract() with XPath
- existsNode() for validation
- Basic XSLT transformation
JSON Functions (Oracle 21c+)
-- JSON_VALUESELECT JSON_VALUE('{"name":"John","age":30}', '$.name') AS name;
-- JSON_QUERYSELECT JSON_QUERY('{"items":[1,2,3]}', '$.items') AS items;
-- JSON_TABLESELECT jt.*FROM JSON_TABLE( '[{"id":1,"name":"John"},{"id":2,"name":"Jane"}]', '$[*]' COLUMNS( id NUMBER PATH '$.id', name VARCHAR2(50) PATH '$.name' )) jt;✓ HeliosDB Support: 94% compatible
Migration Checklist
- Test connection string changes
- Identify PL/SQL packages usage (check compatibility)
- Review hierarchical queries with cycles
- Test exception handling edge cases
- Validate XMLType usage
- Check JSON path expressions
- Test cursor-intensive code
- Verify ROWNUM behavior in complex queries
SQL Server to HeliosDB Migration
Connection String Changes
Before (SQL Server)
Server=hostname;Database=mydb;User Id=sa;Password=***;After (HeliosDB with TDS protocol)
Server=hostname;Database=mydb;User Id=user;Password=***;No application code changes required - HeliosDB speaks TDS protocol.
Automatic T-SQL Translation
TOP to LIMIT
-- SQL Server syntax (automatically handled)SELECT TOP 10 * FROM employees ORDER BY salary DESC;
-- HeliosDB internal translationSELECT * FROM employees ORDER BY salary DESC LIMIT 10;Identity Functions
-- All fully supportedINSERT INTO orders (customer) VALUES ('John');
SELECT @@IDENTITY; -- Last identity inserted (any table, includes triggers)SELECT SCOPE_IDENTITY(); -- Last identity in current scope (excludes triggers)SELECT IDENT_CURRENT('orders'); -- Last identity for specific table
SELECT @@ROWCOUNT; -- Rows affected by last statement✓ HeliosDB Support: 97% compatible
- Correct scope handling for identity functions
- Transaction awareness
- Trigger distinction
T-SQL Features
TRY…CATCH
SQL Server T-SQL (fully supported)
BEGIN TRY -- Risky operation INSERT INTO orders (customer) VALUES ('John'); UPDATE inventory SET qty = qty - 1 WHERE product_id = 123;END TRYBEGIN CATCH -- Error handling SELECT ERROR_NUMBER() AS ErrorNumber, ERROR_MESSAGE() AS ErrorMessage, ERROR_SEVERITY() AS ErrorSeverity, ERROR_STATE() AS ErrorState, ERROR_PROCEDURE() AS ErrorProcedure, ERROR_LINE() AS ErrorLine;
ROLLBACK TRANSACTION;END CATCH;✓ HeliosDB Support: 95% compatible
- Full ERROR_* function support
- Nested TRY…CATCH blocks
- Severity level handling (errors >= 20 terminate connection)
- THROW for re-raising exceptions
Temp Tables and Table Variables
-- Local temp tableCREATE TABLE #temp_orders ( order_id INT, customer VARCHAR(100));
-- Global temp tableCREATE TABLE ##global_temp ( id INT);
-- Table variableDECLARE @results TABLE ( id INT, name VARCHAR(100));
INSERT INTO @results VALUES (1, 'John');SELECT * FROM @results;✓ HeliosDB Support: 94% compatible
- Local temp tables (#temp) - session scope
- Global temp tables (##temp) - cross-session scope
- Table variables (@table) - batch scope
- Proper scope enforcement
OUTPUT Clause
-- INSERT with OUTPUTINSERT INTO products (name, price)OUTPUT INSERTED.product_id, INSERTED.nameVALUES ('Widget', 9.99);
-- UPDATE with OUTPUTUPDATE inventorySET qty = qty - 1OUTPUT DELETED.qty AS old_qty, INSERTED.qty AS new_qtyWHERE product_id = 123;
-- DELETE with OUTPUT INTODECLARE @deleted TABLE (product_id INT, name VARCHAR(100));
DELETE FROM productsOUTPUT DELETED.product_id, DELETED.name INTO @deletedWHERE discontinued = 1;✓ HeliosDB Support: 93% compatible
- INSERTED and DELETED pseudo-tables
- OUTPUT INTO table/variable
- Works with triggers (proper isolation)
MERGE Statement
MERGE target tUSING source sON t.id = s.idWHEN MATCHED THEN UPDATE SET t.value = s.valueWHEN NOT MATCHED BY TARGET THEN INSERT (id, value) VALUES (s.id, s.value)WHEN NOT MATCHED BY SOURCE THEN DELETEOUTPUT $action, INSERTED.*, DELETED.*;✓ HeliosDB Support: 92% compatible
- Multiple WHEN clauses
- WHEN NOT MATCHED BY SOURCE
- OUTPUT with $action
- Proper transaction handling
Common Table Expressions (CTEs)
Non-Recursive CTEs
WITH sales_summary AS ( SELECT customer_id, SUM(amount) AS total FROM orders GROUP BY customer_id)SELECT c.name, s.totalFROM customers cJOIN sales_summary s ON c.id = s.customer_id;✓ HeliosDB Support: 96% compatible
Recursive CTEs
WITH RECURSIVE numbers AS ( SELECT 1 AS n UNION ALL SELECT n + 1 FROM numbers WHERE n < 100)SELECT * FROM numbersOPTION (MAXRECURSION 100);✓ HeliosDB Support: 96% compatible
- MAXRECURSION limit (default 100, max 32767)
- Infinite recursion detection
- Proper validation (anchor vs recursive member)
JSON Support (SQL Server 2016+)
JSON Functions
DECLARE @json NVARCHAR(MAX) = N'{"name":"John","age":30,"active":true}';
-- JSON_VALUE (scalar extraction)SELECT JSON_VALUE(@json, '$.name') AS name;SELECT JSON_VALUE(@json, 'lax $.missing') AS missing; -- Returns NULL (lax mode)SELECT JSON_VALUE(@json, 'strict $.missing') AS error; -- Raises error (strict mode)
-- JSON_QUERY (object/array extraction)SELECT JSON_QUERY(@json, '$') AS full_object;
-- JSON_MODIFYSET @json = JSON_MODIFY(@json, '$.age', 31);SET @json = JSON_MODIFY(@json, 'append $.hobbies', 'reading');
-- ISJSON validationIF ISJSON(@json) = 1 PRINT 'Valid JSON';
-- OPENJSONSELECT *FROM OPENJSON(@json)WITH ( name NVARCHAR(50) '$.name', age INT '$.age', active BIT '$.active');
-- FOR JSONSELECT customer_id, name, emailFROM customersFOR JSON PATH, ROOT('customers'), INCLUDE_NULL_VALUES;✓ HeliosDB Support: 95% compatible
- lax and strict path modes
- All JSON functions
- FOR JSON AUTO and PATH
- Complex path expressions
Migration Checklist
- Test connection string changes
- Review @@IDENTITY vs SCOPE_IDENTITY usage
- Check temp table scope requirements
- Validate TRY…CATCH error handling
- Test OUTPUT clause behavior
- Verify MERGE statement logic
- Check recursive CTE depth limits
- Test JSON path modes (lax/strict)
- Review table variable performance
- Validate transaction handling
Performance Optimization Tips
Oracle Protocol
- Minimize ROWNUM usage: Convert to LIMIT when possible
- Hierarchical queries: Add NOCYCLE to prevent infinite loops
- REF CURSOR: Use strong-typed when possible for better optimization
- Bulk operations: Use BULK COLLECT for better performance
SQL Server Protocol
- Identity functions: Prefer SCOPE_IDENTITY() over @@IDENTITY
- CTEs: Set appropriate MAXRECURSION to prevent runaway queries
- Table variables: Use temp tables for large datasets (better statistics)
- JSON: Use strict mode only when necessary (lax mode is faster)
Troubleshooting
Common Issues
Oracle
- Cursor already open: Check for proper OPEN/CLOSE pairing
- ORA-01436 (CONNECT BY loop): Add NOCYCLE keyword
- XMLType parsing errors: Validate XML well-formedness
- PL/SQL package not found: Check DBMS_* package support
SQL Server
- Severity 20+ errors: These terminate connection, cannot be caught
- MAXRECURSION exceeded: Increase limit or optimize recursive query
- Table variable out of scope: Ensure usage within same batch
- JSON path errors: Check lax vs strict mode settings
Getting Help
- Documentation:
/docs/protocol/MULTI_PROTOCOL_COMPATIBILITY_MATRIX.md - Test examples:
/heliosdb-protocols/tests/ - Issue tracker: GitHub Issues
Version Compatibility
| Database | Tested Versions | Compatibility |
|---|---|---|
| Oracle | 19c, 21c, 23ai | 95%+ |
| SQL Server | 2016, 2019, 2022 | 95%+ |
Last updated: 2025-01-02 (Agent 26 - Phase 5 Hardening)