Thank you for fast response. It's hard to know where to look for the problem...
my $query = qq|SELECT
s.shiptofax, s.shiptocountry, s.shiptophone, s.ship
+toaddress1, s.shiptoaddress2,
s.shiptocity, s.shiptostate, s.shiptozipcode,
s.shiptocontact, s.shiptoname,
s.shiptoemail, o.waybill, o.shipvia
FROM shipto s, oe o
WHERE ((trans_id = $form->{"$form->{vc}_id"}) AND ( o.id =
+$form->{"$form->{vc}_id"})
AND ((to_date( s.shiptophone, 'YYYY-MM-DD') >= to_da
+te( to_char(current_timestamp,'YYYY-MM-DD'), 'YYYY-MM-DD'))
))
UNION
SELECT
s.shiptofax, s.shiptocountry, s.shiptophone, s.shiptoaddre
+ss1, s.shiptoaddress2,
s.shiptocity, s.shiptostate, s.shiptozipcode,
s.shiptocontact, s.shiptoname,
s.shiptoemail, o.waybill, o.shipvia
FROM shipto s
JOIN oe o ON (o.id = s.trans_id)
WHERE ((o.$form->{vc}_id = $form->{"$form->{vc}_id"})
AND ((to_date( s.shiptophone, 'YYYY-MM-DD') >= to_da
+te( to_char(current_timestamp,'YYYY-MM-DD'), 'YYYY-MM-DD'))
))
UNION
SELECT
s.shiptofax, s.shiptocountry, s.shiptophone, s.shiptoaddres
+s1, s.shiptoaddress2,
s.shiptocity, s.shiptostate, s.shiptozipcode,
s.shiptocontact, s.shiptoname,
s.shiptoemail, a.waybill, a.shipvia
FROM shipto s
JOIN $table a ON (a.id = s.trans_id)
WHERE ((a.$form->{vc}_id = $form->{"$form->{vc}_id"})
AND ((to_date( s.shiptophone, 'YYYY-MM-DD') >= to_da
+te( to_char(current_timestamp,'YYYY-MM-DD'), 'YYYY-MM-DD'))
))|;
if ($form->{id}) {
$query .= qq|
EXCEPT
SELECT
s.shiptofax, s.shiptocountry, s.shiptophone, s.shiptoaddress
+1, s.shiptoaddress2,
s.shiptocity, s.shiptostate, s.shiptozipcode,
s.shiptocontact, s.shiptoname,
s.shiptoemail, o.waybill, o.shipvia
FROM shipto s, oe o
WHERE ((s.trans_id = '$form->{id}') AND ( o.id = '$form->{id}
+'))
|;
}
my $sth = $dbh->prepare($query);
$sth->execute || $form->dberror($query);
my $ref;
while ($ref = $sth->fetchrow_hashref(NAME_lc)) {
push @{ $form->{all_shipto} }, $ref;
}
$sth->finish;
$dbh->disconnect;
This is the code I build the hash from. I would like to sort on 'shiptofax' but it doesn't get this way...
Regards,
|