Difference between revisions of "Queries: AD"

From iDempiere en
(Sessions run during the actual year)
m (Ngordon7000 moved page Code Scratchpad: Queries: AD to Queries: AD)
 
(One intermediate revision by one other user not shown)
Line 5: Line 5:
 
= Client =
 
= Client =
  
−
  <nowiki>select ad_client_id,value,name from ad_client order by ad_client_id;
+
  <syntaxhighlight lang="sql">select ad_client_id,value,name from ad_client order by ad_client_id;
  
 
select ad_client_id from ad_client where name like 'A%';  
 
select ad_client_id from ad_client where name like 'A%';  
−
</nowiki>
+
</syntaxhighlight>
  
 
= Windows =
 
= Windows =
 
== Windows referencing a specific process ==
 
== Windows referencing a specific process ==
−
  <nowiki>select name from ad_window where ad_window_id in (
+
  <syntaxhighlight lang="sql">select name from ad_window where ad_window_id in (
 
select ad_window_id from ad_tab where ad_process_id in (
 
select ad_window_id from ad_tab where ad_process_id in (
 
select ad_process_id from ad_process where value = 'processname')
 
select ad_process_id from ad_process where value = 'processname')
−
);</nowiki>
+
);</syntaxhighlight>
  
 
== Window ==
 
== Window ==
−
  <nowiki>select * from ad_window a
+
  <syntaxhighlight lang="sql">select * from ad_window a
−
where a.ad_window_id=id</nowiki>
+
where a.ad_window_id=id</syntaxhighlight>
  
 
== Tab ==
 
== Tab ==
−
  <nowiki>select * from ad_tab a
+
  <syntaxhighlight lang="sql">select * from ad_tab a
 
where a.ad_window_id=id
 
where a.ad_window_id=id
  
−
select distinct a.whereclause from ad_tab a </nowiki>
+
select distinct a.whereclause from ad_tab a </syntaxhighlight>
  
−
  <nowiki>select b.name as WindowName from ad_tab a
+
  <syntaxhighlight lang="sql">select b.name as WindowName from ad_tab a
 
join ad_window b on a.ad_window_id = b.ad_window_id
 
join ad_window b on a.ad_window_id = b.ad_window_id
 
where  
 
where  
 
a.ad_table_id =  
 
a.ad_table_id =  
−
(select ad_table_id from ad_table where name='tablename');</nowiki>
+
(select ad_table_id from ad_table where name='tablename');</syntaxhighlight>
  
 
= Field information =
 
= Field information =
  
 
== Field ==
 
== Field ==
−
  <nowiki>select a.* from ad_field a
+
  <syntaxhighlight lang="sql">select a.* from ad_field a
 
join ad_tab b on a.ad_tab_id=b.ad_tab_id
 
join ad_tab b on a.ad_tab_id=b.ad_tab_id
−
where b.ad_window_id=id</nowiki>
+
where b.ad_window_id=id</syntaxhighlight>
  
 
== Combining Window, tab, field ==
 
== Combining Window, tab, field ==
Line 44: Line 44:
 
=== As a view ===
 
=== As a view ===
  
−
  <nowiki>drop view if exists zz_fieldinfo_v;
+
  <syntaxhighlight lang="sql">drop view if exists zz_fieldinfo_v;
  
 
create view zz_fieldinfo_v as
 
create view zz_fieldinfo_v as
Line 88: Line 88:
  
 
select field_display_name, field_ismandatory, field_mandatorylogic from zz_fieldinfo_v where windowname like  'C%' and field_mandatorylogic is not null;
 
select field_display_name, field_ismandatory, field_mandatorylogic from zz_fieldinfo_v where windowname like  'C%' and field_mandatorylogic is not null;
−
</nowiki>
+
</syntaxhighlight>
  
 
== Show fields by update date (useful to run after loading 2pack) ==
 
== Show fields by update date (useful to run after loading 2pack) ==
  
−
  <nowiki>select column_updated, column_name, * from zz_fieldinfo_v order by column_updated desc;</nowiki>
+
  <syntaxhighlight lang="sql">select column_updated, column_name, * from zz_fieldinfo_v order by column_updated desc;</syntaxhighlight>
  
 
= Form =
 
= Form =
  
−
  <nowiki>select a.entitytype, a.name, a.classname from ad_form a where a.entitytype='U' order by classname;</nowiki>
+
  <syntaxhighlight lang="sql">select a.entitytype, a.name, a.classname from ad_form a where a.entitytype='U' order by classname;</syntaxhighlight>
  
 
= Table =
 
= Table =
 
== Table ==
 
== Table ==
−
  <nowiki>select a.* from ad_table a
+
  <syntaxhighlight lang="sql">select a.* from ad_table a
 
order by a.created desc;
 
order by a.created desc;
  
