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 •Ò4 - SQL •¶A“®“I SQLAselectAinsertAupdateAdelete

¡SQL •¶

  PL/SQL “à‚Å‚à
    insert
    update
    delete
    select
    lock table
    commit
    rollback
    savepoint
    rollback to
    set transaction
  ‚È‚Ç‚Ì SQL •¶‚ªŽg‚¦‚邪A‚»‚ÌŽž“_‚Å‘¶Ý‚µ‚È‚¢ƒIƒuƒWƒFƒNƒg–¼‚ðŠÜ‚Þ‚±‚Æ
  ‚Í‚Å‚«‚È‚¢B]‚Á‚āAcreate table ‚̃e[ƒuƒ‹–¼‚̓Gƒ‰[‚É‚È‚éB
  ‚±‚ê‚ɑΏˆ‚·‚é‚ɂ́A“®“I SQL ‚ðŽg—p‚·‚éB

¡“®“I SQL

declare
  tbl in varchar2 default 'test';
  cid integer;
begin
  cid := DBMS_SQL.OPEN_CURSOR;
  DBMS_SQL.PARSE(cid, 'create table ' || tbl || ' (ƒf[ƒ^ number(9))', dbms_sql.v7);
  DBMS_SQL.CLOSE_CURSOR(cid);
  dbms_output.put_line ('end');
exception
  when OTHERS then
    dbms_output.put_line ('** ƒGƒ‰[ **');
end;
/

¡select (–â‚¢‡‚킹AƒŒƒR[ƒhŽQÆ)

declare
  jcsu number(12, 2);
begin
  select Žó’” into jcsu from Žó’m where Žó’”ԍ† = '000010-001';
end;
/

¡insert (ƒŒƒR[ƒh’ljÁ)

declare
  jcsu number(12, 2);
begin
  jcsu := 100;
  insert into Žó’m values ('111111-011', 'a001', jcsu, '1000',
    'sak', '2001.08.25', '07:02:00');
  commit;
end;
/

¡update (ƒŒƒR[ƒhC³AƒŒƒR[ƒhXV)

declare
  jcsu number(12, 2);
begin
  jcsu := 100;
  update Žó’m set Žó’” = Žó’” + jcsu where Žó’”ԍ† = '111111-011';
  commit;
end;
/

¡delete (ƒŒƒR[ƒhíœ)

declare
  jcno  varchar2(10);
begin
  jcno := '111111-011';
  delete from Žó’m where Žó’”ԍ† = jcno;
  commit;
end;
/

¡set transaction (“Ç‚ÝŽæ‚èê—pƒgƒ‰ƒ“ƒUƒNƒVƒ‡ƒ“)

declare
  jcsu number(12, 2);
begin
  set transaction read only;
  select Žó’” into jcsu from Žó’m where Žó’”ԍ† = '000010-001';
  commit;
end;
/

¡commitArollback (ƒgƒ‰ƒ“ƒUƒNƒVƒ‡ƒ“ƒRƒ~ƒbƒgAƒ[ƒ‹ƒoƒbƒN)

declare
  jcsu number(12, 2);
begin
  jcsu := 100;
  insert into Žó’m values ('111111-011', 'a001', jcsu, '1000',
    'sak', '2001.08.25', '07:02:00');
  commit;
exception
  when OTHERS then
    rollback;
end;
/

¡savepointArollback to (ƒZ[ƒuƒ|ƒCƒ“ƒgA2 ƒtƒF[ƒYƒRƒ~ƒbƒg)

declare
  jcsu number(12, 2);
begin
  jcsu := 100;
  insert into Žó’m values ('111111-011', 'a001', jcsu, '1000',
    'sak', '2001.08.25', '07:02:00');
  savepoint sv_ins1;
  jcsu := 200;
  insert into Žó’m values ('111111-011', 'a001', jcsu, '1000',
    'sak', '2001.08.25', '07:02:00');
  commit;
exception
  when DUP_VAL_ON_INDEX then
    rollback to sv_ins1;
end;
/

¡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