Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help with tally command

Status
Not open for further replies.

EBOUGHEY

Programmer
Aug 20, 2002
143
US
Hi All,

I am trying to write a program that inserts an address multiple times (have 156 names that need the same address according to the qty field).

Someone said to use the _tally feature with an insert command and I am not too good with this type of programming. I'm more old school with do while commands...

Something similar to the below. quick and easy...

close all
clear
use dealers in 0 alias supp
select supp
select * from supp group by dlrnmbr, qty into cursor control

_tally = qty
select control
SELECT DISTINCT DLRNMBR, QTY FROM CONTROL INTO CURSOR SAMPLES
SELECT SAMPLES
FOR X = 1 TO _TALLY
select dlrnmbr, DEALER, ADDRESS, CITY, STATE, ZIP, count(*) as qty from DEALERS group by dlrnmbr, DEALER, ADDRESS, CITY, STATE, ZIP order by dlrnmbr
 
FYI - I was taking an old program and manipulating it to give you an idea of what I am trying to accomplish so I'm sure you will see inconsistencies and things that don't make sense.
 
The code isn't working at all actually. Does anyone know where some sample code is to insert multiple information in based on a qty field that is character?


close all
use dealers in 0 alias source
use samples in 0 alias target
select source

INDEX ON dlrnmbr+qty TAG qty

lcOldqty = source.dlrnmbr+source.qty
GO TOP

scan
DO WHILE NOT EOF('source')
scatter memvar
insert into samples
lcOldqty = source.qty
ENDDO
endscan
 
This keeps overwriting and leaving only 1 record in the file. If someone can help with this loop perhaps I can make it work this way. Thanks.....

Elena



close all
use dealers
set safety off

INDEX ON dlrnmbr+qty TAG qty
lcOldqty = DEALERS.dlrnmbr+DEALERS.qty

GO TOP
DO WHILE !eof('DEALERS')
* lcNewFile = ALLTRIM(dealers.dlrnmbr)+"-"+alltrim(qty)+".DBF"
COPY TO (LCNEWFILE) WHILE DEALERS.QTY = lcOldQty
lcOldQty = Dealers.qty

ENDDO

close all
clear
set safety on
 
Can you please clarify what is it you are trying to do?
I didn't get it. (And also, what's the structure of Dealers table?) I can see several problems with your code, but don't know what to correct and what to drop altogether, because don't understand what you want to achieve.
 
I may be totally off base here but if you're trying to set an address field value when field qty is a specific value wouldn't REPLACE work.

Code:
REPLACE table.fldAdress WITH lsAddress FOR table.qty == lsQtyValue

Assumming that these fields exist in the same table.

Ralph
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top