Line 109: Line 109:
  
 
delete from ad_table where ad_table_id in (select ad_table_id from ad_table where tablename='tablename');
 
delete from ad_table where ad_table_id in (select ad_table_id from ad_table where tablename='tablename');
−
</nowiki>
+
</syntaxhighlight>
  
 
= Table Columns =
 
= Table Columns =
  
−
  <nowiki>select a.name, a.columnname, a.created from ad_column a
+
  <syntaxhighlight lang="sql">select a.name, a.columnname, a.created from ad_column a
 
join ad_element b on a.ad_element_id=b.ad_element_id
 
join ad_element b on a.ad_element_id=b.ad_element_id
 
where a.ad_table_id in ((select ad_table_id from ad_table where tablename='tablename'))
 
where a.ad_table_id in ((select ad_table_id from ad_table where tablename='tablename'))
 
order by a.name;
 
order by a.name;
 
--order by a.created desc;
 
--order by a.created desc;
−
</nowiki>
+
</syntaxhighlight>
  
 
= Menu =
 
= Menu =
Line 130: Line 130:
 
== Update entity type ==
 
== Update entity type ==
  
−
  <nowiki>update ad_column set entitytype='U' where ad_column_id=3510;
+
  <syntaxhighlight lang="sql">update ad_column set entitytype='U' where ad_column_id=3510;
−
</nowiki>
+
</syntaxhighlight>
  
 
= Callout =
 
= Callout =
−
  <nowiki>select a.ad_column_id,tbl.tablename, a.columnname,a.name, a.callout from ad_column a
+
  <syntaxhighlight lang="sql">select a.ad_column_id,tbl.tablename, a.columnname,a.name, a.callout from ad_column a
 
join ad_table tbl on a.ad_table_id = tbl.ad_table_id
 
join ad_table tbl on a.ad_table_id = tbl.ad_table_id
 
where a.callout is not null and a.callout like '%bPartner%'
 
where a.callout is not null and a.callout like '%bPartner%'
 
--and tbl.tablename = 'C_BankStatementLine'
 
--and tbl.tablename = 'C_BankStatementLine'
 
order by tbl.tablename, a.callout, a.name;
 
order by tbl.tablename, a.callout, a.name;
−
--order by a.updated desc;</nowiki>
+
--order by a.updated desc;</syntaxhighlight>
  
 
== Update callout ==
 
== Update callout ==
  
−
  <nowiki>update ad_column set callout = 'org.compiere.model.CalloutInvoiceNew.bPartner' where ad_column_id = 3499;</nowiki>
+
  <syntaxhighlight lang="sql">update ad_column set callout = 'org.compiere.model.CalloutInvoiceNew.bPartner' where ad_column_id = 3499;</syntaxhighlight>
  
 
= References =
 
= References =
−
  <nowiki>select * from ad_ref_list where ad_reference_id in ( select ad_reference_id from ad_reference where name = 'Ref Name' );
+
  <syntaxhighlight lang="sql">select * from ad_ref_list where ad_reference_id in ( select ad_reference_id from ad_reference where name = 'Ref Name' );
 
-
 
-
 
Incomplete:
 
Incomplete:
Line 152: Line 152:
 
ad_reference ref on ref.name = 'ZZ_Status'
 
ad_reference ref on ref.name = 'ZZ_Status'
 
left join
 
left join
−
ad_ref_list reflist on reflist.ad_reference_id = ref.ad_reference_id and reflist.value = perm.zz_status</nowiki>
+
ad_ref_list reflist on reflist.ad_reference_id = ref.ad_reference_id and reflist.value = perm.zz_status</syntaxhighlight>
  
 
== For use in Jasper Report to lookup reference name ==
 
== For use in Jasper Report to lookup reference name ==
  
−
  <nowiki>( SELECT rl.name FROM ad_ref_list rl WHERE ((rl.ad_reference_id = (select ad_reference_id from ad_reference where name = 'my ref name')::numeric) AND ((rl.value)::text = (v.ice_fuel_type)::text))) AS field_name</nowiki>
+
  <syntaxhighlight lang="sql">( SELECT rl.name FROM ad_ref_list rl WHERE ((rl.ad_reference_id = (select ad_reference_id from ad_reference where name = 'my ref name')::numeric) AND ((rl.value)::text = (v.ice_fuel_type)::text))) AS field_name</syntaxhighlight>
  
 
== Validation Rules ==
 
== Validation Rules ==
  
−
  <nowiki>select ad_val_rule_id, name, code from ad_val_rule where upper(code) like upper('%quota%');</nowiki>
+
  <syntaxhighlight lang="sql">select ad_val_rule_id, name, code from ad_val_rule where upper(code) like upper('%quota%');</syntaxhighlight>
  
 
= Elements =
 
= Elements =
−
  <nowiki>select b.* from ad_column a
+
  <syntaxhighlight lang="sql">select b.* from ad_column a
 
