SAK }‘ŠÙ

SAK Streets ƒƒCƒ“ƒXƒgƒŠ[ƒg }‘ŠÙEƒJƒtƒF ˆê—— SAK Streets ŒŸõ
| VB | SQL | Perl | PHP | ASP | JSP | C | PC | HP | FAQ | ƒtƒŠ[ƒ\ƒtƒg |

Oracle PL/SQL •Ò11 - —”Adbms_randomAinitializeAseedArandom

¡DBMS_RANDOM

  EDBMS_RANDOM ‚ŁA—”ƒWƒFƒlƒŒ[ƒ^‚ðŽg—p‚Å‚«‚éB
    ƒ}ƒjƒ…ƒAƒ‹‚ɂ́A8 Œ…‚̐®”‚ª•Ô‚é‚Æ‚È‚Á‚Ä‚¢‚邪AƒeƒXƒg‚·‚é‚Æ 10 Œ…
    •Ô‚Á‚Ä‚­‚éBƒ}ƒCƒiƒX’l‚à‚ ‚é‚Ì‚Å—v’ˆÓ‚Å‚ ‚éB

¡initialize

  E—”ƒWƒFƒlƒŒ[ƒ^‚ðƒV[ƒh’l‚ŏ‰Šú‰»‚·‚éB

  dbms_random.initialize(seed);
                         |_ —”ƒV[ƒh’l(in binary_integer)

¡seed

  E—”ƒWƒFƒlƒŒ[ƒ^‚ðƒV[ƒh’l‚ōč\¬‚·‚éB

  dbms_random.seed(seed);
                   |_ —”ƒV[ƒh’l(in binary_integer)

¡random

  E”­¶‚µ‚½—”‚ðŽæ“¾‚·‚éB

  ret := dbms_random.random();
  |_ –ß‚è’l(binary_integer)

¡terminate

  E—”ƒWƒFƒlƒŒ[ƒ^‚ðI—¹‚·‚éB

  dbms_random.terminate;

  EŽŸ‚Ì—á‚́AŒ»ÝŽžŠÔ‚ðƒV[ƒh‚Æ‚µ‚āA—”ƒWƒFƒlƒŒ[ƒ^‚ð‰Šú‰»‚µ‚ÄŽg—p‚µ
    ‚Ä‚¢‚éB

set serveroutput on;

declare
  todttm   char(14);
  rndinit  number;
  rnd      number;
begin

-- —”ƒV[ƒhì¬
  todttm := to_char(sysdate, 'yyyymmddhh24miss');
  rndinit := to_number(substr(todttm, 1, 8)) + to_number(substr(todttm, 9, 6));

-- —”ƒWƒFƒlƒŒ[ƒ^‰Šú‰»
  dbms_random.initialize(rndinit);

-- —”ƒWƒFƒlƒŒ[ƒ^Ä‰Šú‰»
  dbms_random.seed(rndinit);

-- —”Žæ“¾
  rnd := dbms_random.random();
  dbms_output.put_line ('-- ˆ—Œ‹‰Ê --');
  dbms_output.put_line ('—”1 = ' || rnd);

-- —”Žæ“¾
  rnd := dbms_random.random();
  dbms_output.put_line ('—”2 = ' || rnd);

-- —”Žæ“¾
  rnd := dbms_random.random();
  dbms_output.put_line ('—”3 = ' || rnd);

-- —”ƒWƒFƒlƒŒ[ƒ^I—¹
  dbms_random.terminate;

end;
/

-- ˆ—Œ‹‰Ê --
—”1 = 940632317
—”2 = 1303998716
—”3 = -537697097

  EŒ»ŽÀ–â‘è‚Æ‚µ‚āA“Á’è‚͈̗̔͂”‚Æ‚·‚é‚ɂ́AŽŸ‚̂悤‚É‚·‚éB
    ’A‚µA’Pƒ‚ɉº‚ÌŒ…‚ðØ‚èo‚µ‚Ä‚¢‚邾‚¯‚Ȃ̂ŁA—”•ª•z‚ª•Î‚é‰Â”\«‚Í
    ‚ ‚éBketa := 5; ‚ª 5 Œ…‚Ì—”‚Æ‚·‚éŽw’è‚Å‚ ‚éB

set serveroutput on;

declare
  todttm   char(14);
  rndinit  number;
  rnd      number;
  keta     number := 5;
begin

-- —”ƒV[ƒhì¬
  todttm := to_char(sysdate, 'yyyymmddhh24miss');
  rndinit := to_number(substr(todttm, 1, 8)) + to_number(substr(todttm, 9, 6));

-- —”ƒWƒFƒlƒŒ[ƒ^‰Šú‰»
  dbms_random.initialize(rndinit);

-- —”ƒWƒFƒlƒŒ[ƒ^Ä‰Šú‰»
  dbms_random.seed(rndinit);

-- —”Žæ“¾
  rnd := to_number(substr(to_char(dbms_random.random()), - keta, keta));
  dbms_output.put_line ('-- ˆ—Œ‹‰Ê --');
  dbms_output.put_line ('—”1 = ' || rnd);

-- —”Žæ“¾
  rnd := to_number(substr(to_char(dbms_random.random()), - keta, keta));
  dbms_output.put_line ('—”2 = ' || rnd);

-- —”Žæ“¾
  rnd := to_number(substr(to_char(dbms_random.random()), - keta, keta));
  dbms_output.put_line ('—”3 = ' || rnd);

-- —”ƒWƒFƒlƒŒ[ƒ^I—¹
  dbms_random.terminate;

end;
/

-- ˆ—Œ‹‰Ê --
—”1 = 32859
—”2 = 70836
—”3 = 60193

¡Oracle PL/SQL •ÒŽ‘—¿
¡SQL Šî‘bŽÀ’n•ÒŽ‘—¿
¡SQL Šî‘b•ÒŽ‘—¿
¡SQL ƒ`ƒ…[ƒjƒ“ƒO•ÒŽ‘—¿
¡PostgreSQL •ÒAJAVA ServletAJSP •ÒŽ‘—¿
¡MySQL •ÒŽ‘—¿
| VB | SQL | Perl | PHP | ASP | JSP | C | PC | HP | FAQ | ƒtƒŠ[ƒ\ƒtƒg |

SAK Streets ƒƒCƒ“ƒXƒgƒŠ[ƒg }‘ŠÙEƒJƒtƒF ˆê—— SAK Streets ŒŸõ



Copyright (C) 1999-2017 Y.SAK