NewFromMattel
Programmer
I can compile the following sproc, but when I execute it, it fails on eval(). I thought this was a valid function.
Thanks
/* This sproc fixed the master form build table to include a specified missing
base table row for a specified form.
To call this sproc:
EXEC FixMFBForForm 'formname', 'basetable', 'applicationDSN'
*/
IF EXISTS (SELECT name
FROM sysobjects
WHERE name = N'FixMFBForForm'
AND type = 'P')
DROP PROCEDURE FixMFBForForm
GO
CREATE PROCEDURE FixMFBForForm
@formName varchar(50), @baseTable varchar(25), @appDSN varchar(25)
AS
DECLARE @formTableName varchar(50)
DECLARE @masterFieldList varchar(50)
DECLARE @masterFormBuild varchar(50)
DECLARE @list varchar(4000)
SET @formTableName = 'UCFORMS.dbo.' + @formName + '_FieldList'
SET @masterFieldList = @appDSN + '.dbo.Master_Field_List'
SET @masterFormBuild = @appDSN + '.dbo.Master_Form_Build'
/* Here I get the list of necessary fields from the formname_fieldlist table */
SELECT @list = CASE WHEN @list IS NULL THEN FieldName ELSE @list + ',' + FieldName END
FROM eval(@formTableName)
WHERE FieldName IN -- Where the fieldname is in the master_field_list table for the given basetable
(SELECT Field_Name FROM eval(@masterFieldList) WHERE Base_Table_Name = @baseTable)
/* Now that I have my list of fields, let's see if we need it. */
IF NOT Exists
(SELECT Form_Name FROM eval(@masterFormBuild) WHERE Form_Name = @formName AND Table_Name = @baseTable)
BEGIN
INSERT INTO eval(@masterFormBuild)
(Form_Name, Table_Name, Field_List)
VALUES
(@formName, @baseTable, @list)
END
GO
Thanks
/* This sproc fixed the master form build table to include a specified missing
base table row for a specified form.
To call this sproc:
EXEC FixMFBForForm 'formname', 'basetable', 'applicationDSN'
*/
IF EXISTS (SELECT name
FROM sysobjects
WHERE name = N'FixMFBForForm'
AND type = 'P')
DROP PROCEDURE FixMFBForForm
GO
CREATE PROCEDURE FixMFBForForm
@formName varchar(50), @baseTable varchar(25), @appDSN varchar(25)
AS
DECLARE @formTableName varchar(50)
DECLARE @masterFieldList varchar(50)
DECLARE @masterFormBuild varchar(50)
DECLARE @list varchar(4000)
SET @formTableName = 'UCFORMS.dbo.' + @formName + '_FieldList'
SET @masterFieldList = @appDSN + '.dbo.Master_Field_List'
SET @masterFormBuild = @appDSN + '.dbo.Master_Form_Build'
/* Here I get the list of necessary fields from the formname_fieldlist table */
SELECT @list = CASE WHEN @list IS NULL THEN FieldName ELSE @list + ',' + FieldName END
FROM eval(@formTableName)
WHERE FieldName IN -- Where the fieldname is in the master_field_list table for the given basetable
(SELECT Field_Name FROM eval(@masterFieldList) WHERE Base_Table_Name = @baseTable)
/* Now that I have my list of fields, let's see if we need it. */
IF NOT Exists
(SELECT Form_Name FROM eval(@masterFormBuild) WHERE Form_Name = @formName AND Table_Name = @baseTable)
BEGIN
INSERT INTO eval(@masterFormBuild)
(Form_Name, Table_Name, Field_List)
VALUES
(@formName, @baseTable, @list)
END
GO