Thursday, December 24, 2009

Summary results for dates


select 1979 + years.year  year
from   ( select  rownum year
         from    dual
         connect
         by      rownum < 6 ) years
/

YEAR
----------
      1980
      1981
      1982
      1983
      1984
      1985



Or 


Generate Ascii codes:

select 96 + codes.code  code
from   ( select  rownum code
         from    dual
         connect
         by      rownum < 27 ) codes




select DBMS_RANDOM.string('L',3) from dba_objects    


STRING

The STRING function returns a string of random characters of the specified length. The OPT parameter determines the type of string produced as follows:
  • 'u', 'U' - uppercase alpha characters
  • 'l', 'L' - lowercase alpha characters
  • 'a', 'A' - mixed case alpha characters
  • 'x', 'X' - uppercase alpha-numeric characters
  • 'p', 'P' - any printable characters
The LEN parameter, not surprisingly, specifies the length of the string returned.
SET SERVEROUTPUT ON
BEGIN
  FOR i IN 1 .. 5 LOOP
    DBMS_OUTPUT.put_line('string(''x'',10)= ' || DBMS_RANDOM.string('x',10));
  END LOOP;
END;
/
string('x',10)= BL69189JC0
string('x',10)= XKSI33Z5E8
string('x',10)= WMK7LWIXK7
string('x',10)= E9T9KAZTIX
string('x',10)= 5NTMSELFXD

PL/SQL procedure successfully completed.

SQL>

No comments: