BlockingStateSqlDao.sql.stg

59 lines | 1.079 kB Blame History Raw Download
group BlockingStateSqlDao;

getBlockingStateFor() ::= <<
    select
        id
      , state
      , type
      , service
      , block_change
      , block_entitlement
      , block_billing
      , created_date   
    from blocking_states
    where id = :id
    -- We want the current state, hence the order desc and limit 1
    order by created_date desc, record_id desc
    limit 1
    ;
>>

getBlockingHistoryFor() ::= <<
    select
       id
      , state
      , type
      , service
      , block_change
      , block_entitlement
      , block_billing
      , created_date   
    from blocking_states
    where id = :id
    -- We want the history in order
    order by created_date asc, record_id asc
    ;
>>

setBlockingState() ::= <<
    insert into blocking_states (
       id
      , state
      , type
      , service
      , block_change
      , block_entitlement
      , block_billing
      , created_date   
    ) values (
        :id
      , :state
      , :type
      , :service
      , :block_change
      , :block_entitlement
      , :block_billing   
      , :created_date 
    );
>>