.net - Oracle dotnet DBMS output query -


i running code in .net, using oracleclient in ,net. sql code can output number of responses using dbms_put_line function, retrieve call dbms_get_line. if output specific line of text, ie 'dbms_output.put_line('user not available : please contact system administrator');' call get_line works fine, , text. however, if call output sql error message, 'dbms_output.put_line(sqlerrm);' following error returned, 'ora-06502: pl/sql: numeric or value error: hex raw conversion error'

the wierd thing, if run same code 2nd time (including close , reconnect db) call get_line returns actual error message being output.

my code following:

opens db connection runs sql query executenonquery creates output parameters like:

dim anonymous_block = "begin dbms_output.get_line(:1, :2); end;"  acmd.commandtext = anonymous_block acmd.parameters.add("1", oracletype.varchar, 32000) acmd.parameters("1").direction = parameterdirection.output acmd.parameters.add("2", oracletype.int32) acmd.parameters("2").direction = parameterdirection.output 

then runs executenonquery output.

then closes db .close()

but on 2nd run, gets correct output. there perhaps not setting correctly 1st time?

any thoughts? can run code twice, seems horribly inefficient.

first off, designing application meaningful interactions between client , server using dbms_output terrible approach. if stored procedure needs send information caller, should accomplished via out parameters or exceptions. having stored procedure catch exception, attempt write dbms_output buffer, , having application attempt read dbms_output buffer determine if there exception not scalable approach writing application.

that said, if going fetch data dbms_output buffer, you'll need in loop. in specific case, error stack contains multiple lines of data (there may 1 call dbms_output.put_line text contains internal newline characters. you'll need loop until status (the second parameter) returns 1.


Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -