Hi

I like using VALUES in SQL as a way to give a short name to an
expression or a substring, but I haven't yet tried to use it in an
update statement (where the data comes from within the record itself).
Is it possible?

Consider the following alteration to a flat file, which replaces the
text at pos. 57 for 30 characters, prepending PAYMORE to the string if
it doesn't already contain PAYMORE, and does contain 'Sales' or
'Branch' (or is 'NYC'), and the statement simultaneously removes
'Sales' and/or 'Branch':

update FLATFL
set FLDATA =
overlay(FLDATA placing
'PAYMORE ' || substr(replace(replace( substr(FLDATA,57,30) ,
'Branch',''),'Sales',''),1,22)
from 57 for 30)
where upper(substr(FLDATA,57,30)) not like '%PAYMORE%'
and ( regexp_like( substr(FLDATA,57,30) ,'(Sales|Branch)') OR
substr(FLDATA,57,30) = 'NYC')

So, for instance 'Baltimore Sales' would become 'PAYMORE Baltimore'
(has a nice ring to it), and 'NYC' would become 'PAYMORE NYC'.

This works, but as you can see, "substr(FLDATA,57,30)" is defined four
times, which is not very elegant. It would be nice to be able to
define it once and refer to it by name. But without a FROM or a WITH,
I can't figure out how to get a VALUES clause in there.

Thanks,

Arnie.

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.