Subject Re: [firebird-support] Stripping non numerics from a string column
Author Rich Pinder
Of course, NOW I realize why I was looking for something 'built in' !!

Read thru Helen's chapters, on both SP and Triggers, and continue to
miss something (probably) quite easy.

So, started with the SP described in SI's post below - description is:
> CREATE OR ALTER PROCEDURE SPLITTEXT
> (
> ipTEXT VARCHAR(32000),
> ipSPLITCHARS VARCHAR(20),
> ipIGNORECHARS VARCHAR(20)
> )
> RETURNS
> (
> opTEXT VARCHAR(500))
> AS
> DECLARE VARIABLE vCurrChar VARCHAR(1);
> DECLARE VARIABLE vIDX INTEGER;
> DECLARE VARIABLE vLen INTEGER;

Example shows:
> SELECT OPTEXT
> FROM SPLITTEXT('+49/()6849-22415',NULL,'-+/()')
and this works fine. So SP is active.

But, I'm fuzzy on how to pass parameters either in a) sql (think I can't
), or b) inside a trigger (think I can, but just cant quite grasp it !!)

I'm 'recoding' existing data, and want to insure new data goes in
clean. On on INSERT and UPDATE, tried something like:

> begin
> new.phone = splittext(old.phone, NULL, '-');
> end

I am surely missing syntax here... and thanks for any points

Rich



Rich Pinder wrote:
>
> Thanks Nigel,
> I will follow the examples given already for writing a SP - just
> wondered first if I was missing something built in.
>
> ref: http://tech.groups.yahoo.com/group/firebird-support/message/68619
> <http://tech.groups.yahoo.com/group/firebird-support/message/68619>
>
> r
>
> Rich Pinder wrote:
> >
> > I was hoping not to have to write my own function, but I'm not finding
> > anything build in to help update columns by stripping characters from a
> > string. I'd like to use SQL alone to accomplish the update.
> >
> > Phone numbers is the issue
> >
> > Would like to translate 818) 450-2345 into 8189097749
> > Generally, anything which is not a numeral (0-9), I'd like to strip
> >
> > Thanks in advance for any points
> > Rich Pinder
> > USC School of Medicine
> >
> >
>
>