Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: Generating characters with SQL
"Michel Cadot" <micadot{at}altern{dot}org> a écrit dans le message de news:
3fd4ceab$0$28706$626a54ce_at_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
>
>
Merci Michel pour ces 2 réponses !
dbms_random.string seems to be restricted to 60 characters; using it with lpad should do the trick for huge strings. Received on Mon Dec 08 2003 - 16:34:44 CST
![]() |
![]() |