Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 I had some problem with table type parameters ???

Author  Topic 

mohan123
Constraint Violating Yak Guru

252 Posts

Posted - 2012-10-31 : 09:42:16
Hello all,

I have taken table Type parameters need to update values in table as well as table type

@i_AppUserId KEYID
,@i_QuestionaireId KEYID
,@i_RecommendationId KEYID
,@i_StopMedication ISINDICATOR = 0
,@t_tQuestionaireRecommendation TQUESTIONAIRERECOMMENDATION READONLY
,@vc_DaysToNextQuestionnaire CHAR(2)
,@i_NextQuestionaireId KEYID
,@vc_StatusCode STATUSCODE = 'A'
,@i_QuestionaireRecommendationId INT
,@o_QuestionaireRecommendationId INT OUTPUT

my update query :

UPDATE
QuestionaireRecommendation
SET
QuestionaireId = @i_QuestionaireId
,RecommendationId = @i_RecommendationId
,StopMedication = @i_StopMedication
,DaysToNextQuestionnaire = @vc_DaysToNextQuestionnaire
,StatusCode = @vc_StatusCode
,NextQuestionaireId = @i_NextQuestionaireId
,LastModifiedByUserId = @i_AppUserId
,LastModifiedDate = GETDATE()
WHERE
QuestionaireRecommendationId = @i_QuestionaireRecommendationId

DELETE FROM
MedicationQuestionaire
WHERE
QuestionaireRecommendationId = @i_QuestionaireRecommendationId

INSERT INTO
MedicationQuestionaire
(
QuestionaireRecommendationId
,DrugCodeId
,RecommendationNumber
,RecommendationFrequency
,DurationNumber
,DurationFrequency
,CreatedByUserId
)
SELECT
@i_QuestionaireRecommendationId
,t.DrugCodeId
,t.RecommendationNumber
,t.RecommendationFrequency
,t.DurationNumber
,t.DurationFrequency
,@i_AppUserId
FROM
@t_tQuestionaireRecommendation t

but my main problem is while updating it is deleting recored again new record is inserting.How to update exisiting record with same ID in main table as well as table type

I am here passing values directly ??? how to update table type in update procedure
Where i need to update main table as well as table type paramaeters
Suggest me
P.V.P.MOhan
   

- Advertisement -