join ad_element b on a.ad_element_id=b.ad_element_id
 
join ad_element b on a.ad_element_id=b.ad_element_id
−
where a.ad_table_id in (1000153, 1000152, 1000154, 1000156)</nowiki>
+
where a.ad_table_id in (1000153, 1000152, 1000154, 1000156)</syntaxhighlight>
  
 
= Report and process =
 
= Report and process =
−
  <nowiki>select * from ad_process order by created desc;
+
  <syntaxhighlight lang="sql">select * from ad_process order by created desc;
  
  
Line 177: Line 177:
 
select columnname, name, defaultvalue from ad_process_para where ad_process_id = 1000000 order by seqno;
 
select columnname, name, defaultvalue from ad_process_para where ad_process_id = 1000000 order by seqno;
  
−
update ad_process_para set defaultvalue='1' where ad_process_id = 1000000 and columnname = 'columname'; --Sequence</nowiki>
+
update ad_process_para set defaultvalue='1' where ad_process_id = 1000000 and columnname = 'columname'; --Sequence</syntaxhighlight>
  
 
= Deletion =
 
= Deletion =
 
== Delete all fields on window ==
 
== Delete all fields on window ==
−
  <nowiki>delete from ad_field where ad_tab_id in ( select ad_tab_id from ad_tab where ad_window_id in  
+
  <syntaxhighlight lang="sql">delete from ad_field where ad_tab_id in ( select ad_tab_id from ad_tab where ad_window_id in  
 
(
 
(
 
select ad_window_id from ad_window where name like 'Name of window'  
 
select ad_window_id from ad_window where name like 'Name of window'  
−
) );</nowiki>
+
) );</syntaxhighlight>
  
 
== Delete all fields on tab ==
 
== Delete all fields on tab ==
 
   
 
   
−
  <nowiki>1.  
+
  <syntaxhighlight lang="sql">1.  
  
 
