Solved

Trimming a number forces failure on MERGE

Posted on 2011-09-27
5
361 Views
Last Modified: 2012-05-12
Greetings,
With this SQL, (in both select statements, the datatype is number(15,0))
 
SELECT NVL(TRIM(K3A.BSA_ID), 0) as FINANCIAL_INST_BRANCH_SEQ_NUM
FROM CASH_8300_3A K3A
UNION
SELECT 0 AS FINANCIAL_INST_BRANCH_SEQ_NUMB
FROM CTR_1A

Open in new window


I get the following error:
ORA-01790: expression must have same datatype as corresponding expression
01790. 00000 -  "expression must have same datatype as corresponding expression"
*Cause:    
*Action:
Error at Line: 1 Column: 7

Why does TRIM fail the MERGE?  If it's job is to just remove leading zeros, I am not understanding the fail here.
0
Comment
Question by:Evan Cutler
5 Comments
 
LVL 76

Accepted Solution

by:
slightwv (䄆 Netminder) earned 500 total points
ID: 36712870
Jut like the last question:  TRIM returns a varchar2.

Change to:
NVL(to_number(TRIM(K3A.BSA_ID)), 0)
0
 
LVL 73

Expert Comment

by:sdstuber
ID: 36712878
Trim removes leading a
nd trailing spaces
Which causes an implicit conversion from number to string
0
 
LVL 76

Expert Comment

by:slightwv (䄆 Netminder)
ID: 36712881
>> If it's job is to just remove leading zeros

Not quite what it does.

From the docs:

TRIM enables you to trim leading or trailing characters (or both) from a character string

http://download.oracle.com/docs/cd/E11882_01/server.112/e17118/functions219.htm#SQLRF06149
0
 
LVL 34

Expert Comment

by:johnsone
ID: 36712893
Also, what datatype is BSA_ID?  If it is a NUMBER, there is no need for the trim.
0
 
LVL 9

Author Closing Comment

by:Evan Cutler
ID: 36712894
AWESOME...
Thanks Much.
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Have you ever had to make fundamental changes to a table in Oracle, but haven't been able to get any downtime?  I'm talking things like: * Dropping columns * Shrinking allocated space * Removing chained blocks and restoring the PCTFREE * Re-or…
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 information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…

813 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now