[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

minus gives me results but i see no difference

Posted on 2013-12-27
11
Medium Priority
?
323 Views
Last Modified: 2014-01-07
Hi,
i am  doing below query to see differences:

select frenchdesc from table a
minus
select frenchdesc from table b

and i am seeing the difference

but when i select the record in both table it looks same to me any idea why minus gives me results:


table a

"DIRECTEUR - SERVICES STÉRIELS
"
table b

"DIRECTEUR - SERVICES STÉRIELS
0
Comment
Question by:sam2929
  • 4
  • 3
  • 2
  • +2
11 Comments
 
LVL 23

Expert Comment

by:David
ID: 39742641
It may be a typographic mistake, but the table B string is missing the <newline> closing ".  It is possible, albeit unlikely, that one of the two strings has unprintable characters.

If you would, provide a better sample of the two tables and the result set.  What I would expect is something like:

table a:
a
b
c

table b:
a
d

The result would be:
b
c
0
 

Author Comment

by:sam2929
ID: 39743251
String missing was typo i think i know the problem one column is unicode and the other is not
any idea how can i see if the database support unicode or not
0
 
LVL 23

Expert Comment

by:David
ID: 39743597
SELECT *
  FROM v$nls_parameters
 WHERE parameter LIKE '%CHARACTERSET'

Results?  And a web search on "Oracle unicode" will provide additional resources for your second question.  Also, which RDBMS version are you running?
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 

Author Comment

by:sam2929
ID: 39743662
its 11g
0
 
LVL 78

Expert Comment

by:slightwv (䄆 Netminder)
ID: 39743955
Take a look at the individual bytes in the returned resultset:

select dump(frenchdesc) from (
select frenchdesc from table a
minus
select frenchdesc from table b
)

Then check the individual bytes from the two returned.
0
 

Author Comment

by:sam2929
ID: 39746304
This is what i find not sure what it means length are different when you say bytes what bytes mean here?


Typ=1 Len=80: 0,68,0,73,0,82,0,69,0,67,0,84,0,69,0,85,0,82,0,32,0,45,0,32,0,
32,0,73,0,78,0,86,0,69,0,83,0,84,0,73,0,83,0,83,0,69,0,77,0,69,0,
78,0,84,0,83,0,32,0,83,0,84,0,82,0,65,0,84,0,201,0,71,0,73,0,81,0,85,0,69


DIRECTEUR -  INVESTISSEMENTS STRATÉGIQUE


Typ=1 Len=41: 68,73,82,69,67,84,69,85,82,32,45,32,32,73,78,86,69,83,84,73,83,83,
69,77,69,78,84,83,32,83,84,82,65,84,195,137,71,73,81,85,69

DIRECTEUR -  INVESTISSEMENTS STRATÉGIQUE
0
 
LVL 21

Accepted Solution

by:
flow01 earned 2000 total points
ID: 39746672
Appears there is an extra chr(0) before each character. If i try to reproduce it I get different results depending on the tool I use.

Try with table_a
as
(
select 'DIRECTEUR -  INVESTISSEMENTS STRATÉGIQUE' frenchdesc from dual
)
, table_b
as
(select REGEXP_REPLACE(frenchdesc, '(.)', chr(0) || '\1' ) frenchdesc from table_a)
select frenchdesc from (
select frenchdesc from table_a
union all
select frenchdesc from table_b
)
/

in sqlplus i get
FRENCHDESC
--------------------------------------------------------------------------------
DIRECTEUR -  INVESTISSEMENTS STRATÉGIQUE
 D I R E C T E U R   -     I N V E S T I S S E M E N T S   S T R A T É G I Q U E
so chr(0) shows like a blank

in pl-sql developer
1      
2      DIRECTEUR -  INVESTISSEMENTS STRATÉGIQUE
so chr(0) ends display the value (if i set the chr(0) after each character i only see 'D'

May be your tool just does not show the value chr(0)
You could try removing it before making the comparison replace(frenchdesc,chr(0),null)
0
 
LVL 78

Expert Comment

by:slightwv (䄆 Netminder)
ID: 39747053
As dvz suggested above, it looks like it is a characterset issue.

Is one of the columns a NVARCHAR2 and one not?
Is it possible that one of the tables is from a database link to a remote database?

The one with the length of 80 looks like a 2Byte characterset.  If you remove the 0 bytes and compare them character by character, look at the "É".

They show two different codes.
201,71
195,137

This is why the minus returned them.
0
 

Author Comment

by:sam2929
ID: 39750033
yes we pulling data from SAP which is remote access and its unicode .

we inserting it in oracle database which is varchar .

Are you suggesting i convert nvarchar to varchar and all should be good.
0
 
LVL 23

Expert Comment

by:David
ID: 39750298
I'm missing where you every responded to my query, exactly which character set is your client session using?
0
 
LVL 38

Expert Comment

by:Geert Gruwez
ID: 39750334
when loading data from a unicode source (like Sap or Active Directory) and storing it in the oracle database tables as VARCHAR2 a conversion occurs from unicode across the setting of the language you use (probably WE8MSWIN1252) to 8-bit ascii.

if you then do a select on the saved data and compare that with a select of the original, they will differ
as you see in the bytes returned, but possibly not on the screen

if you want an exact match in the database without conversion
use NVARCHAR2 or NCLOB for the data holding characters
0

Featured Post

2018 Annual Membership Survey

Here at Experts Exchange, we strive to give members the best experience. Help us improve the site by taking this survey today! (Bonus: Be entered to win a great tech prize for participating!)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
This post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.
This video shows how to recover a database from a user managed backup
Suggested Courses
Course of the Month8 days, 7 hours left to enroll

607 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question