Wednesday, September 28, 2005

Check List

( ) Written dodgy concatenated embedded sql?
( ) Wrapped it in shell script?
( ) Littered it with literals?
( ) Included some random control characters?
( ) Released it without checking it works?

( ) Remembered to add the sarcastic comment questioning someone else's ability?
# formatting had to be included in select statement
# could this suggest the database could use some normalisation?
strqry="select invoice_line_items.product_code||"
strqry=$strqry"invoice_line_items.customer_type||"
strqry=$strqry"invoice_line_items.product_sku||\n^D"
strqry=$strqry"substr(expiry_date,3,4)||"
strqry=$strqry"to_char(trunc(instant_cost/10000),'FMX')||"
strqry=$strqry"to_char(mod(instant_cost,10000),'FM0999')||"
strqry=$strqry"contract_type"
strqry=$strqry"from invoice_line_items, retail_calendar, customer_contract,"
strqry=$strqry"product_domain"
strqry=$strqry"where last_retail_day >= retail_calendar.retail_day"
strqry=$strqry"and first_retail_day <= retail_calendar.retail_day"
strqry=$strqry"and retail_calendar.day = $day"
strqry=$strqry"and retail_calendar.month = $month"
strqry=$strqry"and retail_calendar.year = $year"
strqry=$strqry"and invoice_line_items.line_code='$flag'"
strqry=$strqry"and customer_contract.line_code='$flag'"
strqry=$strqry"and invoice_line_items.product_code=customer_contract.product_code"
strqry=$strqry"and invoice_line_items.customer_type="
strqry=$strqry"      customer_contract.customer_type"
strqry=$strqry"and invoice_line_items.product_sku="
strqry=$strqry"      customer_contract.product_sku"
if [ $host_id != "-1" ]; then
        strqry=$strqry" and product_domain.host_id = $host_id"
fi
strqry=$strqry"and invoice_line_items.product_code=product_domain.product_code"
strqry=$strqry"and invoice_line_items.customer_type="
strqry=$strqry"      product_domain.customer_type"
strqry=$strqry"and invoice_line_items.product_sku="
strqry=$strqry"      product_domain.product_sku;"

4 comments:

William Robertson said...

# formatting had to be included in select statement
# could this suggest the database could use some normalisation?


Formatting needing to be included in the SELECT statement is always a sure sign that the database could use some normalisation. Isn't Fabian Pascal always saying that?

Robert Vollman said...

Wow, making a snide comment should be preceded by a quick check to make sure you understand what normalisation even means...

William Robertson said...

Anyway, we do the snide comments.

Adrian said...

The saddest thing for this individual is that the file was already in the source control system, so it wasn't too hard to identifiy the culprit.

My favourite is actually the helpful comment:


/*
look if you dont know what this means, you shouldnt be f!%&king working here
*/


...which bamboozled deployment for months:

enter value for KING
_