How to select the csv data stored in a BLOB column as if it were an external table?

Hi all

(Happy to be back after a while! )

Currently I am working on a site where users should be able to load the data of csv (comma is the separator) of their client machines (APEX 3.2 application) in the Oracle 11.2.0.4.0 EE database.

My problem is:

I can't use an external table (for the first time in my life ) so I'm a little clueless what to do as the csv data is stored by the application of the APEX in a BLOB column, and I'm looking for an elegant way (at least SQL PL/SQL/maximization) to insert the data into the destination table (run validations by a MERGER would be the most effective way to do the job).

I found a few examples, but I think they are too heavy and there could be a more elegant way in Oracle DB 11.2.

Simple unit test:

drop table CBC purge;

drop table dst serving;

create table src

(myblob blob

);

create table dst

(num number

, varchar2 (6) str

);

Insert in src

Select utl_raw.cast_to_raw (1; AAAAAA ;'|| Chr (10) |

2; BATH; »

)

Double;

Desired (of course) output based on the data in table SRC:

SQL > select * DST;

NUM STR

---------- ------

1 ABDELKRIM

2 BATH

Does anybody know a solution for this?

Any ideas/pointers/links/examples are welcome!

/ * WARNING: I was 'off' for about 3 months, then the Oracle - the part of my brain has become a bit "rusty and I feel it should not be so complicated as the examples I've found sofar ' * /"

Haha, wonder about regexp is like the blind leading the blind!

However, it's my mistake: I forgot to put the starting position setting (so 1, 2, 3,... was in fact the starting position, not the nth occurrence. duh!)

So, it should actually be:

select x.*
,      regexp_substr(x.col1, '[^;]+', 1, 1)
,      regexp_substr(x.col1, '[^;]+', 1, 2)
,      regexp_substr(x.col1, '[^;]+', 1, 3)
,      regexp_substr(x.col1, '[^;]+', 1, 4)
,      regexp_substr(x.col1, '[^;]+', 1, 5)
,      regexp_substr(x.col1, '[^;]+', 1, 6)
from  src
,      xmltable('/a/b'
              passing xmltype(''||replace(conv_to_clob(src.myblob), chr(10), '')||'')
              columns
                col1 varchar2(100) path '.') x;

Note: that's assuming that all the "columns" passed in the string won't be lame.

If one of them might be null, then:

select x.*
,      regexp_substr(ltrim(x.col1, ';'), '[^;]+', 1, 1)
,      regexp_substr(ltrim(x.col1, ';'), '[^;]+', 1, 2)
,      regexp_substr(ltrim(x.col1, ';'), '[^;]+', 1, 3)
,      regexp_substr(ltrim(x.col1, ';'), '[^;]+', 1, 4)
,      regexp_substr(ltrim(x.col1, ';'), '[^;]+', 1, 5)
,      regexp_substr(ltrim(x.col1, ';'), '[^;]+', 1, 6)
from   src
,      xmltable('/a/b'
              passing xmltype(replace(';'||replace(conv_to_clob(src.myblob), chr(10), ';')||'', ';;', '; ;'))
              columns
                col1 varchar2(100) path '.') x;

Tags: Database

