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.
Author |
Topic |
Ramin
Starting Member
26 Posts |
Posted - 2013-12-15 : 20:30:19
|
HI,I am using below code to get patient status as an out put to my form. not sure whats happening but each time I run this its not executing my last "IF" if set to "N" show me N if not show me "Y" but it is by passing my first "IF" condition and jumps to last?The column alerts_ind shows only Y or N in the table patient_status.The table patient_status_mstr show the description of the patient which "discharged". All I want to do is if the patient is flagged with "discharge" the columns "alerts_ind" shows "Y". but something wrong? any help will be great. below is the code.Thanks.!!Alter PROCEDURE GBCheckPatientStatus (@enc_id varchar(36), @data_ind Char(1) OUTPUT)asbegindeclare @alerts_ind char(1);select @alerts_ind =pm.alerts_ind from patient_status_mstr pm inner join patient_status ps on ps.patient_status_id = pm.patient_status_id INNER JOIN patient_encounter pe ON pe.person_id = ps.person_id INNER JOIN person p ON p.person_id = ps.person_id where alerts_ind = @alerts_ind IF @alerts_ind = 'N' select @data_ind= 'N' else select @data_ind= 'Y' SET NOCOUNT Off; endGO |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2013-12-15 : 22:36:32
|
[code]select @alerts_ind =pm.alerts_indfrom patient_status_mstr pminner join patient_status ps on ps.patient_status_id = pm.patient_status_idINNER JOIN patient_encounter pe ON pe.person_id = ps.person_idINNER JOIN person p ON p.person_id = ps.person_idwhere alerts_ind = @alerts_ind[/code]perhaps that should be enc_id = @enc_id ? KH[spoiler]Time is always against us[/spoiler] |
 |
|
Pasi
Posting Yak Master
166 Posts |
Posted - 2013-12-15 : 22:45:05
|
Thanks KH but no I have played with that still the same I had pe.enc_id=@enc_id but no luck. |
 |
|
Ramin
Starting Member
26 Posts |
Posted - 2013-12-15 : 23:02:10
|
KH I took out the where alerts_ind = @alerts_ind and substituted the enc_id and for some reason started working!! I had both statements in there which should have only be the one you mentioned!! Thanks so much!! |
 |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2013-12-16 : 00:10:31
|
so do you understand why it does not work when you have the condition "alerts_ind = @alerts_ind" in there ? KH[spoiler]Time is always against us[/spoiler] |
 |
|
Ramin
Starting Member
26 Posts |
Posted - 2013-12-16 : 11:03:10
|
I did understand a bit but a little more explanation is great! I have started learning SP and I am loving it!! thnx for you help. |
 |
|
|
|
|