Re : Using like with a column name

Re : Using like with a column name

 

  

If I'm mistaken, somebody tell me; but I think in DB2 you would say:
WHERE UserSecurityAttributes.dAttributeName LIKE '%DocumentAccounts.dDocAccount %'

Note that this means you will always get a tablescan to resolve this as no index could be used because of the % front padding.
Hope this helps, Pierre.

----- Message d'origine -----
De: Thompson Keith <db2udbdba-ezmlmshield-x80675655.[Email address protected]
Date: Mercredi, Juin 27, 2007 4:19 pm
Objet: Using like with a column name
À: LazyDBA Discussion <[Email address protected]

> I need to convert some SQL server sql to db2. The sql I am starting
> with looks like this:
>
> WHERE (UserSecurityAttributes.dAttributeName LIKE '%' +
> DocumentAccounts.dDocAccount + '%')
>
> They are trying to allow padding of extra characters on either
> side of
> the column name. DB2 returns the error below when a like is
> used with a
> column name.
>
> SQL0132N A LIKE predicate or POSSTR scalar function is not valid
> because the
> first operand is not a string expression or the second operand
> is not a
> string. SQLSTATE=42824
>
> Is there another way to do this in db2?
>
> Thanks,
>
> Keith
>
>
> -----------------------------------------------------------------
> ----
> TO REPLY TO EVERBODY , PLEASE CLICK REPLY-ALL, NOT JUST REPLY
> To post a dba job: http://jobs.lazydba.com
> To Subscribe : http://www.LazyDBA.com
> To unsubscribe: http://www.lazydba.com/unsubscribe.html
>
>

Pierre Saint-Jacques

DB2 & UDB email list listserv db2-l LazyDBA home page