Subject | Re: [firebird-support] Stripping non numerics from a string column |
---|---|
Author | Alexandre Benson Smith |
Post date | 2007-07-20T21:30:12Z |
Rich Pinder wrote:
SPLITTEXT('+49/()6849-22415',NULL,'-+/()')" *is* SQL
Stored Procedures are not Stored Functions (not yet :-) ) to be used
like your example
try those variations (I don't know the procedure code, so I don't know
if it's selectable or executable):
Selectable (I think you have this one):
begin
select optext from splittext(old.phone, NULL, '-') into new.Phone;
end;
Executable:
begin
execute procedure splittext(old.phone, NULL, '-') returning_values
new.Phone;
end;
I had never did this kind of procedure inside triggers, but I think the
above syntax would be ok. You could try store the SP result into a
variable first and after that apply the variable value to the new.phone
field like thi:
.
Selectable (I think you have this one):
declare variable wPhone varchar(20) /* define it according to the column
definition of your table */
begin
select optext from splittext(old.phone, NULL, '-') into :wPhone;
new.Phone = wPhone;
end;
Executable:
declare variable wPhone varchar(20) /* define it according to the column
definition of your table */
begin
execute procedure splittext(old.phone, NULL, '-') returning_values
wPhone;
new.Phone = wPhone;
end;
--
Alexandre Benson Smith
Development
THOR Software e Comercial Ltda
Santo Andre - Sao Paulo - Brazil
www.thorsoftware.com.br
> Of course, NOW I realize why I was looking for something 'built in' !!I can't find the parent message on this thread that shows all the code..
>
> 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.I don't know if I understood you... but this example "SELECT OPTEXT FROM
>
> But, I'm fuzzy on how to pass parameters either in a) sql
SPLITTEXT('+49/()6849-22415',NULL,'-+/()')" *is* SQL
> (think I can'tyou could.
> ), 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 inyou are using bad syntax here...
> clean. On on INSERT and UPDATE, tried something like:
>
>
>> begin
>> new.phone = splittext(old.phone, NULL, '-');
>> end
>>
>
>
Stored Procedures are not Stored Functions (not yet :-) ) to be used
like your example
try those variations (I don't know the procedure code, so I don't know
if it's selectable or executable):
Selectable (I think you have this one):
begin
select optext from splittext(old.phone, NULL, '-') into new.Phone;
end;
Executable:
begin
execute procedure splittext(old.phone, NULL, '-') returning_values
new.Phone;
end;
I had never did this kind of procedure inside triggers, but I think the
above syntax would be ok. You could try store the SP result into a
variable first and after that apply the variable value to the new.phone
field like thi:
.
Selectable (I think you have this one):
declare variable wPhone varchar(20) /* define it according to the column
definition of your table */
begin
select optext from splittext(old.phone, NULL, '-') into :wPhone;
new.Phone = wPhone;
end;
Executable:
declare variable wPhone varchar(20) /* define it according to the column
definition of your table */
begin
execute procedure splittext(old.phone, NULL, '-') returning_values
wPhone;
new.Phone = wPhone;
end;
> I am surely missing syntax here... and thanks for any pointssee you !
>
> Rich
>
>
>
--
Alexandre Benson Smith
Development
THOR Software e Comercial Ltda
Santo Andre - Sao Paulo - Brazil
www.thorsoftware.com.br