delete from ad_field where ad_tab_id in ( select ad_tab_id from ad_tab where name = 'tabname' and ad_window_id in  
 
delete from ad_field where ad_tab_id in ( select ad_tab_id from ad_tab where name = 'tabname' and ad_window_id in  
Line 206: Line 206:
 
delete from ad_field where ad_tab_id in ( select ad_tab_id from ad_tab where ad_tab_uu in ( 'REPLACEWITHWINDOWUUHERE' ) );
 
delete from ad_field where ad_tab_id in ( select ad_tab_id from ad_tab where ad_tab_uu in ( 'REPLACEWITHWINDOWUUHERE' ) );
  
−
</nowiki>
+
</syntaxhighlight>
  
 
== Delete all occurences of column from windows ==
 
== Delete all occurences of column from windows ==
  
−
  <nowiki>delete from ad_field where ad_column_id in  
+
  <syntaxhighlight lang="sql">delete from ad_field where ad_column_id in  
−
( select ad_column_id from ad_column where upper(columnname) like upper('zz_nbsm_matchsetup_id') )</nowiki>
+
( select ad_column_id from ad_column where upper(columnname) like upper('zz_nbsm_matchsetup_id') )</syntaxhighlight>
  
 
== Delete index definitions on table ==
 
== Delete index definitions on table ==
Line 217: Line 217:
 
* NB: Indexes not dropped automatically
 
* NB: Indexes not dropped automatically
  
−
  <nowiki>delete from ad_indexcolumn where AD_TableIndex_ID in (select ad_tableindex_id from ad_tableindex where ad_table_id = 318);
+
  <syntaxhighlight lang="sql">delete from ad_indexcolumn where AD_TableIndex_ID in (select ad_tableindex_id from ad_tableindex where ad_table_id = 318);
  
−
delete from AD_TableIndex where ad_table_id = 318;</nowiki>
+
delete from AD_TableIndex where ad_table_id = 318;</syntaxhighlight>
  
 
= Sequences =
 
= Sequences =
−
  <nowiki>update ad_sequence a set CURRENTNEXTSYS =13000  where a.name = 'name';</nowiki>
+
  <syntaxhighlight lang="sql">update ad_sequence a set CURRENTNEXTSYS =13000  where a.name = 'name';</syntaxhighlight>
  
 
= Doctype =
 
= Doctype =
  
−
  <nowiki>select c_doctype_id from c_doctype where name = 'DocumentName'</nowiki>
+
  <syntaxhighlight lang="sql">select c_doctype_id from c_doctype where name = 'DocumentName'</syntaxhighlight>
  
 
= Attachments =
 
= Attachments =
Line 232: Line 232:
 
== All pack-in attachments ==
 
== All pack-in attachments ==
  
−
  <nowiki>select * from ad_attachment where ad_table_id = 50008 and record_id in (
+
  <syntaxhighlight lang="sql">select * from ad_attachment where ad_table_id = 50008 and record_id in (
 
   select AD_Package_Imp_Proc_id from AD_Package_Imp_Proc where name like '%%'  
 
   select AD_Package_Imp_Proc_id from AD_Package_Imp_Proc where name like '%%'  
−
   );</nowiki>
+
   );</syntaxhighlight>
  
 
= Synchronize Translations =
 
= Synchronize Translations =
Line 240: Line 240:
 
An example:
 
An example:
  
−
  <nowiki>update ad_process_trl a set name = b.name, description = b.name from ad_process b where a.ad_process_id = b.ad_process_id and b.name = 'Process Name';</nowiki>
+
  <syntaxhighlight lang="sql">update ad_process_trl a set name = b.name, description = b.name from ad_process b where a.ad_process_id = b.ad_process_id and b.name = 'Process Name';</syntaxhighlight>
  
 
= Translations =
 
= Translations =
Line 246: Line 246:
 
== Various helpers (work in progress) ==
 
== Various helpers (work in progress) ==
  
−
  <nowiki>select ad_message_id, value, msgtext, msgtip from ad_message where upper(msgtext) like upper('%login%') order by msgtext;
+
  <syntaxhighlight lang="sql">select ad_message_id, value, msgtext, msgtip from ad_message where upper(msgtext) like upper('%login%') order by msgtext;
  
 
drop view if exists zz_trl_helper_field_v;
 
drop view if exists zz_trl_helper_field_v;
Line 306: Line 306:
 
ad_menu_trl.ad_menu_id = b.ad_menu_id
 
ad_menu_trl.ad_menu_id = b.ad_menu_id
 
and b.ad_menu_uu = 'ccf0fc37-76cc-4a3c-8e1c-80d4c28e695a';
 
and b.ad_menu_uu = 'ccf0fc37-76cc-4a3c-8e1c-80d4c28e695a';
−
</nowiki>
+
</syntaxhighlight>
  
 
= Pack out =
 
= Pack out =
Line 312: Line 312:
 
== Backup AD information before running 2pack ==
 
== Backup AD information before running 2pack ==
  
−
  <nowiki>select * into bk_rq16_process from ad_process;
+
  <syntaxhighlight lang="sql">select * into bk_rq16_process from ad_process;
  
 
select * into bk_rq16_table from ad_table;
 
select * into bk_rq16_table from ad_table;
Line 328: Line 328:
 
select * into bk_rq16_ref_table from ad_ref_table;
 
select * into bk_rq16_ref_table from ad_ref_table;
  
−
select * into bk_rq16_ref_list from ad_ref_list;</nowiki>
+
select * into bk_rq16_ref_list from ad_ref_list;</syntaxhighlight>
  
 
== Delete all fields + tabs on windows (for Pack In) ==
 
== Delete all fields + tabs on windows (for Pack In) ==
Line 334: Line 334:
 
* Helps to ensure is packed in correctly
 
* Helps to ensure is packed in correctly
  
−
  <nowiki>delete from ad_tab_customization where ad_tab_id in ( select ad_tab_id from ad_tab where ad_window_id in  
+
  <syntaxhighlight lang="sql">delete from ad_tab_customization where ad_tab_id in ( select ad_tab_id from ad_tab where ad_window_id in  
 
(
 
(
 
select ad_window_id from ad_window where name in ( 'nameOfWindow' )  
 
select ad_window_id from ad_window where name in ( 'nameOfWindow' )  
 
));
 
));
  
−
) );</nowiki>
+
) );</syntaxhighlight>
  
 
* See also under the heading: 'Deletion'
 
* See also under the heading: 'Deletion'
Line 345: Line 345:
 
== Packout/Packin package details ==
 
== Packout/Packin package details ==
  
−
  <nowiki>select  
+
  <syntaxhighlight lang="sql">select  
 
hdr.name, det.created, det.updated, det.ad_package_exp_id, det.AD_Package_Exp_Detail_id, det.line, det.description, det.dbtype, det.sqlstatement, det.ad_table_id, tbl.tablename
 
hdr.name, det.created, det.updated, det.ad_package_exp_id, det.AD_Package_Exp_Detail_id, det.line, det.description, det.dbtype, det.sqlstatement, det.ad_table_id, tbl.tablename
 
from  
 
from  
Line 374: Line 374:
 
left join ad_table tbl on tbl.ad_table_id = det.ad_table_id;
 
left join ad_table tbl on tbl.ad_table_id = det.ad_table_id;
  
−
</nowiki>
+
</syntaxhighlight>
  
 
== Duplicate key error when importing AD_Message ==
 
== Duplicate key error when importing AD_Message ==
Line 380: Line 380:
 
* unique constraint (...AD_MESSAGE_TRL_KEY) violated
 
* unique constraint (...AD_MESSAGE_TRL_KEY) violated
  
