Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Generating characters with SQL

Re: Generating characters with SQL

From: Michel Cadot <micadot{at}altern{dot}org>
Date: Mon, 8 Dec 2003 20:20:04 +0100
Message-ID: <3fd4ceab$0$28706$626a54ce@news.free.fr>

"Vitalo Pedrotti" <vitalisREMOVETHAT_at_numericable.fr> a écrit dans le message de news:pan.2003.12.08.13.06.36.887251.321_at_numericable.fr...
> Do you know a simple way to generate long strings in SQL? Something like
> the x operator of Perl ('go' x 1000 is 'gogogogogo....')
>
> And even better: how to generate a long *random* string?
>
> TIA
v817> select lpad('GO',10,'GO') from dual;

LPAD('GO',



GOGOGOGOGO 1 ligne sélectionnée.

v817> set serveroutput on
v817> exec dbms_output.put_line(dbms_random.string('X',10)); ?=21NJJ;64 Procédure PL/SQL terminée avec succès.

FUNCTION string (opt char, len NUMBER)

          /* "opt" specifies that the returned string may contain:
             'u','U'  :  upper case alpha characters only
             'l','L'  :  lower case alpha characters only
             'a','A'  :  alpha characters only (mixed case)
             'x','X'  :  any alpha-numeric characters (upper)
             'p','P'  :  any printable characters
          */
        RETURN VARCHAR2;  -- string of <len> characters (max 60)

Hope this helps
Michel Cadot Received on Mon Dec 08 2003 - 13:20:04 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US