Em 16/12/08, Rubens José
Rodrigues<[email protected]> escreveu:
>
> Meu cenário:
>
> PostgreSQL 8.3.3, compiled by Visual C++ build 1400
>
> Windows Vista
>
> Minha necessidade:
>
> Verificar uma string, numa posição qualquer, se é alfa ou numérico hoje
> estou fazendo na "unha" algo funcional porém acredito não se a forma mais
> elegante de testar.
>


Verifique se é isto ajuda:

bdteste=# SELECT (substring('ABC12345', 2, 1) ~* '[[:digit:]]') AS "É numérico";
 É numérico
------------
 f
(1 registro)

bdteste=# SELECT (substring('ABC12345', 4, 1) ~* '[[:digit:]]') AS "É numérico";
 É numérico
------------
 t
(1 registro)

bdteste=# SELECT (substring('ABC12345', 2, 1) ~* '[[:alpha:]]') AS "É
alfabético";
 É alfabético
--------------
 t
(1 registro)

bdteste=# SELECT (substring('ABC12345', 4, 1) ~* '[[:alpha:]]') AS "É
alfabético";
 É alfabético
--------------
 f
(1 registro)

Veja:
http://www.postgresql.org/docs/current/interactive/functions-string.html
http://www.postgresql.org/docs/current/interactive/functions-matching.html#FUNCTIONS-POSIX-REGEXP

Osvaldo
_______________________________________________
pgbr-geral mailing list
[email protected]
https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral

Responder a