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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 charindex problem

Author  Topic 

rajasekhar857
Constraint Violating Yak Guru

396 Posts

Posted - 2009-12-16 : 03:51:30
[code]
IF(@IS_CONTRACEPTION='1')
begin
SELECT @Y= ezEMRxID FROM EMRIDS WHERE PROPERTY_NAME='FR_EXAM_ANS_ID'
Update EMRIDS set ezEMRxID=@Y+1 WHERE PROPERTY_NAME='FR_EXAM_ANS_ID'
SET @idValue = ISNULL(Rtrim(CAST(@Pre_hj as Varchar)),'') + ISNULL(Rtrim(Cast(@Y as varchar)),'')
INSERT INTO EMRFRExamAns(FR_EXAM_ANS_ID,FR_EXAM_DATA_ID,QUES_ID,QUES_ANS_ID,CTRL_VALUE,DISP_LABEL) VALUES(@idValue,@xy ,1018,1034,'YES',NULL)
SET @idValue = ''
IF(@ISCONTRACEPTIONOPT!=NULL)
begin
if (charindex('oral', @ISCONTRACEPTIONOPT)>=1)
begin
SELECT @Y= ezEMRxID FROM EMRIDS WHERE PROPERTY_NAME='FR_EXAM_ANS_ID'
Update EMRIDS set ezEMRxID=@Y+1 WHERE PROPERTY_NAME='FR_EXAM_ANS_ID'
SET @idValue = ISNULL(Rtrim(CAST(@Pre_hj as Varchar)),'') + ISNULL(Rtrim(Cast(@Y as varchar)),'')
INSERT INTO EMRFRExamAns(FR_EXAM_ANS_ID,FR_EXAM_DATA_ID,QUES_ID,QUES_ANS_ID,CTRL_VALUE,DISP_LABEL) VALUES(@idValue,@xy ,1018,1040,'Oral Contraceptive Pills',NULL)
SET @idValue = ''
end
if (charindex('hormonalinj', @ISCONTRACEPTIONOPT)>=1)
begin
SELECT @Y= ezEMRxID FROM EMRIDS WHERE PROPERTY_NAME='FR_EXAM_ANS_ID'
Update EMRIDS set ezEMRxID=@Y+1 WHERE PROPERTY_NAME='FR_EXAM_ANS_ID'
SET @idValue = ISNULL(Rtrim(CAST(@Pre_hj as Varchar)),'') + ISNULL(Rtrim(Cast(@Y as varchar)),'')
INSERT INTO EMRFRExamAns(FR_EXAM_ANS_ID,FR_EXAM_DATA_ID,QUES_ID,QUES_ANS_ID,CTRL_VALUE,DISP_LABEL) VALUES(@idValue,@xy ,1018,1041,'Hormonal Injectables(Long Acting)',NULL)
SET @idValue = ''
end
[/code]

values are like this

oral*hormonalinj*0*0*0*0
oral*hormonalinj*0*0*0*0
oral*hormonalinj*0*0*0*0
oral*hormonalinj*0*0*0*0
oral*hormonalinj*0*0*0*0
oral*hormonalinj*0*0*0*0
oral*hormonalinj*0*0*0*0


i have to do please help me as it is not inserting the values needs to change the if condition as charindex not working

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-12-16 : 03:56:47
Again, you are doing the same mistake(ask questions and not follow them properly)
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=137196
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=137135
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=137105
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=137107

First reply to those topics

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

rajasekhar857
Constraint Violating Yak Guru

396 Posts

Posted - 2009-12-16 : 04:00:32
they are all working fine.only this one is the problem
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-12-16 : 04:05:57
quote:
Originally posted by rajasekhar857

they are all working fine.only this one is the problem



Then it means you are not ready to say "Thanks" to the people who helped you. Right?


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

rajasekhar857
Constraint Violating Yak Guru

396 Posts

Posted - 2009-12-16 : 04:28:59
sorry for that please help me in this case
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-12-16 : 05:04:41
quote:
Originally posted by rajasekhar857

sorry for that please help me in this case


Ok. What is the problem you are having with charindex?
Did you get any error?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

rajasekhar857
Constraint Violating Yak Guru

396 Posts

Posted - 2009-12-16 : 05:22:35
Hi i got it
after replacing codition IF(@ISCONTRACEPTIONOPT!=NULL) toIF(ISNULL(@ISCONTRACEPTIONOPT,'')!='') its working finr.Thank you
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-12-16 : 05:39:48
or use

IF(@ISCONTRACEPTIONOPT is not null)

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -