Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MICROS RES 3700 5.7.5 SQL Script for Mi_Def update

Status
Not open for further replies.

AaronMackee

IS-IT--Management
Dec 8, 2018
1
CA
I'm working on a SQL script to clone a specific block of menu items across several systems. I've got the import working fine for items that don't exist, but running into a key constraint issue when trying to update specific values in Micros.mi_def.

Here is what I am working with. I know the first two sections work fine - if I comment out the update block and add in a select * from #mi_def_update I've got all the data, and I know my mi_seq info aligns, since I'm using an export from the same DB as the source.

Guessing I'm missing something obvious as my SQL is rudimentary at best, but would appreciate any help if someone has a fix.

SQL:
//Checks for existing temp table and remove if it exists, then create the temp table

DROP TABLE IF EXISTS "#mi_def_update"
GO

CREATE "#mi_def_update"
	(
	mi_seq		NUMERIC(6),
	obj_num		NUMERIC(7),
	name_1		CHAR(16),
	name_2		CHAR(12),
	maj_grp_seq NUMERIC(3),	
	fam_grp_seq NUMERIC(3),
	mi_grp_seq NUMERIC(3),
	Mi_Slu_Seq	NUMERIC(8),
	slu_priority NUMERIC(3),
	mi_type_seq NUMERIC(3),
	cond_allowed NUMERIC(3),
	mlvl_class_seq NUMERIC(1),
	prn_def_class_seq NUMERIC(2),
	);
	
//-------------------------------------------------------------------------------------

//Imports data into temp table from csv

INPUT INTO "#mi_def_update"
	FROM '.\mi_import.csv'
	FORMAT ascii
		(
		"mi_seq",
		"obj_num",
		"name_1",
		"name_2",
		"maj_grp_seq",
		"fam_grp_seq",
		"mi_grp_seq",
		"Mi_Slu_Seq",
		"slu_priority",
		"mi_type_seq",
		"cond_allowed",
		"mlvl_class_seq",
		"prn_def_class_seq"
		);
	
//-------------------------------------------------------------------------------------

//Updates the mi_def table from the temp table

UPDATE MICROS.mi_def SET

    target.obj_num = source.obj_num,
	target.name_1 = source.name_1,
	target.name_2 = source.name_2,
	target.maj_grp_seq = source.maj_grp_seq,
	target.fam_grp_seq = source.fam_grp_seq,
	target.mi_grp_seq = source.mi_grp_seq,
	target.Mi_Slu_Seq = source.Mi_Slu_Seq,
	target.slu_priority = source.slu_priority,
	target.mi_type_seq = source.mi_type_seq,
	target.cond_allowed = source.cond_allowed,
	target.mlvl_class_seq = source.mlvl_class_seq,
	target.prn_def_class_seq = source.prn_def_class_seq
	
FROM MICROS.mi_def target
LEFT OUTER JOIN #mi_def_update source
ON target.mi_seq = source.mi_seq;
WHERE target.mi_seq IN (SELECT mi_seq FROM #mi_def_update);
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top