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/pgSQLAƒ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 ServletAJSP •ŌŽ‘—ŋ
Ą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-2017 Y.SAK