Skip to Main Content

Oracle Database Discussions

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Function to convert varray to delimited string

User_1871Jul 10 2022

I have VARRAYS in SDO_GEOMETRY objects:

create table test_table (shape sdo_geometry);

insert into test_table (shape) values (sdo_geometry('linestring(10 20, 30 40, 50 60)'));
insert into test_table (shape) values (sdo_geometry('linestring(70 80, 90 100)'));
insert into test_table (shape) values (sdo_geometry('linestring(110 120, 130 140, 150 160, 170 180)'));

select
    (shape).sdo_ordinates as sdo_ordinate_array
from
    test_table


SDO_ORDINATE_ARRAY
------------------
MDSYS.SDO_ORDINATE_ARRAY(10, 20, 30, 40, 50, 60)
MDSYS.SDO_ORDINATE_ARRAY(70, 80, 90, 100)
MDSYS.SDO_ORDINATE_ARRAY(110, 120, 130, 140, 150, 160, 170, 180)

I want to extract the ordinates from the VARRAYS as comma delimited strings:

ORDINATES
------------------------------
10,20,30,40,50,60
70,80,90,100
110,120,130,140,150,160,170,180

It would be helpful if there were a function that could convert the VARRAYS to strings.
There are ways to do it in a query. But I would prefer to do it with a function since that would be a lot more succinct.
Something like this:
VARRAY_TO_VARCHAR2( varray )

Comments

Vishal Gupta

Anyone seen this error?

Hi VishalGupta,

1/Which version of SQLDeveloper are you using the recent 4.0 EA or the Production 3.2.2?

2/I have not seen the error you mention (unless there is a typing error in the command).

3/There was a problem with 3.2.2 - need to set the PATH otherwise SQLDeveloper may get confused with another version of SQLDeveloper stored in /opt and referenced elsewhere in the PATH ('which sqldeveloper' to see where it is)

4/I had to use a full path for the file name i.e. /tmp/vg.html on my test case (which did not reproduce your issue) (*)

5/'force_print' in html script output is a bug

(*)export PATH=`pwd`:$PATH ; bash ./sdcli reports generate -report z -db DB_NAME -file /tmp/zzq4.html

Oracle SQL Developer

Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.

Java asserts are enabled!

Success!

-Turloch

SQLDeveloper Team

Vishal Gupta

Turloch,

Thanks for the reply.  I was using SQL Developer 4.0 EA1. I noticed that my problem was because of the space in the report name. See following link.

SQLDev4 - sdcli - space in report name (Linux/Mac)

Regards,

Vishal Gupta

http://blog.vishalgupta.com

Barry Mcgillin-Oracle
Answer

Vishal,

Youre right. I just fixed this under bug 17221719

B

Marked as Answer by Vishal Gupta · Sep 27 2020
1 - 4

Post Details

Added on Jul 10 2022
1 comment
538 views