March 27, 2009 at 8:36 am
I have to keep end date for the previous record before creatign new record?
I have multiple records storing in one table.every time before creating new record end the previous record with end date.
What query can i write for that?
I have to write in a case statment.
Thanks.
March 27, 2009 at 9:46 am
Why does it have to be a case statement?
Can you provide the table definitions and some sample data?
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
March 27, 2009 at 10:07 am
Declare @workflow_activity_type_identifier int,
@workflow_identifier
select @workflow_activity_type_identifier=workflow_activity_type_identifier from workflow_activity
where workflow_activity_identifier = @workflow_activity_identifier
select @sequence_number = case @workflow_activity_type_identifier
when 197 then 1
when 203 then 1
when 200 then(select count(*) from workflow_activity where workflow_activity_type_identifier = 200
and workflow_identifier = @workflow_identifier)
when 201 then(select count(*) from workflow_activity where workflow_activity_type_identifier = 201
and workflow_identifier = @workflow_identifier)
else 0
end
In the above code on workflow_activity_type_identifier = 200 or 201 on this identifier multiple records are created i have to keep end date for the previous record.
these workflow_activity_type_identifier having workflow_activity_code's are SIFW04 and SIFW05.using these code i have to keep end date for the previous record when ever creating new record on the same workflow_activity_type_identifier's(200,201)
Thanks
March 27, 2009 at 11:13 am
Why not just declare a datetime variable and grab the value when you get the activity type identifier? Will that not do what you need?
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
March 27, 2009 at 11:26 am
Canu send a query for that as an example?
March 27, 2009 at 11:32 am
Declare @workflow_activity_type_identifier int,
@workflow_identifier,
@Date datetime
select @workflow_activity_type_identifier=workflow_activity_type_identifier from workflow_activity,
@Date = End_Date
where workflow_activity_identifier = @workflow_activity_identifier
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply