Top of case does not work

Hi all

Why not this wor? I received .csv gall foreign and loaded in oracle which is B_SECOND.

< pre >
create table A_PRIME)
username varchar2 (50).
number of planner_id);

create table B_SECOND)
username varchar2 (50).
number of planner_id);

insert into A_PRIME
values ("janet jackson", 1);

insert into A_PRIME
values ("lisa priestley', 2");


insert into B_SECOND
values ("Janet Jackson", 45);

insert into B_SECOND
values ("Lisa PRIESTLEY", 50 ");

update of A_PRIME one
Set planner_id =
(select planner_id from B_SECOND b WHERE UPPER (B.USERNAME) = UPPER (A.USERNAME))
where EXISTS (select planner_id from B_SECOND b WHERE UPPER (B.USERNAME) = UPPER (A.USERNAME));

< / pre >

The above work in oracle (table and data create din oracle) but does not work with the B_SECOND table laoded .csv. of SQLLOADER

How to find all the spaces or any other problem with the data?
< pre >
update of A_PRIME one
Set planner_id =
(select planner_id from B_SECOND b WHERE UPPER (B.USERNAME) = UPPER (A.USERNAME))
where EXISTS (select planner_id from B_SECOND b WHERE UPPER (B.USERNAME) = UPPER (A.USERNAME));
< / pre >

Does not work with Lisa PRIESTLEY of the csv, but works well with create data in Oracle.Even when I put trim upper front, does not work.

Published by: CrackerJack on November 15, 2009 17:16

Oops, it should be + no * (* if the result is a space between each character). Use:

update  A_PRIME a
  set planner_id = (
                    select  planner_id
                      from  B_SECOND b
                      WHERE UPPER(TRIM(REGEXP_REPLACE(B.USERNAME,CHR(160) || '+',' '))) = UPPER(TRIM(REGEXP_REPLACE(A.USERNAME,CHR(160) || '+',' ')))
                   )
  where EXISTS(
               select  planner_id
                 from  B_SECOND b
                 WHERE UPPER(TRIM(REGEXP_REPLACE(B.USERNAME,CHR(160) || '+',' '))) = UPPER(TRIM(REGEXP_REPLACE(A.USERNAME,CHR(160) || '+',' ')))
              );

For example:

SQL> select username,planner_id,dump(username) from a_prime
  2  /

USERNAME                                           PLANNER_ID
-------------------------------------------------- ----------
DUMP(USERNAME)
------------------------------------------------------------------------------------------------------------------------------------
david lim                                                   1
Typ=1 Len=9: 100,97,118,105,100,32,108,105,109

david diamond                                               2
Typ=1 Len=13: 100,97,118,105,100,32,100,105,97,109,111,110,100

SQL> select username,planner_id,dump(username) from b_second
  2  /

USERNAME                                           PLANNER_ID
-------------------------------------------------- ----------
DUMP(USERNAME)
------------------------------------------------------------------------------------------------------------------------------------
David   Lim                                                45
Typ=1 Len=14: 68,97,118,105,100,160,160,160,76,105,109,160,160,160

David   Diamond                                            50
Typ=1 Len=18: 68,97,118,105,100,160,160,160,68,105,97,109,111,110,100,160,160,160

SQL> update  A_PRIME a
  2    set planner_id = (
  3                      select  planner_id
  4                        from  B_SECOND b
  5                        WHERE UPPER(TRIM(REGEXP_REPLACE(B.USERNAME,CHR(160) || '+',' '))) = UPPER(TRIM(REGEXP_REPLACE(A.USERNAME,CHR(160) || '+',' ')))
  6                     )
  7    where EXISTS(
  8                 select  planner_id
  9                   from  B_SECOND b
 10                   WHERE UPPER(TRIM(REGEXP_REPLACE(B.USERNAME,CHR(160) || '+',' '))) = UPPER(TRIM(REGEXP_REPLACE(A.USERNAME,CHR(160) || '+',' ')))
 11                );

2 rows updated.

SQL> select * from a_prime
  2  /

USERNAME                                           PLANNER_ID
-------------------------------------------------- ----------
david lim                                                  45
david diamond                                              50

SQL> 

SY.

Tags: Database

Similar Questions

Maybe you are looking for