Merge 3b92d1d047fe
This commit is contained in:
commit
06ebc462b8
|
@ -14,13 +14,13 @@ declare
|
||||||
begin
|
begin
|
||||||
if datatype is not null then
|
if datatype is not null then
|
||||||
select pg_type.typname, format_type(pg_type.oid, pg_attribute.atttypmod)
|
select pg_type.typname, format_type(pg_type.oid, pg_attribute.atttypmod)
|
||||||
into typename, sqltype
|
into typename, sqltype
|
||||||
from pg_class, pg_attribute, pg_type
|
from pg_class, pg_attribute, pg_type
|
||||||
where relname = lower(tablename)
|
where relname = lower(tablename)
|
||||||
and relkind = 'r'
|
and relkind = 'r'
|
||||||
and pg_class.oid = pg_attribute.attrelid
|
and pg_class.oid = pg_attribute.attrelid
|
||||||
and attname = lower(columnname)
|
and attname = lower(columnname)
|
||||||
and atttypid = pg_type.oid;
|
and atttypid = pg_type.oid;
|
||||||
sqltype_short := sqltype;
|
sqltype_short := sqltype;
|
||||||
if typename = 'numeric' then
|
if typename = 'numeric' then
|
||||||
sqltype_short := replace(sqltype, ',0', '');
|
sqltype_short := replace(sqltype, ',0', '');
|
||||||
|
@ -31,28 +31,41 @@ begin
|
||||||
end if;
|
end if;
|
||||||
if lower(datatype) <> sqltype and lower(datatype) <> sqltype_short then
|
if lower(datatype) <> sqltype and lower(datatype) <> sqltype_short then
|
||||||
i := 0;
|
i := 0;
|
||||||
for v in select a.relname, a.oid
|
for v in
|
||||||
from pg_class a, pg_depend b, pg_depend c, pg_class d, pg_attribute e
|
with recursive depv(relname, viewoid, depth) as (
|
||||||
where a.oid = b.refobjid
|
select distinct a.relname, a.oid, 1
|
||||||
and b.objid = c.objid
|
from pg_class a, pg_depend b, pg_depend c, pg_class d, pg_attribute e
|
||||||
and b.refobjid <> c.refobjid
|
where a.oid = b.refobjid
|
||||||
and b.deptype = 'n'
|
and b.objid = c.objid
|
||||||
and c.refobjid = d.oid
|
and b.refobjid <> c.refobjid
|
||||||
and d.relname = lower(tablename)
|
and b.deptype = 'n'
|
||||||
and d.relkind = 'r'
|
and c.refobjid = d.oid
|
||||||
and d.oid = e.attrelid
|
and d.relname = lower(tablename)
|
||||||
and e.attname = lower(columnname)
|
and d.relkind = 'r'
|
||||||
and c.refobjsubid = e.attnum
|
and d.oid = e.attrelid
|
||||||
and a.relkind = 'v'
|
and e.attname = lower(columnname)
|
||||||
loop
|
and c.refobjsubid = e.attnum
|
||||||
|
and a.relkind = 'v'
|
||||||
|
union all
|
||||||
|
select distinct dependee.relname, dependee.oid, depv.depth+1
|
||||||
|
from pg_depend
|
||||||
|
join pg_rewrite on pg_depend.objid = pg_rewrite.oid
|
||||||
|
join pg_class as dependee on pg_rewrite.ev_class = dependee.oid
|
||||||
|
join pg_class as dependent on pg_depend.refobjid = dependent.oid
|
||||||
|
join pg_attribute ON pg_depend.refobjid = pg_attribute.attrelid and pg_depend.refobjsubid = pg_attribute.attnum and pg_attribute.attnum > 0
|
||||||
|
join depv on dependent.relname = depv.relname
|
||||||
|
)
|
||||||
|
select relname, viewoid, max(depth) from depv group by relname, viewoid order by 3 desc
|
||||||
|
loop
|
||||||
i := i + 1;
|
i := i + 1;
|
||||||
viewtext[i] := pg_get_viewdef(v.oid);
|
viewtext[i] := pg_get_viewdef(v.viewoid);
|
||||||
viewname[i] := v.relname;
|
viewname[i] := v.relname;
|
||||||
end loop;
|
end loop;
|
||||||
if i > 0 then
|
if i > 0 then
|
||||||
begin
|
begin
|
||||||
for j in 1 .. i loop
|
for j in 1 .. i loop
|
||||||
command := 'drop view ' || viewname[j];
|
command := 'drop view ' || viewname[j];
|
||||||
|
raise notice 'executing -> %', command;
|
||||||
execute command;
|
execute command;
|
||||||
dropviews[j] := viewname[j];
|
dropviews[j] := viewname[j];
|
||||||
end loop;
|
end loop;
|
||||||
|
@ -60,20 +73,23 @@ begin
|
||||||
when others then
|
when others then
|
||||||
i := array_upper(dropviews, 1);
|
i := array_upper(dropviews, 1);
|
||||||
if i > 0 then
|
if i > 0 then
|
||||||
for j in 1 .. i loop
|
for j in reverse i .. 1 loop
|
||||||
command := 'create or replace view ' || dropviews[j] || ' as ' || viewtext[j];
|
command := 'create or replace view ' || dropviews[j] || ' as ' || viewtext[j];
|
||||||
|
raise notice 'executing -> %', 'create view ' || dropviews[j];
|
||||||
execute command;
|
execute command;
|
||||||
end loop;
|
end loop;
|
||||||
end if;
|
end if;
|
||||||
raise exception 'Failed to recreate dependent view';
|
raise exception 'Failed to recreate dependent view. SQLERRM=%', SQLERRM;
|
||||||
end;
|
end;
|
||||||
end if;
|
end if;
|
||||||
command := 'alter table ' || lower(tablename) || ' alter column ' || lower(columnname) || ' type ' || lower(datatype);
|
command := 'alter table ' || lower(tablename) || ' alter column ' || lower(columnname) || ' type ' || lower(datatype);
|
||||||
|
raise notice 'executing -> %', command;
|
||||||
execute command;
|
execute command;
|
||||||
i := array_upper(dropviews, 1);
|
i := array_upper(dropviews, 1);
|
||||||
if i > 0 then
|
if i > 0 then
|
||||||
for j in 1 .. i loop
|
for j in reverse i .. 1 loop
|
||||||
command := 'create or replace view ' || dropviews[j] || ' as ' || viewtext[j];
|
command := 'create or replace view ' || dropviews[j] || ' as ' || viewtext[j];
|
||||||
|
raise notice 'executing -> %', 'create view ' || dropviews[j];
|
||||||
execute command;
|
execute command;
|
||||||
end loop;
|
end loop;
|
||||||
end if;
|
end if;
|
||||||
|
@ -86,24 +102,29 @@ begin
|
||||||
else
|
else
|
||||||
command := 'alter table ' || lower(tablename) || ' alter column ' || lower(columnname) || ' set default ''' || defaultclause || '''';
|
command := 'alter table ' || lower(tablename) || ' alter column ' || lower(columnname) || ' set default ''' || defaultclause || '''';
|
||||||
end if;
|
end if;
|
||||||
|
raise notice 'executing -> %', command;
|
||||||
execute command;
|
execute command;
|
||||||
end if;
|
end if;
|
||||||
|
|
||||||
if nullclause is not null then
|
if nullclause is not null then
|
||||||
if lower(nullclause) = 'not null' then
|
if lower(nullclause) = 'not null' then
|
||||||
command := 'alter table ' || lower(tablename) || ' alter column ' || lower(columnname) || ' set not null';
|
command := 'alter table ' || lower(tablename) || ' alter column ' || lower(columnname) || ' set not null';
|
||||||
|
raise notice 'executing -> %', command;
|
||||||
execute command;
|
execute command;
|
||||||
elsif lower(nullclause) = 'null' then
|
elsif lower(nullclause) = 'null' then
|
||||||
command := 'alter table ' || lower(tablename) || ' alter column ' || lower(columnname) || ' drop not null';
|
command := 'alter table ' || lower(tablename) || ' alter column ' || lower(columnname) || ' drop not null';
|
||||||
|
raise notice 'executing -> %', command;
|
||||||
execute command;
|
execute command;
|
||||||
end if;
|
end if;
|
||||||
end if;
|
end if;
|
||||||
end;
|
end;
|
||||||
$$ language plpgsql;
|
$$ language plpgsql;
|
||||||
|
|
||||||
|
/*
|
||||||
create table t_alter_column
|
create table t_alter_column
|
||||||
( tablename name, columnname name, datatype name, nullclause varchar(10), defaultclause varchar(200));
|
( tablename name, columnname name, datatype name, nullclause varchar(10), defaultclause varchar(200));
|
||||||
|
|
||||||
create rule alter_column_rule as on insert to t_alter_column
|
create rule alter_column_rule as on insert to t_alter_column
|
||||||
do instead select altercolumn(new.tablename, new.columnname, new.datatype, new.nullclause,
|
do instead select altercolumn(new.tablename, new.columnname, new.datatype, new.nullclause,
|
||||||
new.defaultclause);
|
new.defaultclause);
|
||||||
|
*/
|
||||||
|
|
|
@ -38,3 +38,6 @@ INSERT INTO AD_Message (AD_Client_ID,AD_Message_ID,AD_Message_UU,AD_Org_ID,Creat
|
||||||
INSERT INTO AD_Message_Trl (AD_Language,AD_Message_ID, MsgText,MsgTip, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Message_Trl_UU ) SELECT l.AD_Language,t.AD_Message_ID, t.MsgText,t.MsgTip, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Message t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Message_ID=200138 AND NOT EXISTS (SELECT * FROM AD_Message_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Message_ID=t.AD_Message_ID)
|
INSERT INTO AD_Message_Trl (AD_Language,AD_Message_ID, MsgText,MsgTip, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Message_Trl_UU ) SELECT l.AD_Language,t.AD_Message_ID, t.MsgText,t.MsgTip, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Message t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Message_ID=200138 AND NOT EXISTS (SELECT * FROM AD_Message_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Message_ID=t.AD_Message_ID)
|
||||||
;
|
;
|
||||||
|
|
||||||
|
SELECT register_migration_script('2013012430719_IDEMPIERE-90.sql') FROM dual
|
||||||
|
;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
-- just for postgresql
|
||||||
|
SELECT register_migration_script('201302081954_IDEMPIERE-621_altercolumn.sql') FROM dual
|
||||||
|
;
|
||||||
|
|
|
@ -38,3 +38,6 @@ INSERT INTO AD_Message (AD_Client_ID,AD_Message_ID,AD_Message_UU,AD_Org_ID,Creat
|
||||||
INSERT INTO AD_Message_Trl (AD_Language,AD_Message_ID, MsgText,MsgTip, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Message_Trl_UU ) SELECT l.AD_Language,t.AD_Message_ID, t.MsgText,t.MsgTip, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Message t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Message_ID=200138 AND NOT EXISTS (SELECT * FROM AD_Message_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Message_ID=t.AD_Message_ID)
|
INSERT INTO AD_Message_Trl (AD_Language,AD_Message_ID, MsgText,MsgTip, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Message_Trl_UU ) SELECT l.AD_Language,t.AD_Message_ID, t.MsgText,t.MsgTip, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Message t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Message_ID=200138 AND NOT EXISTS (SELECT * FROM AD_Message_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Message_ID=t.AD_Message_ID)
|
||||||
;
|
;
|
||||||
|
|
||||||
|
SELECT register_migration_script('2013012430719_IDEMPIERE-90.sql') FROM dual
|
||||||
|
;
|
||||||
|
|
||||||
|
|
|
@ -14,13 +14,13 @@ declare
|
||||||
begin
|
begin
|
||||||
if datatype is not null then
|
if datatype is not null then
|
||||||
select pg_type.typname, format_type(pg_type.oid, pg_attribute.atttypmod)
|
select pg_type.typname, format_type(pg_type.oid, pg_attribute.atttypmod)
|
||||||
into typename, sqltype
|
into typename, sqltype
|
||||||
from pg_class, pg_attribute, pg_type
|
from pg_class, pg_attribute, pg_type
|
||||||
where relname = lower(tablename)
|
where relname = lower(tablename)
|
||||||
and relkind = 'r'
|
and relkind = 'r'
|
||||||
and pg_class.oid = pg_attribute.attrelid
|
and pg_class.oid = pg_attribute.attrelid
|
||||||
and attname = lower(columnname)
|
and attname = lower(columnname)
|
||||||
and atttypid = pg_type.oid;
|
and atttypid = pg_type.oid;
|
||||||
sqltype_short := sqltype;
|
sqltype_short := sqltype;
|
||||||
if typename = 'numeric' then
|
if typename = 'numeric' then
|
||||||
sqltype_short := replace(sqltype, ',0', '');
|
sqltype_short := replace(sqltype, ',0', '');
|
||||||
|
@ -31,28 +31,41 @@ begin
|
||||||
end if;
|
end if;
|
||||||
if lower(datatype) <> sqltype and lower(datatype) <> sqltype_short then
|
if lower(datatype) <> sqltype and lower(datatype) <> sqltype_short then
|
||||||
i := 0;
|
i := 0;
|
||||||
for v in select a.relname, a.oid
|
for v in
|
||||||
from pg_class a, pg_depend b, pg_depend c, pg_class d, pg_attribute e
|
with recursive depv(relname, viewoid, depth) as (
|
||||||
where a.oid = b.refobjid
|
select distinct a.relname, a.oid, 1
|
||||||
and b.objid = c.objid
|
from pg_class a, pg_depend b, pg_depend c, pg_class d, pg_attribute e
|
||||||
and b.refobjid <> c.refobjid
|
where a.oid = b.refobjid
|
||||||
and b.deptype = 'n'
|
and b.objid = c.objid
|
||||||
and c.refobjid = d.oid
|
and b.refobjid <> c.refobjid
|
||||||
and d.relname = lower(tablename)
|
and b.deptype = 'n'
|
||||||
and d.relkind = 'r'
|
and c.refobjid = d.oid
|
||||||
and d.oid = e.attrelid
|
and d.relname = lower(tablename)
|
||||||
and e.attname = lower(columnname)
|
and d.relkind = 'r'
|
||||||
and c.refobjsubid = e.attnum
|
and d.oid = e.attrelid
|
||||||
and a.relkind = 'v'
|
and e.attname = lower(columnname)
|
||||||
loop
|
and c.refobjsubid = e.attnum
|
||||||
|
and a.relkind = 'v'
|
||||||
|
union all
|
||||||
|
select distinct dependee.relname, dependee.oid, depv.depth+1
|
||||||
|
from pg_depend
|
||||||
|
join pg_rewrite on pg_depend.objid = pg_rewrite.oid
|
||||||
|
join pg_class as dependee on pg_rewrite.ev_class = dependee.oid
|
||||||
|
join pg_class as dependent on pg_depend.refobjid = dependent.oid
|
||||||
|
join pg_attribute ON pg_depend.refobjid = pg_attribute.attrelid and pg_depend.refobjsubid = pg_attribute.attnum and pg_attribute.attnum > 0
|
||||||
|
join depv on dependent.relname = depv.relname
|
||||||
|
)
|
||||||
|
select relname, viewoid, max(depth) from depv group by relname, viewoid order by 3 desc
|
||||||
|
loop
|
||||||
i := i + 1;
|
i := i + 1;
|
||||||
viewtext[i] := pg_get_viewdef(v.oid);
|
viewtext[i] := pg_get_viewdef(v.viewoid);
|
||||||
viewname[i] := v.relname;
|
viewname[i] := v.relname;
|
||||||
end loop;
|
end loop;
|
||||||
if i > 0 then
|
if i > 0 then
|
||||||
begin
|
begin
|
||||||
for j in 1 .. i loop
|
for j in 1 .. i loop
|
||||||
command := 'drop view ' || viewname[j];
|
command := 'drop view ' || viewname[j];
|
||||||
|
raise notice 'executing -> %', command;
|
||||||
execute command;
|
execute command;
|
||||||
dropviews[j] := viewname[j];
|
dropviews[j] := viewname[j];
|
||||||
end loop;
|
end loop;
|
||||||
|
@ -60,20 +73,23 @@ begin
|
||||||
when others then
|
when others then
|
||||||
i := array_upper(dropviews, 1);
|
i := array_upper(dropviews, 1);
|
||||||
if i > 0 then
|
if i > 0 then
|
||||||
for j in 1 .. i loop
|
for j in reverse i .. 1 loop
|
||||||
command := 'create or replace view ' || dropviews[j] || ' as ' || viewtext[j];
|
command := 'create or replace view ' || dropviews[j] || ' as ' || viewtext[j];
|
||||||
|
raise notice 'executing -> %', 'create view ' || dropviews[j];
|
||||||
execute command;
|
execute command;
|
||||||
end loop;
|
end loop;
|
||||||
end if;
|
end if;
|
||||||
raise exception 'Failed to recreate dependent view';
|
raise exception 'Failed to recreate dependent view. SQLERRM=%', SQLERRM;
|
||||||
end;
|
end;
|
||||||
end if;
|
end if;
|
||||||
command := 'alter table ' || lower(tablename) || ' alter column ' || lower(columnname) || ' type ' || lower(datatype);
|
command := 'alter table ' || lower(tablename) || ' alter column ' || lower(columnname) || ' type ' || lower(datatype);
|
||||||
|
raise notice 'executing -> %', command;
|
||||||
execute command;
|
execute command;
|
||||||
i := array_upper(dropviews, 1);
|
i := array_upper(dropviews, 1);
|
||||||
if i > 0 then
|
if i > 0 then
|
||||||
for j in 1 .. i loop
|
for j in reverse i .. 1 loop
|
||||||
command := 'create or replace view ' || dropviews[j] || ' as ' || viewtext[j];
|
command := 'create or replace view ' || dropviews[j] || ' as ' || viewtext[j];
|
||||||
|
raise notice 'executing -> %', 'create view ' || dropviews[j];
|
||||||
execute command;
|
execute command;
|
||||||
end loop;
|
end loop;
|
||||||
end if;
|
end if;
|
||||||
|
@ -86,26 +102,24 @@ begin
|
||||||
else
|
else
|
||||||
command := 'alter table ' || lower(tablename) || ' alter column ' || lower(columnname) || ' set default ''' || defaultclause || '''';
|
command := 'alter table ' || lower(tablename) || ' alter column ' || lower(columnname) || ' set default ''' || defaultclause || '''';
|
||||||
end if;
|
end if;
|
||||||
|
raise notice 'executing -> %', command;
|
||||||
execute command;
|
execute command;
|
||||||
end if;
|
end if;
|
||||||
|
|
||||||
if nullclause is not null then
|
if nullclause is not null then
|
||||||
if lower(nullclause) = 'not null' then
|
if lower(nullclause) = 'not null' then
|
||||||
command := 'alter table ' || lower(tablename) || ' alter column ' || lower(columnname) || ' set not null';
|
command := 'alter table ' || lower(tablename) || ' alter column ' || lower(columnname) || ' set not null';
|
||||||
|
raise notice 'executing -> %', command;
|
||||||
execute command;
|
execute command;
|
||||||
elsif lower(nullclause) = 'null' then
|
elsif lower(nullclause) = 'null' then
|
||||||
command := 'alter table ' || lower(tablename) || ' alter column ' || lower(columnname) || ' drop not null';
|
command := 'alter table ' || lower(tablename) || ' alter column ' || lower(columnname) || ' drop not null';
|
||||||
|
raise notice 'executing -> %', command;
|
||||||
execute command;
|
execute command;
|
||||||
end if;
|
end if;
|
||||||
end if;
|
end if;
|
||||||
end;
|
end;
|
||||||
$$ language plpgsql;
|
$$ language plpgsql;
|
||||||
|
|
||||||
/*
|
SELECT register_migration_script('201302081954_IDEMPIERE-621_altercolumn.sql') FROM dual
|
||||||
create table t_alter_column
|
;
|
||||||
( tablename name, columnname name, datatype name, nullclause varchar(10), defaultclause varchar(200));
|
|
||||||
|
|
||||||
create rule alter_column_rule as on insert to t_alter_column
|
|
||||||
do instead select altercolumn(new.tablename, new.columnname, new.datatype, new.nullclause,
|
|
||||||
new.defaultclause);
|
|
||||||
*/
|
|
|
@ -349,8 +349,7 @@ ORDER BY UPPER (columnname), columnname;
|
||||||
UPDATE AD_PROCESS_PARA
|
UPDATE AD_PROCESS_PARA
|
||||||
SET columnname = (SELECT e.columnname
|
SET columnname = (SELECT e.columnname
|
||||||
FROM AD_ELEMENT e
|
FROM AD_ELEMENT e
|
||||||
-- WHERE UPPER (e.columnname) = UPPER (AD_PROCESS_PARA.columnname))
|
WHERE UPPER (e.columnname) = UPPER (AD_PROCESS_PARA.columnname))
|
||||||
WHERE e.columnname = AD_PROCESS_PARA.columnname) -- Temporary patch Fixed Assets are broking it
|
|
||||||
WHERE AD_PROCESS_PARA.iscentrallymaintained = 'Y'
|
WHERE AD_PROCESS_PARA.iscentrallymaintained = 'Y'
|
||||||
AND AD_PROCESS_PARA.isactive = 'Y'
|
AND AD_PROCESS_PARA.isactive = 'Y'
|
||||||
AND EXISTS (
|
AND EXISTS (
|
||||||
|
|
|
@ -104,30 +104,23 @@ public class MTable extends X_AD_Table
|
||||||
MTable retValue = null;
|
MTable retValue = null;
|
||||||
String sql = "SELECT * FROM AD_Table WHERE UPPER(TableName)=?";
|
String sql = "SELECT * FROM AD_Table WHERE UPPER(TableName)=?";
|
||||||
PreparedStatement pstmt = null;
|
PreparedStatement pstmt = null;
|
||||||
|
ResultSet rs = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
pstmt = DB.prepareStatement (sql, null);
|
pstmt = DB.prepareStatement (sql, null);
|
||||||
pstmt.setString(1, tableName.toUpperCase());
|
pstmt.setString(1, tableName.toUpperCase());
|
||||||
ResultSet rs = pstmt.executeQuery ();
|
rs = pstmt.executeQuery ();
|
||||||
if (rs.next ())
|
if (rs.next())
|
||||||
retValue = new MTable (ctx, rs, null);
|
retValue = new MTable (ctx, rs, null);
|
||||||
rs.close ();
|
|
||||||
pstmt.close ();
|
|
||||||
pstmt = null;
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
s_log.log(Level.SEVERE, sql, e);
|
s_log.log(Level.SEVERE, sql, e);
|
||||||
}
|
}
|
||||||
try
|
finally
|
||||||
{
|
{
|
||||||
if (pstmt != null)
|
DB.close(rs, pstmt);
|
||||||
pstmt.close ();
|
rs = null; pstmt = null;
|
||||||
pstmt = null;
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
pstmt = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (retValue != null)
|
if (retValue != null)
|
||||||
|
@ -229,37 +222,30 @@ public class MTable extends X_AD_Table
|
||||||
return m_columns;
|
return m_columns;
|
||||||
m_columnNameMap = new HashMap<String, Integer>();
|
m_columnNameMap = new HashMap<String, Integer>();
|
||||||
m_columnIdMap = new HashMap<Integer, Integer>();
|
m_columnIdMap = new HashMap<Integer, Integer>();
|
||||||
String sql = "SELECT * FROM AD_Column WHERE AD_Table_ID=? ORDER BY ColumnName";
|
String sql = "SELECT * FROM AD_Column WHERE AD_Table_ID=? AND IsActive='Y' ORDER BY ColumnName";
|
||||||
ArrayList<MColumn> list = new ArrayList<MColumn>();
|
ArrayList<MColumn> list = new ArrayList<MColumn>();
|
||||||
PreparedStatement pstmt = null;
|
PreparedStatement pstmt = null;
|
||||||
|
ResultSet rs = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
pstmt = DB.prepareStatement (sql, get_TrxName());
|
pstmt = DB.prepareStatement (sql, get_TrxName());
|
||||||
pstmt.setInt (1, getAD_Table_ID());
|
pstmt.setInt (1, getAD_Table_ID());
|
||||||
ResultSet rs = pstmt.executeQuery ();
|
rs = pstmt.executeQuery ();
|
||||||
while (rs.next ()) {
|
while (rs.next ()) {
|
||||||
MColumn column = new MColumn (getCtx(), rs, get_TrxName());
|
MColumn column = new MColumn (getCtx(), rs, get_TrxName());
|
||||||
list.add (column);
|
list.add (column);
|
||||||
m_columnNameMap.put(column.getColumnName().toUpperCase(), list.size() - 1);
|
m_columnNameMap.put(column.getColumnName().toUpperCase(), list.size() - 1);
|
||||||
m_columnIdMap.put(column.getAD_Column_ID(), list.size() - 1);
|
m_columnIdMap.put(column.getAD_Column_ID(), list.size() - 1);
|
||||||
}
|
}
|
||||||
rs.close ();
|
|
||||||
pstmt.close ();
|
|
||||||
pstmt = null;
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
log.log(Level.SEVERE, sql, e);
|
log.log(Level.SEVERE, sql, e);
|
||||||
}
|
}
|
||||||
try
|
finally
|
||||||
{
|
{
|
||||||
if (pstmt != null)
|
DB.close(rs, pstmt);
|
||||||
pstmt.close ();
|
rs = null; pstmt = null;
|
||||||
pstmt = null;
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
pstmt = null;
|
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
m_columns = new MColumn[list.size ()];
|
m_columns = new MColumn[list.size ()];
|
||||||
|
@ -476,6 +462,7 @@ public class MTable extends X_AD_Table
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
DB.close(rs, pstmt);
|
DB.close(rs, pstmt);
|
||||||
|
rs = null; pstmt = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return po;
|
return po;
|
||||||
|
@ -581,21 +568,26 @@ public class MTable extends X_AD_Table
|
||||||
public static int getTable_ID(String tableName) {
|
public static int getTable_ID(String tableName) {
|
||||||
int retValue = 0;
|
int retValue = 0;
|
||||||
String SQL = "SELECT AD_Table_ID FROM AD_Table WHERE tablename = ?";
|
String SQL = "SELECT AD_Table_ID FROM AD_Table WHERE tablename = ?";
|
||||||
|
PreparedStatement pstmt = null;
|
||||||
|
ResultSet rs = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
PreparedStatement pstmt = DB.prepareStatement(SQL, null);
|
pstmt = DB.prepareStatement(SQL, null);
|
||||||
pstmt.setString(1, tableName);
|
pstmt.setString(1, tableName);
|
||||||
ResultSet rs = pstmt.executeQuery();
|
rs = pstmt.executeQuery();
|
||||||
if (rs.next())
|
if (rs.next())
|
||||||
retValue = rs.getInt(1);
|
retValue = rs.getInt(1);
|
||||||
rs.close();
|
|
||||||
pstmt.close();
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
s_log.log(Level.SEVERE, SQL, e);
|
s_log.log(Level.SEVERE, SQL, e);
|
||||||
retValue = -1;
|
retValue = -1;
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
DB.close(rs, pstmt);
|
||||||
|
rs = null; pstmt = null;
|
||||||
|
}
|
||||||
return retValue;
|
return retValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue