in reply to Re: Building SQL Query on the fly
in thread Building SQL Query on the fly
Ideas on how to push the column names into the XML tag elements, and the values inside the tags? As for RoR, I am digging it. I don't know very advanced functions with it, but it was pretty easy to pick up, and I like incorporating it with AJAX, making this a pretty rich application. This is what I am doing with the XML::Generator on other canned/static reports, but the stuff it returns is hard coded, and not dynamic variables.my $sql = SQL::Abstract->new; ($group,$source,$orig,$term,$i_sig_start,$cdr_day,$call_status +,$e_rel_cause,$pdd,$asr,$call_duration,$npa,$i_tg_name,$e_tg_name,$st +ate,$gc_id,$dn,$noacpn,$i_rel_cause) = @_; if ($gc_id) { push @fields, "GC_ID"; } if ($pdd) { push @fields, "PDD"; } %where = (DAY => '2007-10-06'); $table = "TABLE_NAME"; my($stmt, @bind) = $sql->select($table, \@fields, \%where); my $sth = $dbh->prepare($stmt); unless ($sth) { $dbh->disconnect; } $sth->execute(@bind); while (my $row = $sth->fetchrow_hashref ){ >>>>>>WHAT DO I DO HERE FOR XML????>>>> }
Maybe do a...?$sth->execute(); while ( ( $gc_id, $cdr_day, $call_status, $direction, $p +dd, $state, $noacpn, $i_cause ) = $sth->fetchrow_array ) { push @output, $xml->cdr( $xml->GC_ID($gc_id), $xml->Date($cdr_day), $xml->CallStatus($call_status), $xml->Direction($direction), $xml->State($state), $xml->PDD($pdd), $xml->NOACPN($noacpn), $xml->I_REL_CAUSE($i_cause) ); } my $cgi = CGI->new; $hdr = "Custom Report"; print $cgi->header('text/xml'); print "<dataset name=\"$hdr\">\n"; print @output; print "</dataset>";
Just need help pushing the hash into the XML format properly. But since the amount of rows will always be different, I am not sure how to do it. Thanks!my $row = $sth->fetchrow_hasharray;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Building SQL Query on the fly
by graff (Chancellor) on Oct 08, 2007 at 05:08 UTC | |
by grinder (Bishop) on Oct 08, 2007 at 10:16 UTC | |
by hallikpapa (Scribe) on Oct 08, 2007 at 05:22 UTC | |
by graff (Chancellor) on Oct 08, 2007 at 05:35 UTC | |
by hallikpapa (Scribe) on Oct 08, 2007 at 06:28 UTC |