SAK �}�‘ŠÙ
PostgreSQL •Ò24 - PL/pgSQL�Aƒe�[ƒuƒ‹�\‘¢ˆê——•\ަ�A•W�€�A“®“ISQL�ALIKE
�¡ƒe�[ƒuƒ‹�\‘¢ˆê——•\ަ(•W�€—á)
�EŠeƒe�[ƒuƒ‹‚̃e�[ƒuƒ‹�\‘¢ˆê——‚ð•\ަ‚·‚é‚É‚Í�AŽŸ‚̂悤‚É‚·‚é�B
–ß‚è’l‚ɂ̓e�[ƒuƒ‹�”‚ª•Ô‚é�B
�®�A•¡�”‚̃f�[ƒ^ƒx�[ƒX‚ª‚ ‚é�ê�‡‚Ì“®�ì‚Í–¢ŒŸ�؂ł ‚é�B
-- PL/pgSQL �� --
drop function tbllist();
create function tbllist() returns int as
'
declare
rec record;
rec2 record;
rcd int := 0;
begin
for rec in
select * from pg_tables where not tablename like ''pg%''
order by tableowner, tablename loop
raise debug ''tablename= %'', rec.tablename;
for rec2 in
select attname, atttypid, attlen from pg_attribute
where attnum > 0 and attrelid =
(select relfilenode from pg_class where relname = rec.tablename)
order by attnum loop
raise debug ''attname= % atttypid= % attlen= &'', rec2.attname, rec2.atttypid, rec2.attlen;
end loop;
rcd := rcd + 1;
end loop;
return rcd;
end;
'
language 'plpgsql'
;
-- PL/pgSQL ŽÀ�s --
select tbllist();
-- PL/pgSQL Œ‹‰Ê --
DEBUG: tablename= test2m
DEBUG: attname= key atttypid= 1042 attlen= &
DEBUG: attname= code1 atttypid= 1042 attlen= &
DEBUG: tablename= testm
DEBUG: attname= key atttypid= 1042 attlen= &
DEBUG: attname= data1 atttypid= 20 attlen= &
DEBUG: attname= data2 atttypid= 20 attlen= &
DEBUG: attname= data3 atttypid= 20 attlen= &
tbllist
---------
2
�¡ƒe�[ƒuƒ‹�\‘¢ˆê——•\ަ(“®“I SQL ‚ł̗á)
�E•W�€—á‚Æ“¯‚¶‚±‚Ƃ𓮓I SQL ‚ðŽg—p‚µ‚ÄŽÀŒ»‚·‚é�B
ŽÀ�Û‚É‚Í�u•W�€�v‚Å�o—ˆ‚邱‚Æ‚É�u“®“I SQL�v‚ðŽg—p‚·‚é•K—v‚͂Ȃ¢�B
-- PL/pgSQL �� --
drop function tbllist();
create function tbllist() returns int as
'
declare
rec record;
rec2 record;
rcd int := 0;
sql varchar;
begin
for rec in
select * from pg_tables where not tablename like ''pg%''
order by tableowner, tablename loop
raise debug ''tablename= %'', rec.tablename;
sql := ''select attname, atttypid, attlen from pg_attribute where attnum > 0 and attrelid = (select relfilenode from pg_class where relname = '' || chr(39) || rec.tablename || chr(39) || '') order by attnum'';
for rec2 in execute sql loop
raise debug ''attname= % atttypid= % attlen= &'', rec2.attname, rec2.atttypid, rec2.attlen;
end loop;
rcd := rcd + 1;
end loop;
return rcd;
end;
'
language 'plpgsql'
;
-- PL/pgSQL ŽÀ�s --
select tbllist();
-- PL/pgSQL Œ‹‰Ê --
DEBUG: tablename= test2m
DEBUG: attname= key atttypid= 1042 attlen= &
DEBUG: attname= code1 atttypid= 1042 attlen= &
DEBUG: tablename= testm
DEBUG: attname= key atttypid= 1042 attlen= &
DEBUG: attname= data1 atttypid= 20 attlen= &
DEBUG: attname= data2 atttypid= 20 attlen= &
DEBUG: attname= data3 atttypid= 20 attlen= &
tbllist
---------
2
�¡ƒe�[ƒuƒ‹�\‘¢ˆê——•\ަ(LIKE Žg—p—á)
�E•W�€—á‚Æ“¯‚¶‚±‚Æ‚ð LIKE ‚ðŽg—p‚µ‚ÄŽÀŒ»‚·‚é�B
ŽÀ�ۂɂ̓e�[ƒuƒ‹�\‘¢ˆê——•\ަ‚ł͌µ–§ˆê’v‚ª•K—v‚Ȃ̂ŠLIKE ‚Ì�o”Ô‚Í
‚È‚¢�B�\•¶—á‚Æ‚µ‚ÄŒ©‚Ä‚‚¾‚³‚¢�B
-- PL/pgSQL �� --
drop function tbllist();
create function tbllist() returns int as
'
declare
rec record;
rec2 record;
rcd int := 0;
begin
for rec in
select * from pg_tables where not tablename like ''pg%''
order by tableowner, tablename loop
raise debug ''tablename= %'', rec.tablename;
for rec2 in
select attname, atttypid, attlen from pg_attribute
where attnum > 0 and attrelid =
(select relfilenode from pg_class where relname like rec.tablename || ''%'')
order by attnum loop
raise debug ''attname= % atttypid= % attlen= &'', rec2.attname, rec2.atttypid, rec2.attlen;
end loop;
rcd := rcd + 1;
end loop;
return rcd;
end;
'
language 'plpgsql'
;
�¡PostgreSQL •Ò�AJAVA Servlet�AJSP •ÒŽ‘—¿
�¡MySQL •ÒŽ‘—¿
�¡SQL Šî‘b•ÒŽ‘—¿
�¡SQL Šî‘bŽÀ’n•ÒŽ‘—¿
�¡SQL ƒ`ƒ…�[ƒjƒ“ƒO•ÒŽ‘—¿
�¡Oracle PL/SQL •ÒŽ‘—¿