|
According to the help descriptions of <@union>
and <@intersect> tags, all arrays must have the same number of
columns in them. I have an array with 1 column that has the selected
values and another with 30 columns from which the selected values came
from. What is the fastest way to find out which records in the 30
column array were selected? Like 20 selected records out of 10,000
records.
Ted
Using
<@union> tag. There is a usefull way to use the UNION
tag.
You
have two arrays:
(1) an array from your database.
(2) an
array of selected rows
Add a
column to the array (1), the values in this array for this column will be
empty, call this COLUMN "checked"
Now do
your UNION on the common ID column. When the UNION executes it will put a
VALUE in that empty "checked" COLUMN form the other array (2). Now you can
do a simple FILTER on the resulting UNION so that only those ROWS where the
"checked" COLUMN is not empty. The action of the UNION depends on
what array is placed first.
I have
used this a few times, Janet. I could send you a short word doc if you
want.
I will look for the
code, but I remember that I did intersect on two arrays, comparing first
columns, and the two arrays were not the same number of columns. It does work,
and is much more efficient then looping.
--
Robert Garcia
President - BigHead Technology
VP Application Development - eventpix.com
13653 West Park Dr
Magalia, Ca 95954
ph: 530.645.4040 x222 fax: 530.645.4040
On May 4, 2005, at 1:12 PM, Ted Wolfley wrote:
What I am doing is bring back information from a 30
column table and putting it into an array. The array is used to create
a selection form using the unique id for the checkbox value.
After the submit, I use the <@POSTARG NAME='a_userid'
TYPE=ARRAY> to create an one column array of the checked
selections.
What I
am trying to do is to use the selected values to bring back data from the
orignial array to create a confirmation page before I preform the next
action. Since I already have the data in an array I thought I could
use it. The <@union> tag won't work because it combines. The
<@intersect> tag requires that the two arrays have the same
number of columns. May be I should just use an another Direct DBMS
action instead.
Ted
Looping through rows should be avoided in witango whenever
another solution is possible. Row looping is an expensive task.
Try something like this, since it is a comma delimited list, you can
turn into an array and filter. You can turn into array with the
<@array> tag, or:
<@assign request$temp <@transpose <@tokenizer "<@var
request$vdeletelist>" chars=",">>
<@! now you have a 1 column array with you items >
Then you can use <@union> to see where the arrays intersect.
--
Robert Garcia
President - BigHead Technology
VP Application Development - eventpix.com
13653 West Park Dr
Magalia, Ca 95954
ph: 530.645.4040 x222 fax: 530.645.4040
On May 4, 2005, at 12:01 PM, Ted Wolfley wrote:
I
couldn't get this to work, I think it is because of a comma delimited list
of values and contains uses only one value. I went with using a row
loop inside another row loop.
ted
Try
this
<@ASSIGN
NAME="vconfirmlist"
VALUE="<@FILTER
ARRAY='varrayout'
EXPR=”
‘@@request$vdeletelist’
contains #usrid>"
SCOPE="request">
Might
work, I did this once but cant find code
I am trying to <@filter>
an array by using values already selected from the array. The sql
equivalent is "select * from array where userid in (selected
list)".
Can a list of values be used
in the filter action?
<@ASSIGN
NAME="vconfirmlist"
VALUE="<@FILTER
ARRAY='varrayout'
EXPR='#usrid
in (@@request$vdeletelist)'>"
SCOPE="request">
@@request$vdeletelist
has
numeric values that are separated by commas and #usrid is a
numeric column.
Ted
Wolfley Database/Internet
Programmer The
Ogden Group of Rochester phone:
(585) 321 1060 x23 fax:
(585) 321 0043 [EMAIL PROTECTED]
www.ogdengroup.com
________________________________________________________________________
TO UNSUBSCRIBE: Go to http://www.witango.com/developer/maillist.taf
________________________________________________________________________
TO UNSUBSCRIBE: Go to http://www.witango.com/developer/maillist.taf
________________________________________________________________________
TO UNSUBSCRIBE: Go to http://www.witango.com/developer/maillist.taf
________________________________________________________________________
TO UNSUBSCRIBE: Go to http://www.witango.com/developer/maillist.taf
________________________________________________________________________
TO UNSUBSCRIBE: Go to http://www.witango.com/developer/maillist.taf
________________________________________________________________________
TO UNSUBSCRIBE: Go to http://www.witango.com/developer/maillist.taf
________________________________________________________________________
TO UNSUBSCRIBE: Go to http://www.witango.com/developer/maillist.taf
________________________________________________________________________
TO UNSUBSCRIBE: Go to http://www.witango.com/developer/maillist.taf
|