Hot Topic (More than 10 Replies) Q&A 5.0 - search techniques (Read 3492 times)
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Q&A 5.0 - search techniques
Mar 16th, 2006 at 4:00pm
Print Post Print Post  
I have a number of fields in my Q&A databases that are formatted as text but should be formatted as number.  I would like to retrieve all the records that contain text in these fields, to edit or delete them.  Any suggestions on what kind of search parameters I should use to pull out just the text records?
  

**
Captain Infinity
Back to top
IP Logged
 
Bob_Hansen
Senior Member
Members
*****
Offline


WOW, They have the Internet
on computers now!

Posts: 1861
Location: Salem, NH
Joined: Nov 24th, 2002
Re: Q&A 5.0 - search techniques
Reply #1 - Mar 16th, 2006 at 7:16pm
Print Post Print Post  
Not sure what is actually in the "text" field.  And not sure what you will do with results, but a few approaches come to mind.

1.  Make a new field TempNumb, type = N6
Run Mass Update so TempNumb=ExistingTextField

Now all former numbers will be numbers, all former text values will be empty. leading zeros will be gone.

Now can delete oldfield and rename new field to oldfieldname

---------------------------------------------
2.  Check for characters NOT 0-9 in the string of the field.   Ascii Codes for 0-9 are 48 thru 57.    These will be text fields.

May have a problem with periods?  What about data that has letters plus numbers?  Would have to get length of each string, and loop for ascii values for each character in the string.......too much programming.

----------------------------------------------
3.  Retrieve records with the following UNTESTED formula in the FieldName:

{IF @InStr(FieldName,0)>0}
OR
{IF @InStr(FieldName,1)>0}
OR
{IF @InStr(FieldName,2)>0}
OR
...
...
...
{IF @InStr(FieldName,9)>0}

This will ID all records that have no numbers in them.
Mass Update these records putting a flag in a temp field, then retrieve all records that are not flagged.  This result set should be all records that do have numbers in them.

Syntax may not be totally correct, have not tested, but I hope you get the idea.  If there is no 0-9 anywhere in the string, then this must be pure text.
----------------------------------------------------

I think option 1 may be the easiest.  After the MassUpdate you will have both fields available to compare results before you delete/replace the original values.....
  



Bob Hansen
Sesame Database Manager Professional
Sensible Solutions Inc.
Salem, NH
603-898-8223
Skype ID = sensiblesolutions
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: Q&A 5.0 - search techniques
Reply #2 - Mar 20th, 2006 at 2:51pm
Print Post Print Post  
Thanks Bob, I'll give it a try.
  

**
Captain Infinity
Back to top
IP Logged
 
Alec
Lanticans
*****
Offline



Posts: 200
Location: Ascot, England, UK
Joined: Nov 22nd, 2002
Re: Q&A 5.0 - search techniques
Reply #3 - May 2nd, 2006 at 7:50pm
Print Post Print Post  
There's an easy way. To be safe do this on a copy of your database.
In Q&A, change the field from text to number. Then search in the field:

 /..

That is forward slash period period. This searches for non-valid entries.
  

Alec
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: Q&A 5.0 - search techniques
Reply #4 - May 11th, 2006 at 5:47pm
Print Post Print Post  
Here's a new search I'm trying:

In my Q&A 5.0 Invoice database I have three fields that add up to the Invoice Total:
1) Subtotal
2) Discount
3) Additional non-discount charges

I'm trying to find all the invoices where the total of these three do not equal the amount in the Invoice Total field.  Yes, there are some, hidden somewhere within the 30,000 odd invoices that are stored.

I have tried the following:  In the Retrieve Spec I have numbered the three fields #1, #2, #3.  I have numbered the Invoice total #4.  In another unrelated field I have put the statement:  {#4<>(#1+#2+#3)}

Unfortunately, this is not working.  It is retreiving <b>all</b> the invoices.

Any ideas on what I'm doing wrong?  Does the programmed retreive have to be in a certain type of field?  Is there a better way to do the calculation?

Any help would be appreciated.  I need to clean these up before translating to Sesame.  Thanks in advance.
  

**
Captain Infinity
Back to top
IP Logged
 
Bob_Hansen
Senior Member
Members
*****
Offline


WOW, They have the Internet
on computers now!

Posts: 1861
Location: Salem, NH
Joined: Nov 24th, 2002
Re: Q&A 5.0 - search techniques
Reply #5 - May 11th, 2006 at 6:42pm
Print Post Print Post  
Looks good to me.  Make sure all the fields are Number fields.

