Creating Assignments via SQL statements

M

Moses Bunting

I am trying to insert assignments using the stored procedure below. I am
following the example in the Project 2003 Data Reference. For reason(s) I
can't identify, the project does not recognize the record and upon saving and
closing the project file, the record is deleted. I have verified and
re-verified all of the information being passed into the record is correct.

Any help will be appreciated.

CREATE PROCEDURE [DBO].[AU_SP_INSERT_ASSIGNMENT]
@PROJ_ID INT,
@RES_UID INT,
@TASK_UID INT,
@ASSN_UNITS DECIMAL(25,6),
@ASSN_WORK DECIMAL(25,6),
@ASSN_START_DATE DATETIME,
@ASSN_FINISH_DATE DATETIME
AS

DECLARE @EXISTS TINYINT
EXEC @EXISTS = AU_FN_CHECK_PROJECT_FOR_ASSIGNMENT @PROJ_ID, @RES_UID,
@TASK_UID
IF @EXISTS = 0
BEGIN

DECLARE @EXT_EDIT_REF_DATA VARCHAR(1)
SET @EXT_EDIT_REF_DATA = '1'

DECLARE @ASSN_UID INT
SELECT @ASSN_UID = MAX(ASSN_UID) FROM MSP_ASSIGNMENTS WHERE PROJ_ID =
@PROJ_ID
SET @ASSN_UID = @ASSN_UID + 1

DECLARE @ASSN_CREATION_DATE DATETIME
SET @ASSN_CREATION_DATE = GETDATE()

-- REMEBER TO DELETE THE PLACEHOLDER ASSIGNMENT
DELETE FROM MSP_ASSIGNMENTS WHERE PROJ_ID = @PROJ_ID AND TASK_UID =
@TASK_UID AND RES_UID = -65535

INSERT INTO MSP_ASSIGNMENTS (PROJ_ID, EXT_EDIT_REF_DATA, ASSN_UID, RES_UID,
TASK_UID,
ASSN_UNITS,ASSN_WORK, ASSN_CREATION_DATE, ASSN_START_DATE, ASSN_FINISH_DATE)
VALUES (@PROJ_ID, @EXT_EDIT_REF_DATA, @ASSN_UID, @RES_UID, @TASK_UID,
@ASSN_UNITS, @ASSN_WORK, @ASSN_CREATION_DATE, @ASSN_START_DATE,
@ASSN_FINISH_DATE)

-- REMEMBER TO SET THE PROJECT EXTERNAL EDIT FLAG
EXEC dbo.MSP_PDS_SetProjectExternalEditFlag @PROJ_ID, @ASSN_CREATION_DATE

END
GO
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top