
DROP PROCEDURE
IF
	EXISTS update_data_dbfield;

DELIMITER $$
CREATE PROCEDURE update_data_dbfield (
	IN metableName VARCHAR(255),
	IN tableId BIGINT ( 20 ),
	IN dbfieldinfoOffset BIGINT ( 20 )
	)
	BEGIN
		#xwcmdbfieldinfo 添加默认字段
		select CONCAT('INSERT INTO  trs_hycloud_iip.xwcmdbfieldinfo
			(DBFIELDINFOID, TABLENAME, TABLEID, FIELDNAME, ANOTHERNAME, FIELDTYPE, DBTYPE, DBLENGTH, DEFAULTVALUE, ENMVALUE, NOTNULL, CLASSID, DBSCALE, CRUSER, CRTIME, VALIDATOR, RADORCHK, NOTEDIT, HIDDENFIELD)
	VALUES (',dbfieldinfoOffset,' + 1, ',metableName,' ,',tableId,', \'FromType\', \'第三方类型\', 45, 4, 0, NULL, NULL, 0, 0, 0, \'admin\', \'2018-09-20 14:50:31\', NULL, NULL, 0, 0);

	INSERT INTO  trs_hycloud_iip.xwcmdbfieldinfo
			(DBFIELDINFOID, TABLENAME, TABLEID, FIELDNAME, ANOTHERNAME, FIELDTYPE, DBTYPE, DBLENGTH, DEFAULTVALUE, ENMVALUE, NOTNULL, CLASSID, DBSCALE, CRUSER, CRTIME, VALIDATOR, RADORCHK, NOTEDIT, HIDDENFIELD)
	VALUES (',dbfieldinfoOffset,' + 2, ',metableName,' ,',tableId,' \'FromId\', \'第三方ID\', 40, 12, 100, NULL, NULL, 0, 0, 0, \'admin\', \'2018-09-20 14:50:31\', NULL, NULL, 0, 0);

	INSERT INTO  trs_hycloud_iip.xwcmdbfieldinfo
			(DBFIELDINFOID, TABLENAME, TABLEID, FIELDNAME, ANOTHERNAME, FIELDTYPE, DBTYPE, DBLENGTH, DEFAULTVALUE, ENMVALUE, NOTNULL, CLASSID, DBSCALE, CRUSER, CRTIME, VALIDATOR, RADORCHK, NOTEDIT, HIDDENFIELD)
	VALUES (',dbfieldinfoOffset,' + 3, ',metableName,' ,',tableId,' \'OriginMetaDataId\', \'源文档ID\', 45, 4, 0, NULL, NULL, 0, 0, 0, \'admin\', \'2018-09-20 14:50:31\', NULL, NULL, 0, 0);

	INSERT INTO  trs_hycloud_iip.xwcmdbfieldinfo
			(DBFIELDINFOID, TABLENAME, TABLEID, FIELDNAME, ANOTHERNAME, FIELDTYPE, DBTYPE, DBLENGTH, DEFAULTVALUE, ENMVALUE, NOTNULL, CLASSID, DBSCALE, CRUSER, CRTIME, VALIDATOR, RADORCHK, NOTEDIT, HIDDENFIELD)
	VALUES (',dbfieldinfoOffset,' + 4, ',metableName,' ,',tableId,' \'AttachPic\', \'含图\', 45, 5, 150, NULL, NULL, 0, 0, 0, \'admin\', \'2018-09-20 14:50:31\', NULL, NULL, 0, 0);

	INSERT INTO  trs_hycloud_iip.xwcmdbfieldinfo
			(DBFIELDINFOID, TABLENAME, TABLEID, FIELDNAME, ANOTHERNAME, FIELDTYPE, DBTYPE, DBLENGTH, DEFAULTVALUE, ENMVALUE, NOTNULL, CLASSID, DBSCALE, CRUSER, CRTIME, VALIDATOR, RADORCHK, NOTEDIT, HIDDENFIELD)
	VALUES (',dbfieldinfoOffset,' + 5, ',metableName,' ,',tableId,' \'AttachVideo\', \'含视频\', 45, 5, 150, NULL, NULL, 0, 0, 0, \'admin\', \'2018-09-20 14:50:31\', NULL, NULL, 0, 0);

	INSERT INTO  trs_hycloud_iip.xwcmdbfieldinfo
			(DBFIELDINFOID, TABLENAME, TABLEID, FIELDNAME, ANOTHERNAME, FIELDTYPE, DBTYPE, DBLENGTH, DEFAULTVALUE, ENMVALUE, NOTNULL, CLASSID, DBSCALE, CRUSER, CRTIME, VALIDATOR, RADORCHK, NOTEDIT, HIDDENFIELD)
	VALUES (',dbfieldinfoOffset,' + 6, ',metableName,' ,',tableId,' \'AttachAudio\', \'含音频\', 45, 5, 150, NULL, NULL, 0, 0, 0, \'admin\', \'2018-09-20 14:50:31\', NULL, NULL, 0, 0);

	INSERT INTO  trs_hycloud_iip.xwcmdbfieldinfo
			(DBFIELDINFOID, TABLENAME, TABLEID, FIELDNAME, ANOTHERNAME, FIELDTYPE, DBTYPE, DBLENGTH, DEFAULTVALUE, ENMVALUE, NOTNULL, CLASSID, DBSCALE, CRUSER, CRTIME, VALIDATOR, RADORCHK, NOTEDIT, HIDDENFIELD)
	VALUES (',dbfieldinfoOffset,' + 7, ',metableName,' ,',tableId,' \'DocType\', \'文档类型\', 45, 4, 0, NULL, NULL, 0, 0, 0, \'admin\', \'2018-09-20 14:50:31\', NULL, NULL, 0, 0);

	INSERT INTO trs_hycloud_iip.xwcmdbfieldinfo
			(DBFIELDINFOID, TABLENAME, TABLEID, FIELDNAME, ANOTHERNAME, FIELDTYPE, DBTYPE, DBLENGTH, DEFAULTVALUE, ENMVALUE, NOTNULL, CLASSID, DBSCALE, CRUSER, CRTIME, VALIDATOR, RADORCHK, NOTEDIT, HIDDENFIELD)
	VALUES (',dbfieldinfoOffset,' + 8, ',metableName,' ,',tableId,' \'DOCRELTIME\', \'撰写时间\', 11, 93, 0, NULL, NULL, 0, 0, 0, \'admin\', \'2018-09-20 14:50:31\', NULL, NULL, 0, 0);

	INSERT INTO trs_hycloud_iip.xwcmdbfieldinfo
			(DBFIELDINFOID, TABLENAME, TABLEID, FIELDNAME, ANOTHERNAME, FIELDTYPE, DBTYPE, DBLENGTH, DEFAULTVALUE, ENMVALUE, NOTNULL, CLASSID, DBSCALE, CRUSER, CRTIME, VALIDATOR, RADORCHK, NOTEDIT, HIDDENFIELD)
	VALUES (',dbfieldinfoOffset,' + 9, ',metableName,' ,',tableId,' \'ThumbFiles\', \'文档附图\', 40, 12, 2000, NULL, NULL, 0, 0, 0, \'admin\', \'2018-09-20 14:50:31\', NULL, NULL, 0, 0);

	alter table trs_hycloud_iip.wcmmetatable', metableName,
											 ' add column OriginMetaDataId int(11) DEFAULT NULL,
                        add column FromType int(11) DEFAULT NULL,
                        add column FromId int(11) DEFAULT NULL,
                        add column DocRelTime int(11) DEFAULT NULL,
                       add column AttachPic smallint(6) DEFAULT NULL,
                       add column AttachVideo smallint(6) DEFAULT NULL,
                       add column AttachAudio smallint(6) DEFAULT NULL,
                       add column ThumbFiles varchar(2000) DEFAULT NULL,
                       add column VersionNum int(11) DEFAULT NULL,
                       add column DocType int(11) DEFAULT NULL;
 ') info;

END $$
DELIMITER;