Unix Technical Forum

Bulk Data Type Testing Question

This is a discussion on Bulk Data Type Testing Question within the Oracle Database forums, part of the Database Server Software category; --> What is the best way to determine if col1 contains a convertible number? Bulk collect? Is there a simple ...


Go Back   Unix Technical Forum > Database Server Software > Oracle Database

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-26-2008, 05:45 AM
EscVector
 
Posts: n/a
Default Bulk Data Type Testing Question

What is the best way to determine if col1 contains a convertible
number?
Bulk collect? Is there a simple SQL function to handle ORA-01722:
invalid number.

Only the values inserted with 2 or -1 will should count.

CREATE TABLE TEST1(COL1 VARCHAR2(4000);

BEGIN
FOR x in 1..1000000
LOOP
INSERT INTO TEST1
SELECT
CASE mod(dbms_crypto.randomnumber,3)
WHEN 1 THEN 'ABC'
WHEN 2 THEN '123'
WHEN -1 THEN '100.42'
WHEN 0 THEN '444.4a' -- NULL --
to_char(dbms_crypto.randomnumber)
ELSE 'BJORK'
END
FROM DUAL;
END LOOP;
END;
/

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-26-2008, 05:46 AM
DA Morgan
 
Posts: n/a
Default Re: Bulk Data Type Testing Question

EscVector wrote:
> What is the best way to determine if col1 contains a convertible
> number?
> Bulk collect? Is there a simple SQL function to handle ORA-01722:
> invalid number.
>
> Only the values inserted with 2 or -1 will should count.
>
> CREATE TABLE TEST1(COL1 VARCHAR2(4000);
>
> BEGIN
> FOR x in 1..1000000
> LOOP
> INSERT INTO TEST1
> SELECT
> CASE mod(dbms_crypto.randomnumber,3)
> WHEN 1 THEN 'ABC'
> WHEN 2 THEN '123'
> WHEN -1 THEN '100.42'
> WHEN 0 THEN '444.4a' -- NULL --
> to_char(dbms_crypto.randomnumber)
> ELSE 'BJORK'
> END
> FROM DUAL;
> END LOOP;
> END;
> /


Bulk collect into an array.
Delete unwanted elements from the array
FORALL INSERT using the INDICES OF syntax
http://www.psoug.org/reference/array_processing.html
--
Daniel A. Morgan
University of Washington
damorgan@x.washington.edu
(replace x with u to respond)
Puget Sound Oracle Users Group
www.psoug.org
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-26-2008, 05:48 AM
EscVector
 
Posts: n/a
Default Re: Bulk Data Type Testing Question

On Mar 23, 5:13 pm, DA Morgan <damor...@psoug.org> wrote:
> EscVector wrote:
> > What is the best way to determine if col1 contains a convertible
> > number?
> > Bulk collect? Is there a simple SQL function to handle ORA-01722:
> > invalid number.

>
> > Only the values inserted with 2 or -1 will should count.

>
> > CREATE TABLE TEST1(COL1 VARCHAR2(4000);

>
> > BEGIN
> > FOR x in 1..1000000
> > LOOP
> > INSERT INTO TEST1
> > SELECT
> > CASE mod(dbms_crypto.randomnumber,3)
> > WHEN 1 THEN 'ABC'
> > WHEN 2 THEN '123'
> > WHEN -1 THEN '100.42'
> > WHEN 0 THEN '444.4a' -- NULL --
> > to_char(dbms_crypto.randomnumber)
> > ELSE 'BJORK'
> > END
> > FROM DUAL;
> > END LOOP;
> > END;
> > /

>
> Bulk collect into an array.
> Delete unwanted elements from the array
> FORALL INSERT using the INDICES OF syntaxhttp://www.psoug.org/reference/array_processing.html
> --
> Daniel A. Morgan
> University of Washington
> damor...@x.washington.edu
> (replace x with u to respond)
> Puget Sound Oracle Users Groupwww.psoug.org


Thanks for the reply. This is exactly what I wanted to do.

Using REGEXP the BULK COLLECT, FORALL, INDICES will work nicely.


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 03:12 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com