Yudie, > Is there any default function for formating string in postgre sql? > for instance: > Format('123ABCDE', '####-###-###') => '12-3AB-CDE' > > The closest function I know is the to_char() function but it only works for numbers
No, there isn't. You could write one, though. For example, you could write: (7.3 syntax) CREATE FUNCTION yudie_format(text) RETURNS text AS 'SELECT SUBSTR($1, 1, 4) || ''-'' || SUBSTR($1,5,3) || ''-'' || SUBSTR($1,9,4); ' LANGUAGE SQL IMMUTABLE STRICT; As a simple formatting function. For that matter, it would be the work of a weekend for someone to write a function in PL/Perl which would take a format mask and apply it to any text string. -- -Josh Berkus Aglio Database Solutions San Francisco ---------------------------(end of broadcast)--------------------------- TIP 5: Have you checked our extensive FAQ? http://www.postgresql.org/users-lounge/docs/faq.html