AccountSqlDao.sql.stg

75 lines | 1.913 kB Blame History Raw Download
group AccountDaoSql;

accountFields(prefix) ::= <<
    <prefix>id,
    <prefix>external_key,
    <prefix>email,
    <prefix>name,
    <prefix>first_name_length,
    <prefix>currency,
    <prefix>billing_cycle_day,
    <prefix>payment_provider_name,
    <prefix>time_zone, 
    <prefix>locale,
    <prefix>address1, 
    <prefix>address2, 
    <prefix>company_name, 
    <prefix>city, 
	<prefix>state_or_province, 
    <prefix>country, 
    <prefix>postal_code,
    <prefix>phone,
    <prefix>created_by,
    <prefix>created_date,
    <prefix>updated_by,
    <prefix>updated_date
>>

create() ::= <<
    INSERT INTO accounts
      (<accountFields()>)
    VALUES
      (:id, :externalKey, :email, :name, :firstNameLength, :currency, :billingCycleDay,
      :paymentProviderName, :timeZone, :locale,
      :address1, :address2, :companyName, :city, :stateOrProvince, :country, :postalCode, :phone,
      :userName, :createdDate, :userName, :updatedDate);
>>

update() ::= <<
    UPDATE accounts
    SET external_key = :externalKey, email = :email, name = :name, first_name_length = :firstNameLength,
        currency = :currency, billing_cycle_day = :billingCycleDay, payment_provider_name = :paymentProviderName,
        time_zone = :timeZone, locale = :locale,
        address1 = :address1, address2 = :address2, company_name = :companyName, city = :city, state_or_province = :stateOrProvince,
        country = :country, postal_code = :postalCode, phone = :phone,
        updated_date = :updatedDate, updated_by = :userName
    WHERE id = :id;
>>

getAccountByKey() ::= <<
    select <accountFields()>
    from accounts
    where external_key = :externalKey;
>>

getById() ::= <<
    SELECT <accountFields()>
    FROM accounts
    WHERE id = :id;
>>

get() ::= <<
    SELECT <accountFields()>
    FROM accounts;
>>

getIdFromKey() ::= <<
    SELECT id
    FROM accounts
    WHERE external_key = :externalKey;
>>

test() ::= <<
    SELECT 1 FROM accounts;
>>
;