−
  <nowiki>delete from ad_message_trl
+
  <syntaxhighlight lang="sql">delete from ad_message_trl
 
WHERE AD_Message_ID=
 
WHERE AD_Message_ID=
−
( SELECT ad_message_id FROM ad_message WHERE value='KEYOFMESSAGE' );</nowiki>
+
( SELECT ad_message_id FROM ad_message WHERE value='KEYOFMESSAGE' );</syntaxhighlight>
  
 
== Pack in/out helpers ==
 
== Pack in/out helpers ==
Line 388: Line 388:
 
=== Delete all fields on a window/tab ===
 
=== Delete all fields on a window/tab ===
 
   
 
   
−
  <nowiki>delete from ad_tab where ad_tab_id in ( select ad_tab_id from ad_tab where ad_window_id in  
+
  <syntaxhighlight lang="sql">delete from ad_tab where ad_tab_id in ( select ad_tab_id from ad_tab where ad_window_id in  
 
(
 
(
 
select ad_window_id from ad_window where ad_window_uu in ( 'REPLACEWITHWINDOWUUHERE' )  
 
select ad_window_id from ad_window where ad_window_uu in ( 'REPLACEWITHWINDOWUUHERE' )  
−
) );</nowiki>
+
) );</syntaxhighlight>
  
 
=== Delete all ad_userquery of window/tab process ===
 
=== Delete all ad_userquery of window/tab process ===
  
−
  <nowiki>delete from ad_userquery where ad_tab_id in ( select ad_tab_id from ad_tab where ad_window_id in  
+
  <syntaxhighlight lang="sql">delete from ad_userquery where ad_tab_id in ( select ad_tab_id from ad_tab where ad_window_id in  
 
(
 
(
 
select ad_window_id from ad_window where ad_window_uu in ( 'REPLACEWITHWINDOWUUHERE')  
 
select ad_window_id from ad_window where ad_window_uu in ( 'REPLACEWITHWINDOWUUHERE')  
−
));</nowiki>
+
));</syntaxhighlight>
  
 
=== Delete all ad_customization of window/tab ===
 
=== Delete all ad_customization of window/tab ===
  
−
  <nowiki>delete from ad_tab_customization where ad_tab_id in ( select ad_tab_id from ad_tab where ad_window_id in  
+
  <syntaxhighlight lang="sql">delete from ad_tab_customization where ad_tab_id in ( select ad_tab_id from ad_tab where ad_window_id in  
 
(
 
(
 
select ad_window_id from ad_window where ad_window_uu in ( 'REPLACEWITHWINDOWUUHERE')  
 
select ad_window_id from ad_window where ad_window_uu in ( 'REPLACEWITHWINDOWUUHERE')  
−
));</nowiki>
+
));</syntaxhighlight>
  
 
=== Delete all attachments of process ===
 
=== Delete all attachments of process ===
  
−
  <nowiki>delete from ad_attachment where record_id in (
+
  <syntaxhighlight lang="sql">delete from ad_attachment where record_id in (
 
select ad_process_id from ad_process where value like '%MYPROCESSKEY%' ) and  
 
select ad_process_id from ad_process where value like '%MYPROCESSKEY%' ) and  
−
ad_table_id = (select ad_table_id from ad_table where tablename='AD_Process');</nowiki>
+
ad_table_id = (select ad_table_id from ad_table where tablename='AD_Process');</syntaxhighlight>
  
 
= Migration scripts =
 
= Migration scripts =
Line 417: Line 417:
 
== Which migration scripts have been run ==
 
== Which migration scripts have been run ==
  
−
  <nowiki>select releaseno,created,name,status,isapply,filename, script  from ad_migrationscript order by releaseno, name;</nowiki>
+
  <syntaxhighlight lang="sql">select releaseno,created,name,status,isapply,filename, script  from ad_migrationscript order by releaseno, name;</syntaxhighlight>
  
 
= Session =
 
= Session =

Latest revision as of 07:54, 28 July 2021


Client

select ad_client_id,value,name from ad_client order by ad_client_id;

select ad_client_id from ad_client where name like 'A%';

Windows

Windows referencing a specific process

select name from ad_window where ad_window_id in (
select ad_window_id from ad_tab where ad_process_id in (
select ad_process_id from ad_process where value = 'processname')
);

Window

select * from ad_window a
where a.ad_window_id=id

Tab

select * from ad_tab a
where a.ad_window_id=id

select distinct a.whereclause from ad_tab a
select b.name as WindowName from ad_tab a
join ad_window b on a.ad_window_id = b.ad_window_id
where 
	a.ad_table_id = 
	(select ad_table_id from ad_table where name='tablename');

Field information

Field

select a.* from ad_field a
join ad_tab b on a.ad_tab_id=b.ad_tab_id
where b.ad_window_id=id

Combining Window, tab, field

As a view

