Archive for the ‘Databases’ Category

 

WTF – Scheduled Reports

Working on scheduled reporting systems, you expect to see the same concepts. What format wiil we send the report in? How will it be delivered? I opened the “scheduled report” table to see how this particular system had been implemented. I couldn’t immediately find which column i was looking for. In fact the only one that looked like it might be useful was something called deliv_method.

deliv_method
206
774
206
206

Ok, so we’ve got a numeric list of delivery methods. Nothing too unusual about that. I just need to find the list either in the database or codebase. But where do we store the format of the report? I worked my way through the report scheduler code until i found this.

$delivMeth = ($row[‘DELIV_METHOD’] >> 8);
$myFormat = ($row[‘DELIV_METHOD’] & 0xFF);

Are those bitwise operators? And even a literal hexadecimal number? The only place i’ve ever seen a bitwise operator is when setting the error reporting level. I’ve looked at this a few times and am still not sure i correctly understand it.

The answer eventually revealed itself.

$a = array(
0×0104 => "Email HTML",
0×0204 => "Email HTML Attachment",
0×0284 => "Email HTML Zipped attach",
0×0201 => "Email PDF",
0×0203 => "Email TSV delim",
0×0283 => "Email TSV delim zipped",
0×0203 => "Email CSV delim",
0×0283 => "Email CSV delim zipped",
0×0304 => "FTP HTML",
0×0301 => "FTP PDF",
0×0303 => "FTP TSV delim",
0×0303 => "FTP CSV delim",
);

Pretty clever you have to admit! Unfortunately it can lead to same rather ugly code.

if ((($('#INPUT\\[DELIVERY_METHOD\\]').val() & 0xFF00) >> 8) != 0×03){

Posted by Lang Sharpe under Database Design, Databases, PHP, Programming Tags: , ,  •  No Comments

 
Rss Feed Tweeter button Facebook button Technorati button Reddit button Myspace button Linkedin button Delicious button Digg button Stumbleupon button