Category=Database Maintenance
Name=04. Migrate- Page Data to SHELFINSTANCEPAGES
Description=Grabs data from current VMR tables and imports it to populate the ShelfInstancePages table

Heading=Import Page Data Into SHELFINSTANCEPAGES

OutputLevel=1
Import2LSQL=SELECT DOCUMENTID from DOCUMENT|	\
SELECT	\
DISTINCT '{0}' DOCUMENTID,	\
lfNr	PAGEID,				\
folio	FOLIONUMBER,		\
concat('{0}', case when (InstId=0) then '0' else concat('0', CAST(InstId as char)) end) USERDATA,	\
cast(lpad(lfNr, 5, '0') as char) SORTORDER		\
	\
from cont{0} order by lfNr|INSERT INTO SHELFINSTANCEPAGES (	\
	\
DOCUMENTID,	\
PAGEID,	\
FOLIONUMBER,	\
SHELFID,	\
SORTORDER	\
) VALUES (	\
{0}, '{1}', '{2}', (select SHELFID from SHELFINSTANCE where USERDATA='{3}'), '{4}')
IgnoreException=Error Code: 1146
