Home > Archive > Programming with dBASE > December 2005 > updateset()









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author updateset()
Dan Anderson

2005-12-06, 7:23 am

db+ I am trying to put together a routine that will create a table of
recipients for blast emails. I want to be able to select by state. The
code below only works for the first two states then fails to recognize
records for the new table (recipients.dbf). I have on "IF/ENDIF" segment
for each state. What can I do to make this work?


q = new Query( )
q.sql = "select * from MASTER"
q.active = true

f = new file()

IF form.container1.checkbox_AL.value = true
q.sql = "select * from MASTER where ST ='AL' "

u = new UpdateSet( )
u.source = q.rowset
u.destination = "recipients.dbf"
if f.exists("recipients.dbf")
u.append( )
else
u.copy( )
endif
ENDIF

IF form.container1.checkbox_AR.value = true
q.sql = "select * from MASTER where ST ='AR' "

u = new UpdateSet( )
u.source = q.rowset
u.destination = "recipients.dbf"
if f.exists("recipients.dbf")
u.append( )
else
u.copy( )
endif
ENDIF

IF form.container1.checkbox_AZ = true
q.sql = "select * from MASTER where ST ='AZ' "

u = new UpdateSet( )
u.source = q.rowset
u.destination = "recipients.dbf"
if f.exists("recipients.dbf")
u.append( )
else
u.copy( )
endif
ENDIF


--
Dan Anderson
UBI Processing Dept.
andersond@ubinc.com
800-444-4824 ext 101


*Lysander*

2005-12-06, 7:23 am

In article <1FkD5kk#FHA.1232@news-server>, andersond@ubinc.com says...
> db+ I am trying to put together a routine that will create a table of=20
> recipients for blast emails. I want to be able to select by state. The=

=20
> code below only works for the first two states then fails to recognize=20
> records for the new table (recipients.dbf). I have on "IF/ENDIF" segment=

=20
> for each state. What can I do to make this work?


I don't see anywhere that the 3 checkboxes are EXCLUDING each other, so=20
I assume that not only one could be selected, but also 2 or 3 of them=20
concurrently?
This would be the purpose of using checkboxes instead of for example=20
radio-buttons... I know... :)

But if this is the case, you should definitely make sure that:
- u has a declared range/scope (in this case I would suggest LOCAL)
- u is never been used twice without being cleaned 100% from memory

The latter point is because of a bug/feature of the updateset-class.
It is generally recommended to destroy the object and release it from=20
memory, before using it a second time.

try:
u.release()

or
release object u

(one of both is correct...)

u =3D null

--=20
ciao,
Andr=E9
Dan Anderson

2005-12-06, 7:23 am

Something odd is happening here. When I added the u.release() line it
results in an error saying "variable undefined: RELEASE" And it happens
whether I select one state or a group of states. Also, in the previous
message I guess I wasn't clear. It works down as far as Arkansas. If I
select "Indiana," which I know for certain has records, the IF test fails.

IF form.container1.checkbox_AL.value = true
q.sql = "select * from MASTER where ST ='AL' "

u = new UpdateSet( )
u.source = q.rowset
u.destination = "recipients.dbf"
if f.exists("recipients.dbf")
u.append( )
else
u.copy( )
endif
u.release()
ENDIF

--
Dan Anderson
UBI Processing Dept.
andersond@ubinc.com
800-444-4824 ext 101
"*Lysander*" <nobody@nowhere.com> wrote in message
news:MPG. 1dff85a64d26d45a9899
6e@news.dbase.com...
In article <1FkD5kk#FHA.1232@news-server>, andersond@ubinc.com says...
> db+ I am trying to put together a routine that will create a table of
> recipients for blast emails. I want to be able to select by state. The
> code below only works for the first two states then fails to recognize
> records for the new table (recipients.dbf). I have on "IF/ENDIF" segment
> for each state. What can I do to make this work?


I don't see anywhere that the 3 checkboxes are EXCLUDING each other, so
I assume that not only one could be selected, but also 2 or 3 of them
concurrently?
This would be the purpose of using checkboxes instead of for example
radio-buttons... I know... :)

But if this is the case, you should definitely make sure that:
- u has a declared range/scope (in this case I would suggest LOCAL)
- u is never been used twice without being cleaned 100% from memory

The latter point is because of a bug/feature of the updateset-class.
It is generally recommended to destroy the object and release it from
memory, before using it a second time.

try:
u.release()

or
release object u

(one of both is correct...)

u = null

--
ciao,
André


*Lysander*

2005-12-06, 9:23 am

In article <opFtvvl#FHA.1020@news-server>, andersond@ubinc.com says...
> Something odd is happening here. When I added the u.release() line it=20
> results in an error saying "variable undefined: RELEASE"=20


So it means that the syntax "release Object u" would be the one correct.
Sorry for not testing before, but when reading newsgroups, I am usually=20
not sitting near my development-machine.
And in my applications I am not using any updateset-objects.

> It works down as far as Arkansas. If I=20
> select "Indiana," which I know for certain has records, the IF test fails=

..

You did not need to be THAT clear, but now I am sure that the only thing=20
going wrong is the updateset-object still in memory.

Do as suggested in the other newsgroup and try "release object u"=20
instead of u.release(). Don't forget the "u=3Dnull" to be complete.
This should do the trick.
=20

--=20
ciao,
Andr=E9
Eric Logan

2005-12-07, 1:23 pm

Dan;
Rather than doing 3 updates, why don't you construct a single query on
Master based on all the checkboxes checked. Then you would get around any
problem with multiple updatesets or whatever it is.
Something like:
******
st = ""
IF form.container1.checkbox_AL.value = true
st+=['AL',]
endif
IF form.container1.checkbox_AR.value = true
st+=['AR',]
endif
IF form.container1.checkbox_AZ = true
st+=['AZ',]
endif
IF len(st) > 0 // if any selections
st = left(st,len(st)-1) // trim off last comma
q = new query()
q.sql = q.sql = [select * from MASTER where ST in (]+st+[)]
u = new UpdateSet( )
etc.
*****
Also, instead of using multiple checkboxes, you could use a single combobox
listing all appropriate states, and set that combobox to multi-select. The
code for extracting multiple combobox selections into a comma-separated
string isn't too bad. It would be better than working with fifty checkboxes.
Eric Logan

"Dan Anderson" wrote ...
The code below only works for the first two states then fails to recognize
records for the new table (recipients.dbf). I have on "IF/ENDIF" segment
for each state. What can I do to make this work?
>
>
> q = new Query( )
> q.sql = "select * from MASTER"
> q.active = true
>
> f = new file()
>
> IF form.container1.checkbox_AL.value = true
> q.sql = "select * from MASTER where ST ='AL' "
>
> u = new UpdateSet( )
> u.source = q.rowset
> u.destination = "recipients.dbf"
> if f.exists("recipients.dbf")
> u.append( )
> else
> u.copy( )
> endif
> ENDIF
>
> IF form.container1.checkbox_AR.value = true
> q.sql = "select * from MASTER where ST ='AR' "
>
> u = new UpdateSet( )
> u.source = q.rowset
> u.destination = "recipients.dbf"
> if f.exists("recipients.dbf")
> u.append( )
> else
> u.copy( )
> endif
> ENDIF
>
> IF form.container1.checkbox_AZ = true
> q.sql = "select * from MASTER where ST ='AZ' "
>
> u = new UpdateSet( )
> u.source = q.rowset
> u.destination = "recipients.dbf"
> if f.exists("recipients.dbf")
> u.append( )
> else
> u.copy( )
> endif
> ENDIF
>




Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com