sijms / go-ora

Pure go oracle client
MIT License
795 stars 176 forks source link

Fails on reading empty array with error 'TTC error: received code 3 during response reading' #555

Closed stle04 closed 4 months ago

stle04 commented 4 months ago

Hi

I have next code and it fails with error if I try to get empty array from SQL Procedure

CREATE OR REPLACE PACKAGE test_pkg AS
    TYPE t_testdata_out_int_array IS TABLE OF test_data.out_int%TYPE INDEX BY BINARY_INTEGER;
    TYPE t_testdata_out_string_array IS TABLE OF test_data.out_string%TYPE INDEX BY BINARY_INTEGER;

    PROCEDURE test_proc_int_and_string_arrays(
        in_string IN VARCHAR2,
        outs_int OUT t_testdata_out_int_array,
        outs_string OUT t_testdata_out_string_array,
        out_string OUT VARCHAR2
    );
END test_pkg;

CREATE OR REPLACE PACKAGE BODY test_pkg AS
    PROCEDURE test_proc_int_and_string_arrays(
        in_string IN VARCHAR2,
        outs_int OUT t_testdata_out_int_array,
        outs_string OUT t_testdata_out_string_array,
        out_string OUT VARCHAR2
    ) AS
        idx NUMBER := 1;
    BEGIN
        FOR idx IN 1..3 LOOP
            outs_int(idx) := idx;
            --outs_string(idx) := idx||'_out';
        END LOOP;
        out_string := in_string||'_out';
    END;
END test_pkg;
func Call(
    ctx context.Context,
    ex *sql.Tx,
    inString string,
    outsInt *[]int,
    outsString *[]string,
    outString *string,
) (err error) {
    _, err = ex.ExecContext(
        ctx,
        `BEGIN test_pkg.test_proc_int_and_string_arrays(in_string => :1,outs_int => :2,outs_string => :3,out_string => :4); END;`,
        inString,
        go_ora.Out{Dest: outsInt, Size: 40},
        go_ora.Out{Dest: outsString, Size: 40},
        go_ora.Out{Dest: outString, Size: 40},
    )
    if err != nil {
        return err
    }
    return nil
}
sijms commented 4 months ago

fixed in next release

sijms commented 4 months ago

fixed in v2.8.18