Re: Comparing VARCHAR2 and CHAR Columns Equality Test
From: Saad Ahmad <sahmad_at_mfa.com>
Date: 1995/08/31
Message-ID: <425cod$8c4_at_homer.alpha.net>#1/1
Date: 1995/08/31
Message-ID: <425cod$8c4_at_homer.alpha.net>#1/1
Larry Nudelman (LNudelm_at_unotes1.mnet.uswest.com) wrote:
> An application developer is comparing (equality) two columns, one is
> VARCHAR2 and the other CHAR.
> Table A
> chr1 CHAR(100),
> Var2 VARCHAR2(100)
> The developer got around the problem by using:
> Select * from A where RTRIM(chr1) = Var2;
> This Returns the 'ABC' row, but since a chr1 is in a function, a full
> table scan is done. (If you tell me that there are only two rows in
> the table so a full table scan does not make any difference, you
> missed my point).
Do opposite of rtrim, ie. rpad
select * from A where chr1 = rpad (Var2, 100);
-- ************************************************************** * Saad Ahmad * * McHugh Freeman & Associates, Inc. * * Ph: (414) 798-8606 Ext. 457 * * Fax: (414) 798-8619 * * E-Mail: sahmad_at_mfa.com * **************************************************************Received on Thu Aug 31 1995 - 00:00:00 CEST