I just did this without looking at yours, and came up with the same formula.  This works for me in the field for #4:
{ #4 <> (#1 + #2 + #3)}

But technically that formula could go into any other field, does not need to be in #4.  In fact, I just tested that by putting the formula in a text field, vs. the #4 number field.

  



Bob Hansen
Sesame Database Manager Professional
Sensible Solutions Inc.
Salem, NH
603-898-8223
Skype ID = sensiblesolutions
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: Q&A 5.0 - search techniques
Reply #6 - May 11th, 2006 at 7:03pm
Print Post Print Post  
Quote:
Looks good to me.  Make sure all the fields are Number fields.


Actually, all the fields are money fields.  And there is significant weirdness going on.

Instead of numbering the fields, I decided to use the field names.  Also, I decided to test it removing the additional charges from the equation.  So I ran the following:

Retreive Spec (note the use of subtraction in the calculation:
Subtotal (F0053) not empty
Discount (F0056) less than 0
Add'l Charges (F0059) empty
{Invoice Total<>(F0053-F0056)}
Results: 1813 records.

Then I changed the calculation to addition:
Subtotal (F0053) not empty
Discount (F0056) less than 0
Add'l Charges (F0059) empty
{Invoice Total<>(F0053+F0056)}
Results: 291 records.

I spot checked the results of each return and in every case the arithmetic was correct.  That is, the Subtotal minus the Discout always equaled the Invoice Total, as it's supposed to but shouldn't if the calculation was working.

Is there something special about money fields that could be causing this?
  

**
Captain Infinity
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: Q&A 5.0 - search techniques
Reply #7 - May 11th, 2006 at 7:26pm
Print Post Print Post  
Further:  It looks like the 291 records returned by the "addition" calculation are also present in the set of 1813 returned by the "subtraction" calculation.

THINGS SHO' DO BE GOIN' CRAZY 'ROUND HEAH!
  

**
Captain Infinity
Back to top
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Q&A 5.0 - search techniques
Reply #8 - May 11th, 2006 at 7:33pm
Print Post Print Post  
Scott,

If the Discount is less than zero, then it is a negative number like -200.00.

If Subtotal is $500.00 then Subtotal MINUS Discount is:
500.00 - -200.00 (note the double minus)
...which is 500.00 + 200.00
...which is 700.00

Subtotal PLUS Discount would be:
500.00 + -200.00
...which is 500.00 - 200.00
...which is 300.00

Is this perhaps what is making your math look strange?
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: Q&A 5.0 - search techniques
Reply #9 - May 11th, 2006 at 7:42pm
Print Post Print Post  
The + operator should be the one which returns the incorrect invoices, where the calculation does not match the Invoice Total.  However, all the records retreived do match.  That is, the invoice are correct.

I've decided to try this using a report, with Derived Colums and a True/False comparison.  I'll let you know how it goes.
  

**
Captain Infinity
Back to top
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: Q&A 5.0 - search techniques
Reply #10 - May 11th, 2006 at 7:47pm
Print Post Print Post  
The values match according to who? Looks can be deceiving.

If you are using @Round for example to round to two decimal places but the calculation result has three the final field is not going to match the calculation. Does that make sense.

For example

9.021 + 5.06 + 6.74 is 20.821
but if you round it to two places you get 20.82
in a comparision 20.82 does not equal 20.821

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: Q&A 5.0 - search techniques
Reply #11 - May 11th, 2006 at 7:59pm
Print Post Print Post  
I've made a report.  The structure is:

Retreive spec: blank (all records)

Sort spec:
Col.1: Invoice Number
Col.2: Subtotal
Col.3: Discount
Col.4: Additional Charges
Col.5: Invoice Total

Derived Columns:
Derived Col. 6: #2+#3+#4 (calculated total)
Derived Col. 7,AS: #5=#6 (test)

This report runs on ALL my invoices and prints to screen.  Smack dab at the top of my screen it shows me that I have one (1) Invoice where the total of the three fields do not match the Invoice Total.  The remaining 30,061 records return "True" to the test field.

YAY!  I have my answer, and it's an easy fix.

However, I am still baffled by the earlier searches.  For the sake of closure I would love it if someone could explain why they failed.  Q&A must have some sort of problem performing this math in a retreive.  Is it due to them being money fields?  The exisitence of a negative number?  Gremlins in the machine?  Am I just having a bad month?
  

**
Captain Infinity
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: Q&A 5.0 - search techniques
Reply #12 - May 11th, 2006 at 8:01pm
Print Post Print Post  
Quote:
If you are using @Round


Ah, excellent, I hadn't thought of that.  I'll check my programming and formatting.  Thanks Ray
  

**
Captain Infinity
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: Q&A 5.0 - search techniques
Reply #13 - May 11th, 2006 at 8:21pm
Print Post Print Post  
Yes, thank you Ray, rounding is precisely the problem.  The discount amount is based on a percentage given to the customer.

Whew!  I'm glad that's solved!  Thanks Ray, Erika and Bob!  This forum is great!
  

**
Captain Infinity
Back to top
IP Logged