drop view if exists zz_fieldinfo_v;

create view zz_fieldinfo_v as
select 
	tabtable.tablename as table_name, 
	tabtable.entitytype as table_entitytype,
  	fld.isdisplayed as field_isdisplayed,
  	fld.seqno as field_seqno,
  	fld.name as field_name, 
	col.columnname as column_name,
  	fld.displaylogic as field_display_logic,
	fld.readonlylogic as field_readonly_logic,
	tab.name as tab_name,
	win.name as WindowName, 
	win.ad_window_id,
	tab.ad_tab_id,
  	tab.isactive as tab_isactive,
  	fld.ad_field_uu,
	fld.ad_field_id,
	fld.iscentrallymaintained as field_centrallymaintained,
	fld.ismandatory as field_ismandatory,
	fld.mandatorylogic as field_mandatorylogic,
	col.ad_element_id,
	ele.name as element_name,
	ref.name as ref_name, refvalue.name as ref_value,
	refvalue.ad_reference_id,
	reftabletbl.tablename as ref_table,
	col.created as column_created, col.updated as column_updated,
	fld.created as field_created, fld.updated as field_updated,
	fld.ad_val_rule_id as field_val_rule_id
from 
	ad_field fld
join ad_tab tab on fld.ad_tab_id = tab.ad_tab_id
join ad_table tabtable on tabtable.ad_table_id = tab.ad_table_id
join ad_window win on tab.ad_window_id = win.ad_window_id
join ad_column col on fld.ad_column_id = col.ad_column_id
join ad_element ele on ele.ad_element_id = col.ad_element_id
left join ad_reference ref on col.ad_reference_id = ref.ad_reference_id
left join ad_reference refvalue on col.ad_reference_value_id = refvalue.ad_reference_id
left join ad_ref_table reftable on reftable.ad_reference_id = refvalue.ad_reference_id
left join ad_table reftabletbl on reftabletbl.ad_table_id = reftable.ad_table_id
order by win.name, tab.seqno, field_seqno;

select field_display_name, field_ismandatory, field_mandatorylogic from zz_fieldinfo_v where windowname like  'C%' and field_mandatorylogic is not null;

Show fields by update date (useful to run after loading 2pack)

select column_updated, column_name, * from zz_fieldinfo_v order by column_updated desc;

Form

select a.entitytype, a.name, a.classname from ad_form a where a.entitytype='U' order by classname;

Table

Table

select a.* from ad_table a
order by a.created desc;

select a.* from ad_table a
where a.ad_table_id in (id, id)

(select ad_table_id from ad_table where tablename='tablename')

delete from ad_table where ad_table_id in (select ad_table_id from ad_table where tablename='tablename');

Table Columns

select a.name, a.columnname, a.created from ad_column a
join ad_element b on a.ad_element_id=b.ad_element_id
where a.ad_table_id in ((select ad_table_id from ad_table where tablename='tablename'))
order by a.name;
--order by a.created desc;

Menu

All the main (root) menu items in a tree

SELECT m.name, mm.* FROM AD_TreeNodeMM mm
left join ad_menu m on mm.node_id = m.ad_menu_id
WHERE mm.AD_Tree_ID=1000171 and mm.parent_id=0;

Update entity type

update ad_column set entitytype='U' where ad_column_id=3510;

Callout

select a.ad_column_id,tbl.tablename, a.columnname,a.name, a.callout from ad_column a
join ad_table tbl on a.ad_table_id = tbl.ad_table_id
where a.callout is not null and a.callout like '%bPartner%'
--and tbl.tablename = 'C_BankStatementLine'
order by tbl.tablename, a.callout, a.name;
--order by a.updated desc;

Update callout

update ad_column set callout = 'org.compiere.model.CalloutInvoiceNew.bPartner' where ad_column_id = 3499;

References

select * from ad_ref_list where ad_reference_id in ( select ad_reference_id from ad_reference where name = 'Ref Name' );
-
Incomplete:
left join
	ad_reference ref on ref.name = 'ZZ_Status'
left join
	ad_ref_list reflist on reflist.ad_reference_id = ref.ad_reference_id and reflist.value = perm.zz_status

For use in Jasper Report to lookup reference name

( SELECT rl.name FROM ad_ref_list rl WHERE ((rl.ad_reference_id = (select ad_reference_id from ad_reference where name = 'my ref name')::numeric) AND ((rl.value)::text = (v.ice_fuel_type)::text))) AS field_name

Validation Rules

select ad_val_rule_id, name, code from ad_val_rule where upper(code) like upper('%quota%');

Elements

select b.* from ad_column a
join ad_element b on a.ad_element_id=b.ad_element_id
where a.ad_table_id in (1000153, 1000152, 1000154, 1000156)

Report and process

select * from ad_process order by created desc;


select ad_process_id, value, name,description, classname, jasperreport from ad_process where upper(value) like upper('%') order by value;

