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
    ;
>>

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