CREATE OR REPLACE VIEW RV_PRINTFORMAT_ITEM_VIEW
	(AD_PRINTFORMAT_ID, AD_CLIENT_ID, AD_ORG_ID, ISACTIVE, CREATED, CREATEDBY, 
	UPDATED, UPDATEDBY, FORMATNAME, ISTABLEBASED, ISFORM, TABLENAME, 
	ISSTANDARDHEADERFOOTER, HEADERMARGIN, FOOTERMARGIN, PRINTPAPER, 
	PRINTCOLOR, PRINTFONT, ITEMNAME, PRINTNAME, ISPRINTED, PRINTAREATYPE, 
	SEQNO, PRINTFORMATTYPE, COLUMNNAME, ISRELATIVEPOSITION, 
	ISNEXTLINE, XSPACE, YSPACE, XPOSITION, YPOSITION, MAXWIDTH, ISHEIGHTONELINE, 
	MAXHEIGHT, FIELDALIGNMENTTYPE, LINEALIGNMENTTYPE, ISORDERBY, SORTNO, 
	ISGROUPBY, ISPAGEBREAK, ITEMCOLOR, ITEMFONT, ISSUMMARIZED, IMAGEISATTACHED, 
	IMAGEURL, ISAVERAGED, ISCOUNTED, ISSETNLPOSITION, ISSUPPRESSNULL, 
	BELOWCOLUMN, PRINTGRAPH, ISFIXEDWIDTH, ISNEXTPAGE, PRINTNAMESUFFIX, 
	ISMINCALC, ISMAXCALC, ISRUNNINGTOTAL, RUNNINGTOTALLINES, 
	ISVARIANCECALC, ISDEVIATIONCALC, ISFILLEDRECTANGLE, LINEWIDTH, 
	ARCDIAMETER, SHAPETYPE, ISCENTRALLYMAINTAINED, ISIMAGEFIELD, 
	BARCODETYPE, PRINTFORMATCHILD) 
AS 
SELECT 	f.AD_PRINTFORMAT_ID AS AD_PRINTFORMAT_ID, 
	f.AD_CLIENT_ID AS AD_CLIENT_ID, 
	f.AD_ORG_ID AS AD_ORG_ID, 
	f.ISACTIVE AS ISACTIVE, 
	f.CREATED AS CREATED, 
	f.CREATEDBY AS CREATEDBY, 
	f.UPDATED AS UPDATED, 
	f.UPDATEDBY AS UPDATEDBY, 
	f.NAME as FORMATNAME, 
	f.ISTABLEBASED AS ISTABLEBASED, 
	f.ISFORM AS ISFORM, 
	(select t.TABLENAME from AD_TABLE t where t.AD_TABLE_ID=f.AD_TABLE_ID) as TABLENAME, 
	f.ISSTANDARDHEADERFOOTER AS ISSTANDARDHEADERFOOTER, 
	f.HEADERMARGIN AS HEADERMARGIN, 
	f.FOOTERMARGIN AS FOOTERMARGIN, 
	(select p.NAME from AD_PRINTPAPER p where p.AD_PRINTPAPER_ID=f.AD_PRINTPAPER_ID) as PRINTPAPER,
	(select p.NAME from AD_PRINTCOLOR p where p.AD_PRINTCOLOR_ID=f.AD_PRINTCOLOR_ID) as PRINTCOLOR, 
	(select p.NAME from AD_PRINTFONT p where p.AD_PRINTFONT_ID=f.AD_PRINTFONT_ID) as PRINTFONT,
	i.NAME as ITEMNAME, 
	i.PRINTNAME AS PRINTNAME, 
	i.ISPRINTED AS ISPRINTED, 
	i.PRINTAREATYPE AS PRINTAREATYPE, 
	i.SEQNO AS SEQNO, 
	i.PRINTFORMATTYPE AS PRINTFORMATTYPE, 
	(select c.COLUMNNAME from AD_COLUMN c where c.AD_COLUMN_ID=i.AD_COLUMN_ID) as COLUMNNAME, 
	i.ISRELATIVEPOSITION AS ISRELATIVEPOSITION, 
	i.ISNEXTLINE AS ISNEXTLINE, 
	i.XSPACE AS XSPACE, 
	i.YSPACE AS YSPACE, 
	i.XPOSITION AS XPOSITION, 
	i.YPOSITION AS YPOSITION, 
	i.MAXWIDTH AS MAXWIDTH, 
	i.ISHEIGHTONELINE AS ISHEIGHTONELINE, 
	i.MAXHEIGHT AS MAXHEIGHT, 
	i.FIELDALIGNMENTTYPE AS FIELDALIGNMENTTYPE, 
	i.LINEALIGNMENTTYPE AS LINEALIGNMENTTYPE,  
	i.ISORDERBY AS ISORDERBY, 
	i.SORTNO AS SORTNO, 
	i.ISGROUPBY AS ISGROUPBY, 
	i.ISPAGEBREAK AS ISPAGEBREAK,
	(select p.NAME from AD_PRINTCOLOR p where p.AD_PRINTCOLOR_ID=i.AD_PRINTCOLOR_ID) as ITEMCOLOR, 
	(select p.NAME from AD_PRINTFONT p where p.AD_PRINTFONT_ID=i.AD_PRINTFONT_ID) as ITEMFONT, 
	i.ISSUMMARIZED AS ISSUMMARIZED, 
	i.IMAGEISATTACHED AS IMAGEISATTACHED, 
	i.IMAGEURL AS IMAGEURL, 
	i.ISAVERAGED AS ISAVERAGED, 
	i.ISCOUNTED AS ISCOUNTED, 
	i.ISSETNLPOSITION AS ISSETNLPOSITION, 
	i.ISSUPPRESSNULL AS ISSUPPRESSNULL, 
	i.BELOWCOLUMN AS BELOWCOLUMN, 
	(select p.NAME from AD_PRINTGRAPH p where p.AD_PRINTGRAPH_ID=i.AD_PRINTGRAPH_ID) as PRINTGRAPH, 
	i.ISFIXEDWIDTH AS ISFIXEDWIDTH, 
	i.ISNEXTPAGE AS ISNEXTPAGE, 
	i.PRINTNAMESUFFIX AS PRINTNAMESUFFIX, 
	i.ISMINCALC AS ISMINCALC, 
	i.ISMAXCALC AS ISMAXCALC, 
	i.ISRUNNINGTOTAL AS ISRUNNINGTOTAL, 
	i.RUNNINGTOTALLINES AS RUNNINGTOTALLINES, 
	i.ISVARIANCECALC AS ISVARIANCECALC, 
	i.ISDEVIATIONCALC AS ISDEVIATIONCALC, 
	i.ISFILLEDRECTANGLE AS ISFILLEDRECTANGLE, 
	i.LINEWIDTH AS LINEWIDTH, 
	i.ARCDIAMETER AS ARCDIAMETER, 
	i.SHAPETYPE AS, 
	i.ISCENTRALLYMAINTAINED AS ISCENTRALLYMAINTAINED, 
	i.ISIMAGEFIELD AS ISIMAGEFIELD, 
	i.BARCODETYPE AS BARCODETYPE,
	(select pf.NAME from AD_PRINTFORMAT pf where pf.AD_PRINTFORMAT_ID=i.AD_PRINTFORMATCHILD_ID) as PRINTFORMATCHILD
FROM AD_PrintFormat f
  INNER JOIN AD_PrintFormatItem i ON (f.AD_PrintFormat_ID=i.AD_PrintFormat_ID)
WHERE i.SEQNO > 0
/