select * from ad_process_para where ad_process_para_id = 1000000;

select columnname, name, defaultvalue from ad_process_para where ad_process_id = 1000000 order by seqno;

update ad_process_para set defaultvalue='1' where ad_process_id = 1000000 and columnname = 'columname';	--Sequence

Deletion

Delete all fields on window

delete from ad_field where ad_tab_id in ( select ad_tab_id from ad_tab where ad_window_id in 
(
	select ad_window_id from ad_window where name like 'Name of window' 
) );

Delete all fields on tab

1. 

delete from ad_field where ad_tab_id in ( select ad_tab_id from ad_tab where name = 'tabname' and ad_window_id in 
(
	select ad_window_id from ad_window where name = 'Name of window' 
) );

2.

delete from ad_tab where ad_tab_id in ( select ad_tab_id from ad_tab where ad_window_id in 
(
select ad_window_id from ad_window where ad_window_uu in ( 'REPLACEWITHWINDOWUUHERE' ) 
) );

3.

delete from ad_field where ad_tab_id in ( select ad_tab_id from ad_tab where ad_tab_uu in ( 'REPLACEWITHWINDOWUUHERE' ) );

Delete all occurences of column from windows

delete from ad_field where ad_column_id in 
( select ad_column_id from ad_column where upper(columnname) like upper('zz_nbsm_matchsetup_id') )

Delete index definitions on table

  • NB: Indexes not dropped automatically
delete from ad_indexcolumn where AD_TableIndex_ID in (select ad_tableindex_id from ad_tableindex where ad_table_id = 318);

delete from AD_TableIndex where ad_table_id = 318;

Sequences

update ad_sequence a set CURRENTNEXTSYS =13000  where a.name = 'name';

Doctype

select c_doctype_id from c_doctype where name = 'DocumentName'

Attachments

All pack-in attachments

select * from ad_attachment where ad_table_id = 50008 and record_id in (
  select AD_Package_Imp_Proc_id from AD_Package_Imp_Proc where name like '%%' 
  );

Synchronize Translations

An example:

update ad_process_trl a set name = b.name, description = b.name from ad_process b where a.ad_process_id = b.ad_process_id and b.name = 'Process Name';

Translations

Various helpers (work in progress)

select ad_message_id, value, msgtext, msgtip from ad_message where upper(msgtext) like upper('%login%') order by msgtext;

drop view if exists zz_trl_helper_field_v;

create or replace view zz_trl_helper_field_v  as 
select 
	main.ad_field_id, 
	trl.ad_language, trl.ad_field_trl_uu, 
	main.ad_field_uu, main.name as field_name, main.description as main_description, 
	trl.name as trl_name, trl.description as trl_description, 
	win.name as window_name, 
	col.columnname
from
ad_field main
join ad_field_trl trl on trl.ad_field_id = main.ad_field_id
join ad_column col on col.ad_column_id = main.ad_column_id
join ad_tab tab on tab.ad_tab_id = main.ad_tab_id
join ad_window win on win.ad_window_id = tab.ad_window_id;


select * from zz_trl_helper_field_v where ad_language in ( '' ) and columnname = '';

update ad_field_trl set name = 'name', description = 'name' where ad_field_trl_uu in (
	select ad_field_trl_uu from zz_trl_helper_field_v where ad_language in ( '' ) and columnname = ''
	);

select main.ad_process_id, trl.ad_language, trl.ad_process_para_trl_uu, main.name, main.description, trl.name, trl.description from
ad_process_para main
join ad_process_para_trl trl on trl.ad_process_para_id = main.ad_process_para_id
where 
	ad_process_id in ( select ad_process_id from ad_process where name like '' );

select main.ad_column_id, trl.ad_language, trl.ad_column_trl_uu, main.columnname, main.name, main.description, trl.name from
ad_column main
join ad_column_trl trl on trl.ad_column_id = main.ad_column_id
where 
	trl.ad_language in ( 'en_ZA' ) and
	main.ad_column_id in ( select ad_column_id from ad_column where columnname like '' );
	
select main.ad_element_id, trl.ad_language, trl.ad_element_trl_uu, main.columnname, main.name, main.description, trl.name, trl.description from
ad_element main
join ad_element_trl trl on trl.ad_element_id = main.ad_element_id
where 
	trl.ad_language in ( 'en_ZA' ) and
	main.ad_element_id in ( select ad_element_id from ad_element where columnname like '' );

select main.ad_menu_id, main.ad_menu_uu, trl.ad_language, trl.ad_menu_trl_uu, main.name, main.description, trl.name, trl.description from
ad_menu main
join ad_menu_trl trl on trl.ad_menu_id = main.ad_menu_id
where 
	trl.ad_language in ( 'en_ZA' ) and
	main.ad_menu_id in ( select ad_menu_id from ad_menu where name like '' );

