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 |

PostgreSQL •Ò23 - PL/pgSQLAƒe[ƒuƒ‹ƒŒƒR[ƒhŒ”ˆê——•\Ž¦

¡ƒe[ƒuƒ‹ƒŒƒR[ƒhŒ”ˆê——•\Ž¦

  EŠeƒe[ƒuƒ‹‚̃ŒƒR[ƒhŒ”‚ð•\Ž¦‚·‚é‚É‚ÍAŽŸ‚̂悤‚É‚·‚éB
    –ß‚è’l‚ɂ̓e[ƒuƒ‹”‚ª•Ô‚éB
    ®A•¡”‚̃f[ƒ^ƒx[ƒX‚ª‚ ‚éꇂ̓®ì‚Í–¢ŒŸØ‚Å‚ ‚éB

-- PL/pgSQL ì¬ --
drop function tblrecct();
create function tblrecct() returns int as
'
declare
  rec  record;
  cu   refcursor;
  rec2 record;
  ct   int;
  rcd  int := 0;
begin
  for rec in
  select * from pg_tables where not tablename like ''pg%''
  order by tableowner, tablename loop
    open cu for execute ''select count(*) as ct from '' || rec.tablename;
    fetch cu into rec2;
    if not found then
      ct := 0;
    else
      ct := rec2.ct;
    end if;
    close cu;
    raise debug ''tablename= %  ct= %'', rec.tablename, ct;
    rcd := rcd + 1;
  end loop;
  return rcd;
end;
'
language 'plpgsql'
;

-- PL/pgSQL ŽÀs --
select tblrecct();

-- PL/pgSQL Œ‹‰Ê --
DEBUG:  tablename= test2m  ct= 3
DEBUG:  tablename= testm  ct= 8
 tblrecct
----------
        2

¡PostgreSQL •ÒAJAVA ServletAJSP •ÒŽ‘—¿
¡MySQL •ÒŽ‘—¿
¡SQL Šî‘b•ÒŽ‘—¿
¡SQL Šî‘bŽÀ’n•ÒŽ‘—¿
¡SQL ƒ`ƒ…[ƒjƒ“ƒO•ÒŽ‘—¿
¡Oracle PL/SQL •ÒŽ‘—¿
| 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