[ic] Not able to retrieve fields from custom table
Tim Good
tim.g at edsd.com
Thu May 13 09:47:46 EDT 2004
>Tim, it seems like your saying that [sql-param charge] is not coming
through
>for you. Your email does not show the [query] that is making [sql-param
charge]
>availiable. Please include that. Maybe you forgot to include "charge"
in the
>select statement.
>
>Also, it may be easier, and cleaner to do somehting like:
>
> $Scratch->{charge_1} = 0;
> $Scratch->{charge_2} = 0;
> $Scratch->{charge_3} = 0;
>
> $tmp = 0;
> # If subtotal value exists, format it for totaling.
> if ($subtotal && !($subtotal =~ /^\$/)) {
> $tmp += $subtotal;
> $Scratch->{charge_1} = $tmp;
> }
> elsif ($subtotal && ($subtotal =~ /^\$/)) {
> $tmp += substr($subtotal, 1, length($subtotal)-1);
> $Scratch->{charge_1} = $tmp;
> }
>
>
> # If install value exists, format it for totaling.
> if ($install && !($install =~ /^\$/)) {
> $tmp += $install;
> $Scratch->{charge_2} = $tmp;
> }
> elsif ($install && ($install =~ /^\$/)) {
> $tmp += substr($install, 1, length($install)-1);
> $Scratch->{charge_2} = $tmp;
> }
>
>
>
>Then disperse [scratchd charge_N] accordingly. You would only have to
call your
>tag once.
>
>Paul
Paul,
What I am saying, about [sql-param foo] and the [query] tag is this; it
works great
except that when no results are returned the area between
[query ...] [no_match]*****BLANK****[/no_match] [/query] is blank. I
have tried to use
the [query ...] tag and within the body of the tag I have several <td>s
and <tr>s.
When no results are returned the <td>s and <tr>s don't show and the
parent HTML table
shows empty areas. I tried to use the [no_match] ... [/no_match] tags
the the HTML
table still shows blank. Other than that the [query] tag works with my
custom table.
The [query ...] is included above look for:
[query sql="select charge from
> delivery_schedule where
> order_number = [loop-data transactions order_number]" type=list]
> [total_view subtotal="[loop-data transactions
> subtotal]" install="[loop-data transactions install_chrg]"
> delivery="[sql-param charge]" ]
> [/query]
Ofcourse the code above is not the exact code which I was using for the
[query ...] tag
encaspulating <td>s and <tr>s. I included the code above as an example
to where I was
working within the order_view page.
I would perfer to use the [data ...] tag rather than redevelop the
wheel. Good suggestion
above. Would also allow for less processing. I will add to Usertag.
I did develop a work around for my problem. I developed a Usertag to
retreive the delivery
charge value from the delivery_schedule table:
UserTag getdelchrg PosNumber 2
UserTag getdelchrg addAttr
UserTag getdelchrg Routine <<EOR
sub {
my ($curo) = @_;
my ($charge, $sql);
$charge = 0;
$sql = "select charge from delivery_schedule where order_number
= $curo";
$charge = $Tag->query({ table=>'delivery_schedule', sql=>$sql,
wantarray=>1 });
return $charge->[0]->[0];
}
EOR
I can then call my tag in my other Usertag like so:
[total_view subtotal="[loop-data transactions subtotal]"
install="[loop-data transactions install_chrg]" delivery="[getdelchrg
curo='[loop-data transactions order_number]']" ]
This works great.
Thanks,
Tim
More information about the interchange-users
mailing list