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 SQLAselectAinsertAupdateAdelete

¡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[ƒhC³AƒŒƒR[ƒhXV)

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;
/

¡commitArollback (ƒgƒ‰ƒ“ƒUƒNƒVƒ‡ƒ“ƒRƒ~ƒbƒgAƒ[ƒ‹ƒ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;
/

¡savepointArollback to (ƒZ[ƒuƒ|ƒCƒ“ƒgA2 ƒ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 ServletAJSP •ÒŽ‘—¿
¡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-2024 Y.SAK