Similar Questions

  • How to select the missing data in the table?

    < p >
    < strong > I have a list of strings as follows (in the table):

    "aaaaa".

    "bath".

    "momo".



    I have a x VARCHAR column in table T1. Here is the data under x

    "aaaaa".

    "momo".



    I would like to make a request as it will bring 'bath' as 'bath' is not in the table. Help, please!



    Thank you.

    < facilities >
    < /p >

    Is it possible to have a sql using only is not a second table?

    You might have fun with the unions:

    SQL> select 'aaaaa' x from dual union all
      2  select 'bbbbb' x from dual union all
      3  select 'ccccc' x from dual
      4  minus
      5  select x from t1;
    
    X
    ----------
    bbbbb
    
  • How to get the last date of 3 days for the current month?

    Hello. Guy

    How to get the last date of 3 days for the current month?

    MY OUTPUT WOULD LOOK LIKE THIS

    JANUARY 29, 2016

    JANUARY 30, 2016

    JANUARY 31, 2016


    GUYS HELP ME / / /...

    SQL > select last_day (sysdate) - level + 1 double connect by level<= 3="" order="" by="">

    LAST_DAY)

    ---------

    29 JANUARY 16

    30 JANUARY 16

    31 JANUARY 16

  • BI Layout Editor - how to display the current date?

    Hello

    Recently used BI Layout Editor (previously using MS Word to create the presentation of the State).

    He seems really nice and easy to use.

    However quick Q - How to display the current date in the layout editor (to show the report run date).

    Any quick suggestions is appreciated.

    Thank you

    Vivek

    Tab displays your selection available.

    It's like how when you insert the table in the Word document and when you select the table, you would see 2 additional tabs such as the design and the tool.

    Can you please insert "Text Element" and select the text element and see if you go to the tab 'text '?

  • How to select the path to a file icon button to a table?

    I have a SYSTEM_PATHS table name. All physical access paths as 'where the forms of execution are located' or 'where performance reports are located' are stored in its ranks for example (C:\HRMS\FORMS\)
    I memorized the path of the icon files (.ico) inside. The forms of execution can take the path of the icons for the buttons of this table. And access the icon of the chosen path. I use forms 6i. Normally, I put the path of the icon files in the nerve to property of the button as (C:\HRMS\ICON\). But now, here, I don't have a path but its in the column of a table. How to select the path to a file icon button to a table using forms 6i?

    Hello Gul,

    have you tried

    set_item_property('Button name',ICON_FILENAME,);
    

    Concerning
    Marcus

  • Printer all in one HP3520 - how to select the wireless network and enter the WEP key?

    According to print my wireless network is detected.

    How to connect the! @# % printer $ fo the wireless network and enter the WEP key?

    Instructions on the HP site tell me to selet NETWORK on the printer control panel.  Well, there's a way to select the NETWORK from the control panel.  It is not an option for him.

    I downnloaded and installed the latest drivers.

    I have restored the default settings.

    How to select the wireless network and enter the WEP key?

    All of HP's instructions seem to be for a newer printer with a touchscreen.

    I want that the printer is connected to my main computer via the USB port.  I want to be able to print wireless phones and tablets.

    My 3520 is not a 'touch Screen' and it has wifi.

    However, the following work:

    Try to open the HP Deskjet 3520 icon, open the utilities tab, click on convert USB wireless, by following the steps on the screen.

    This leads me to believe that ONLY the wireless doesn't work.  I know now that the part of the sentence "Convert USB to wireless connection" is supposed to mean "works like USB and wireless.

    Thank you for your help

  • How to check the manufacturing date of the Z3 Compact?

    How to check the manufacturing date of the Z3 Compact?

    @HerrOdin

    Simple, pull on the flap of the IMEI and search for 14W__

    The first 2 digits are for the year and the last 2 digits are the week

    http://support.sonymobile.com/global-en/xperiaz3compact/Userguide/IMEI-number/

  • How to view the anticipated date of 3 days bb

    Greetings

    How to view the early date to 3 days with bb.

    I was able to view the current in bb, but can not able to display the date fututre.

    Help, please

    concerning

    Anthony singh

    Hello

    Add 3 days to the current date.

    days3 long = (3 * 24 * 60 * 60 * 1000);   MS

    TimeFormat SimpleDateFormat = new SimpleDateFormat ("YYYY/MM/DD HH: mm: EEE");
    timeString = «"+ timeFormat.formatLocal (System.currentTimeMillis () + Days3);»

    Thank you

    Stephenson

  • DateFields 5.0 + operating systems. Impossible to select the current date.

    Have a slight situation.    Have a date with the value field by default of - etc.   The user is not able to select the current date, and must choose another date and what to do again to select the current date.

    This works very well in the pre - 5.0 OSes, but does not work with 5.0 +.

    The date field popup works fine, but if the user tries to select the current date, it is not get populated in the date field.

    I see what you mean now.  I connected it the Issue Tracker here: https://www.blackberry.com/jira/browse/JAVAAPI-1163

  • How to set the current date in the datetimepicker in qml?

    Hello

    Can I know how to set the current date in the DateTimePicker in QML?

     DateTimePicker {
                        id: datePicker
                        mode: DateTimePickerMode.Date
                        title: "Date"
                        value: "2013-11-20"
                        maximum: "2013-11-20"
                    }
    
    Container {
        DateTimePicker {
            id: picker5
            title: "DateTimeQml"
            mode: DateTimePickerMode.DateTime
            value: { new Date(); }
        }
    }
    
  • DateField, can not be able to select the current date

    Hai,

    I use DateField in my application. Initially, the date field is showing-/-/---(JJ/MM/AAAA) this format. So if I click on this field to date I can't able to select the current date. If I go on any later date or past date and define it and that I can not choose the current date.

    Hai,
    Thax for your quick response...
    I found this question in "Issue Tracker" here: https://www.blackberry.com/jira/browse/JAVAAPI-1163

  • How to select the pieces of my image in black and white?

    How to select the pieces of my image in black and white? FOW example letter J or the circle or the two together?

    jaguar_growler_blur best8.png

    It's actually pretty easy, but I have to assume that you know a few basics in Photoshop

    (1) open your existing image

    (2) double click on the layer and the 'layer style' appears. In the mix if area set the sliders so the whites in the image disappears

    You will be left with just the black elements in design

    (3) duplicate layers

    and merge them together

    to give a standard layer

    (4) ctrl or cmd click on the layer to select and create a layer mask

    (5) you now have a mask of the image. Duplicate the layer, click alt or option, click on the layer mask to call

    (6) the blacks and the whites are not completely black and white for the use of levels to adapt to the absolutes

    (7) now you have to decide what you want to select. In this case, I chose the lettering and simply covered everything else to the top with black. You do this by lasso selection and fill and items when it's delicate brush just the details with a black brush "hard." .

    (8) at this stage, you can do what you want you have a layer mask. So you can color the text for example

    or place in a background color and apply a layer as Beveling effect

    Hope that makes some sense. It is much easier to do than to describe.

  • Y at - it a paper on how to use the map data the lookup value?

    I'm looking for a documentation where I could find information about the game of card data and how to use the map data configured according to look.

    Any help is very appreciated.

    I found a few threads on data cards:

    http://topliners.Eloqua.com/docs/doc-2434

    http://topliners.Eloqua.com/docs/doc-2817

    http://topliners.Eloqua.com/message/14058#14058

    Maybe that can help you get started

  • How to select the Type of industry 8.3 Professional P6

    Hi all

    According to the document to change the type of industry for 8.3 Professional P6, I had to go to P6, Application settings, general link.

    But in the P6 Web client to administrator > Application Configuration > General there is no option is available for the type of industry.

    Let me know, how to select the type of industry?

    You can see the OPINION score "How to change the Type of industry P6 P6 PPM (Professional), P6 EPPM E8.2 and later versions (Doc ID 1386047.1)".

    Also can you paste a screenshot here.

  • How to select the same forms of color in the adobe flash program?

    How to select the same forms of color in the adobe flash program? for example, we assume that 10 forms of rectangle. 3 of them are red and others are green. I want to use only one method or click to select 3 of them. Please help me

    Thanks kunter

    You can use Ctrl + F.

Maybe you are looking for