-- For 2pack (sync UUID's)
update ad_menu_trl 
set ad_menu_trl_uu = '521bf63c-c0ab-40ac-a188-fe7cfd0a9612'
from ad_menu b
where 
ad_menu_trl.ad_menu_id = b.ad_menu_id
and b.ad_menu_uu = 'ccf0fc37-76cc-4a3c-8e1c-80d4c28e695a';

Pack out

Backup AD information before running 2pack

select * into bk_rq16_process from ad_process;

select * into bk_rq16_table from ad_table;

select * into bk_rq16_column from ad_column;

select * into bk_rq16_window from ad_window;

select * into bk_rq16_tab from ad_tab;

select * into bk_rq16_field from ad_field;

select * into bk_rq16_reference from ad_reference;

select * into bk_rq16_ref_table from ad_ref_table;

select * into bk_rq16_ref_list from ad_ref_list;

Delete all fields + tabs on windows (for Pack In)

  • Helps to ensure is packed in correctly
delete from ad_tab_customization where ad_tab_id in ( select ad_tab_id from ad_tab where ad_window_id in 
(
select ad_window_id from ad_window where name in ( 'nameOfWindow' ) 
));

) );
  • See also under the heading: 'Deletion'

Packout/Packin package details

select 
	hdr.name, det.created, det.updated, det.ad_package_exp_id, det.AD_Package_Exp_Detail_id, det.line, det.description, det.dbtype, det.sqlstatement, det.ad_table_id, tbl.tablename
from 
	AD_Package_Exp_Detail det
join AD_Package_Exp hdr on hdr.ad_package_exp_id = det.ad_package_exp_id
left join ad_table tbl on tbl.ad_table_id = det.ad_table_id;
order by updated desc;

select 
	updated, hdr.name, hdr.description
from 
	AD_Package_Exp hdr
order by updated desc;

select 
	updated, hdr.name, hdr.description
from 
	AD_Package_Imp hdr
order by updated desc;

-- For searching for tables linked to packouts

select 
	hdr.name, det.created, det.updated, det.ad_package_exp_id, det.AD_Package_Exp_Detail_id, det.line, det.description, det.dbtype, det.sqlstatement, det.ad_table_id, tbl.tablename
from 
	AD_Package_Exp_Detail det
join AD_Package_Exp hdr on hdr.ad_package_exp_id = det.ad_package_exp_id
left join ad_table tbl on tbl.ad_table_id = det.ad_table_id;

Duplicate key error when importing AD_Message

  • unique constraint (...AD_MESSAGE_TRL_KEY) violated
delete from ad_message_trl
WHERE AD_Message_ID=
( SELECT ad_message_id FROM ad_message WHERE value='KEYOFMESSAGE' );

Pack in/out helpers

Delete all fields on a window/tab

delete from ad_tab where ad_tab_id in ( select ad_tab_id from ad_tab where ad_window_id in 
(
select ad_window_id from ad_window where ad_window_uu in ( 'REPLACEWITHWINDOWUUHERE' ) 
) );

Delete all ad_userquery of window/tab process

delete from ad_userquery where ad_tab_id in ( select ad_tab_id from ad_tab where ad_window_id in 
(
select ad_window_id from ad_window where ad_window_uu in ( 'REPLACEWITHWINDOWUUHERE') 
));

Delete all ad_customization of window/tab

delete from ad_tab_customization where ad_tab_id in ( select ad_tab_id from ad_tab where ad_window_id in 
(
select ad_window_id from ad_window where ad_window_uu in ( 'REPLACEWITHWINDOWUUHERE') 
));

Delete all attachments of process

delete from ad_attachment where record_id in (
	select ad_process_id from ad_process where value like '%MYPROCESSKEY%' ) and 
ad_table_id = (select ad_table_id from ad_table where tablename='AD_Process');

Migration scripts

Which migration scripts have been run

select releaseno,created,name,status,isapply,filename, script  from ad_migrationscript order by releaseno, name;

Session

Sessions run during the actual year

SELECT
	c.name AS clientname,
	s.created,
	u.name AS username,
	s.remote_addr,
	s.processed,
	CASE
		WHEN s.processed = 'Y' THEN s.updated-s.created
		ELSE NULL
	END AS duration,
	r.name AS rolename
FROM ad_session s
     JOIN ad_client c ON (s.ad_client_id = c.ad_client_id)
     JOIN ad_user u ON (u.ad_user_id = s.createdby)
     JOIN ad_role r ON (r.ad_role_id = s.ad_role_id)
WHERE 	s.created>date_trunc('year', now())
ORDER BY s.ad_session_id DESC


This page is brought to you by nTier Software Services. Feel free to improve directly or suggest using the Discussion tab.

Cookies help us deliver our services. By using our services, you agree to our use of cookies.