Hi
i do not know how many dependencies you have on that field, but i will create second field with proper collation, poulate it from old field, delete old and rename new.
But i see you can use my below function i have used it to different purposes but it should fit your needs.
SET TERM ^ ;
RECREATE FUNCTION REFORMAT_SN(S VARCHAR(100), PAD_NUM_CHARS INTEGER) RETURNS VARCHAR(500)
AS
DECLARE VARIABLE VAR_RESULT VARCHAR(500);
DECLARE VARIABLE VAR_I INTEGER;
DECLARE VARIABLE VAR_SUB_NR VARCHAR(100);
DECLARE VARIABLE VAR_SUB_A VARCHAR(100);
DECLARE VARIABLE VAR_LEN INTEGER;
DECLARE VARIABLE VAR_C CHAR(1);
BEGIN
IF (S IS NULL) THEN
RETURN NULL;
VAR_LEN = CHAR_LENGTH(S);
VAR_I=1;
VAR_SUB_NR = '';
VAR_SUB_A = '';
VAR_RESULT = '';
WHILE (VAR_I<=VAR_LEN) DO
BEGIN
VAR_C = SUBSTRING(S FROM :VAR_I FOR 1);
IF ('0123456789' CONTAINING :VAR_C) THEN
BEGIN
VAR_SUB_NR = VAR_SUB_NR || VAR_C;
IF (VAR_SUB_A<>'') THEN
VAR_RESULT = VAR_RESULT || LPAD(VAR_SUB_A, PAD_NUM_CHARS, '_');
VAR_SUB_A = '';
END ELSE
BEGIN
VAR_SUB_A = VAR_SUB_A || VAR_C;
IF (VAR_SUB_NR<>'') THEN
VAR_RESULT = VAR_RESULT || LPAD(VAR_SUB_NR, PAD_NUM_CHARS, '0');
VAR_SUB_NR = '';
END
VAR_I = VAR_I + 1;
END
IF (VAR_SUB_A<>'') THEN
VAR_RESULT = VAR_RESULT || LPAD(VAR_SUB_A, PAD_NUM_CHARS, '_');
IF (VAR_SUB_NR<>'') THEN
VAR_RESULT = VAR_RESULT || LPAD(VAR_SUB_NR, PAD_NUM_CHARS, '0');
RETURN VAR_RESULT;
END
^
SET TERM ; ^
Create it and then simply
SELECT
NUMERO
FROM
DOC_TESTA
ORDER BY REFORMAT_SN(NUMERO, 20)
Regards,
Karol Bieniaszewski
--
You received this message because you are subscribed to the Google Groups "firebird-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebird-suppo...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/firebird-support/adc6d9ab-41ed-5003-93c3-e01fba12c34b%40tiscalinet.it.
Hi
i do not know how many dependencies you have on that field, but i will create second field with proper collation, poulate it from old field, delete old and rename new.
No dependencies.
But i see you can use my below function i have used it to different purposes but it should fit your needs.
Thank You