Deleting multiple performances

Does anyone have an easy way to delete multiple performances in one fell swoop? Use case: When you make a mistake while running the Product Creation tool and create a large number of performances with an error that cannot be updated through Season Manager.

I was thinking about trying to mess around with TP_DELETE_PERFORMANCE in Test, to see if I could make it work for a set of performances, but wanted to check if anyone else already had a solution.

Thanks!

Jennifer

Parents
  • Declare
    @DoDelete        bit = 0
    ,@CurrPerfNo        int = 0

    Declare @tblPerf table (
    PerfNo            int
    ,PerfDate        datetime
    primary key (perfNo))

    insert into @tblPerf
    SELECT perf_no , perf_dt  FROM T_PERF
                                        WHERE 1=1
                                        AND Perf_dt BETWEEN '2/1/22' AND '1/1/23'
                                        AND perf_code like '%GADA'
                                        AND prod_season_no = 21645 --basically whatever logic you want to apply'

    Select @@ROWCOUNT  as PerfCount

    Select @CurrPerfNo  = Min(PerfNo) from @tblPerf
    While @DoDelete = 1 and @CurrPerfNo is not null
    Begin
     
        EXEC TP_DELETE_PERFORMANCE @CurrPerfNo
        Select @CurrPerfNo  = Min(PerfNo) from @tblPerf where PerfNo > @CurrPerfNo
    end


    Select * from T_PERF where perf_no in (Select PerfNo from @tblPerf)

Reply
  • Declare
    @DoDelete        bit = 0
    ,@CurrPerfNo        int = 0

    Declare @tblPerf table (
    PerfNo            int
    ,PerfDate        datetime
    primary key (perfNo))

    insert into @tblPerf
    SELECT perf_no , perf_dt  FROM T_PERF
                                        WHERE 1=1
                                        AND Perf_dt BETWEEN '2/1/22' AND '1/1/23'
                                        AND perf_code like '%GADA'
                                        AND prod_season_no = 21645 --basically whatever logic you want to apply'

    Select @@ROWCOUNT  as PerfCount

    Select @CurrPerfNo  = Min(PerfNo) from @tblPerf
    While @DoDelete = 1 and @CurrPerfNo is not null
    Begin
     
        EXEC TP_DELETE_PERFORMANCE @CurrPerfNo
        Select @CurrPerfNo  = Min(PerfNo) from @tblPerf where PerfNo > @CurrPerfNo
    end


    Select * from T_PERF where perf_no in (Select PerfNo from @tblPerf)

Children
No Data