group SubscriptionSqlDao;

insertSubscription() ::= <<
    insert into subscriptions (
        id
      , bundle_id
      , category
      , start_dt
      , bundle_start_dt
      , active_version
      , ctd_dt
      , ptd_dt
      , created_by
      , created_date
      , updated_by
      , updated_date
    ) values (
        :id
      , :bundle_id
      , :category
      , :start_dt
      , :bundle_start_dt
      , :active_version
      , :ctd_dt
      , :ptd_dt
      , :userName
      , :createdDate
      , :userName
      , :updatedDate
    );
>>

getSubscriptionFromId(id) ::= <<
    select
        id
      , bundle_id
      , category
      , start_dt
      , bundle_start_dt
      , active_version
      , ctd_dt
      , ptd_dt    
    from subscriptions
    where id = :id
    ;
>>

getSubscriptionsFromBundleId(bundle_id) ::= <<
    select
      id
      , bundle_id
      , category
      , start_dt
      , bundle_start_dt
      , active_version
      , ctd_dt
      , ptd_dt    
    from subscriptions
    where bundle_id = :bundle_id
    ;
>>

updateChargedThroughDate() ::= <<
    update subscriptions
    set
      ctd_dt = :ctd_dt
      , updated_by = :userName
      , updated_date = :updatedDate
    where id = :id
    ;
>>

updateActiveVersion() ::= <<
    update subscriptions
    set
      active_version = :active_version
      , updated_by = :userName
      , updated_date = :updatedDate
    where id = :id
    ;
>>

updateForRepair() ::= <<
    update subscriptions
    set
      active_version = :active_version
      , start_dt = :start_dt
      , bundle_start_dt = :bundle_start_dt
      , updated_by = :userName
      , updated_date = :updatedDate
    where id = :id
    ;
>>
