Error with UNION query construction
Status: Beta
Brought to you by:
angusgb
[htminer@mypg tasks]$ htminer_warehouse_loader -a -f 2006-12-24 -v -v -v
OLTP: input connected
Warehouse: input connected
Warehouse: output connected
DBD::Pg::st execute failed: ERROR: syntax error at or near "UNION"
LINE 2: UNION
^
ERROR: syntax error at or near "UNION"
LINE 2: UNION
^
Logged In: YES
user_id=28915
Originator: YES
Here is the proposed patch. Please advise if it is appropriate:
Index: htminer_warehouse_loader.in
RCS file: /cvsroot/htminer/htminer/warehouse/htminer_warehouse_loader.in,v
retrieving revision 1.5
diff -u -p -r1.5 htminer_warehouse_loader.in
--- htminer_warehouse_loader.in 23 Nov 2006 16:45:38 -0000 1.5
+++ htminer_warehouse_loader.in 3 Jan 2007 08:27:37 -0000
@@ -441,8 +441,8 @@ sub check_days($$$$) {
my $session_query = '';
while (my $table = $wsth->fetchrow_arrayref) {
$session_query .= "UNION\n" if $session_query;
- $session_query .= "SELECT to_char(date_trunc('day', start_time),'YYYY-MM-DD') AS day, count(*) AS count " .
- "FROM dimensions.$$table[0] $limit_cond GROUP BY date_trunc('day', start_time) ORDER BY day\n";
+ $session_query .= "(SELECT to_char(date_trunc('day', start_time),'YYYY-MM-DD') AS day, count(*) AS count " .
+ "FROM dimensions.$$table[0] $limit_cond GROUP BY date_trunc('day', start_time) ORDER BY day)\n";
}
$wsth->finish;