SQL Developer script output truncates sys_refcursor width

后端 未结 1 1336
孤城傲影
孤城傲影 2020-12-21 19:47

I have a function defined that returns a sys_refcursor containing 5 text columns. Sorry, I cannot post the contents of it here for business reasons. The columns are casted t

相关标签:
1条回答
  • 2020-12-21 20:18

    Not directly answering the question - I don't know why the behaviour is different or how to change it when calling the function from a query, other than with a column command to set the width, using an alias here to simplify things slightly:

    set lines 250
    column rc format a250
    select my_function(input1,input2,input3) as rc from dual;
    

    But you can also get the output you want by calling the function differently; with a variable and an anonymous block (or execute as shorthand):

    variable rc refcursor;
    exec :rc := MY_FUNCTION(input1,input2,input3);
    print rc
    

    Well, almost as you want it; the first line of the output is the variable name rather than the function/parameter list; but the cursor columns are not wrapped:

    anonymous block completed
    RC
    ---------------------------------------------------------------------------
    COLUMN1                   COLUMN2 COLUMN3    COLUMN4    COLUMN5    
    ------------------------- ------- ---------- ---------- ---------- 
    18-NOV-14                 text    some_data1 some_data2 some_data3 
    

    You can also run your function from the code editor (rather than the worksheet), which generates an anonymous block for you; when you click the run arrow (or hit control-F10) you get a dialog like this:

    enter image description here

    And after running it you get an 'output variables' tab at the bottom of the main window which shows the cursor output in a grid.

    You can also see the grid view when you run select my_function(...) from dual. The cursor goes into the normal 'query result' window but not in a very friendly form, appearing as something like:

    {<COLUMN1=19-NOV-14,COLUMN2=text,COLUMN3=some_data1,COLUMN4=some_data2,COLUMN5=some_data3>,}
    

    But if you double-click a value then you see a yellow pencil symbol at the far right of the column, and clicking that shows that cursor in its own grid.

    Personally I prefer the print option in the script output but I rarely use the gird displays anyway.

    0 讨论(0)
提交回复
热议问题