ColdFusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreColdFusion Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old April 1st, 2004, 04:47 PM
simptech simptech is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 2 simptech User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Red face POW() SQL Function, CF4, and Access 2000

My delima is simple enough... or so I thought!

Here's the code:
<!--- Origin Zip Code --->
<cfset origZip = 33990>

<!--- Distance in Miles --->
<cfset distLimit = 10>

<!--- This query works --->
<cfquery name="zipfrom" datasource="********">
SELECT latitude, longitude
FROM zipdata
WHERE zip = '#origZip#'
</cfquery>

<!--- This one fails --->
<cfquery name="ziplist" datsource="********">
SELECT zipcode
FROM zipdata
WHERE (pow((69.1 * (zipdata.longitude - #zipfrom.longitude#) * cos(#zipfrom.latitude# / 57.3)), 2) + pow((69.1 * (zipdata.latitude - #zipfrom.latitude#)), 2)) < (#distLimit# * #distLimit#)
</cfquery>

<p><cfoutput query="ziplist">#zip#, </cfoutput></p>

Problem:[Microsoft][ODBC Microsoft Access Driver] Undefined function 'pow' in expression.



Does anybody know if there is an equivalent to the pow() SQL function when querying MS Access 2000 databases? I have Googled the #&%! out of this topic and could find no useable reference.

BTW: This problem is holding up a project I am charging for. Therefore, if there is a reasonable price to be paid for the CORRECT response, I would gladly entertain the possibility.

Reply With Quote
  #2  
Old April 1st, 2004, 06:30 PM
r937's Avatar
r937 r937 is offline
SQL Consultant
Dev Shed God 24th Plane (16500 - 16999 posts)
 
Join Date: Feb 2003
Location: Toronto Canada
Posts: 16,743 r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 3 Weeks 2 Days 21 h 15 m 22 sec
Reputation Power: 870
i'm guessing the pow() function is just exponentiation?

it's defined in mysql, is that where you got it?

in access you'd use the ^ operator
Code:
where (69.1 * (zipdata.longitude - #zipfrom.longitude#) 
            * cos(#zipfrom.latitude# / 57.3)
       ) ^ 2 
    + (69.1 * (zipdata.latitude - #zipfrom.latitude#)
       ) ^ 2
    < #distLimit# ^ 2
__________________
r937.com | rudy.ca

Reply With Quote
  #3  
Old April 1st, 2004, 06:32 PM
r937's Avatar
r937 r937 is offline
SQL Consultant
Dev Shed God 24th Plane (16500 - 16999 posts)
 
Join Date: Feb 2003
Location: Toronto Canada
Posts: 16,743 r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 3 Weeks 2 Days 21 h 15 m 22 sec
Reputation Power: 870
p.s.

instead of

<p><cfoutput query="ziplist">#zip#, </cfoutput></p>

you can do this:

<p><cfoutput>#ValueList(ziplist.zipcode)#</cfoutput></p>

and you won't have a trailing comma

Reply With Quote
  #4  
Old April 1st, 2004, 06:57 PM
simptech simptech is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 2 simptech User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thumbs up

Thank you very much for the quick reply.

My query executes somewhat slow but that may be do to users currently accessing the database.

As for the reference to the pow() function, the first place I found it was in a php example (MySQL) and then found reference to the same function in the SQL 97 specifications. Therefore I assumed the function had to exist in Access.

which it does (thanks for pointing out the syntax), it's just not a "named" function as I would have expected

Reply With Quote
  #5  
Old May 14th, 2004, 03:23 PM
phoe22 phoe22 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 11 phoe22 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
access

Can somebody fix this code for Access for me? I have tried for days and can't figure it out. Thankyou.

SELECT *
FROM tblCustomer2
WHERE (69.1 * (tblAll_Zips_Lat_Long.longitude) - ( [Enter Zip Code].Longitude) * cos(tblAll_Zips_Lat_Long.Latitude / 57.3)
) ^ 2
+ (69.1 * (tblAll_Zips_Lat_Long - [Enter Zip Code].Latitude)
) ^ 2
< 50 ^ 2

Reply With Quote
  #6  
Old May 14th, 2004, 04:04 PM
r937's Avatar
r937 r937 is offline
SQL Consultant
Dev Shed God 24th Plane (16500 - 16999 posts)
 
Join Date: Feb 2003
Location: Toronto Canada
Posts: 16,743 r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 3 Weeks 2 Days 21 h 15 m 22 sec
Reputation Power: 870
what does "fix" mean?

are you getting a syntax error? any kind of message?

or does the query run but produce no output?

have you tried displaying the terms in the SELECT for all rows?

Reply With Quote
  #7  
Old May 17th, 2004, 11:46 AM
phoe22 phoe22 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 11 phoe22 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
parameter zip code's lat and long

I can't figure out how to access the parameter zip code's latitude and longitude. If I try [Enter Zip Code].Longitude it wants another parameter.

Reply With Quote
  #8  
Old May 17th, 2004, 12:02 PM
r937's Avatar
r937 r937 is offline
SQL Consultant
Dev Shed God 24th Plane (16500 - 16999 posts)
 
Join Date: Feb 2003
Location: Toronto Canada
Posts: 16,743 r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 3 Weeks 2 Days 21 h 15 m 22 sec
Reputation Power: 870
use [latitude] and [longitude], not [foo].latitude and [foo].longitude

Reply With Quote
  #9  
Old May 17th, 2004, 01:18 PM
phoe22 phoe22 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 11 phoe22 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
it still doesn't work. what is [foo] mean? i've tried [Enter Zip Code].[Longitude], i've tried [Enter Zip Code].Longitude, and i've tried [Longitude]. i'm getting so many parameter entry boxes that i don't want.

here is my code:

SELECT *
FROM tblCustomer2
WHERE (69.1 *(tblAll_Zips_Lat_Long.[Longitude] - [Enter Zip Code].[Longitude]) * cos((tblAll_Zips_Lat_Long.[Latitude]) / 57.3)
) ^ 2
+ (69.1 * (tblAll_Zips_Lat_Long.Latitude -[Enter Zip Code].[Latitude])
) ^ 2
< 50 ^ 2;

Reply With Quote
  #10  
Old May 17th, 2004, 01:45 PM
r937's Avatar
r937 r937 is offline
SQL Consultant
Dev Shed God 24th Plane (16500 - 16999 posts)
 
Join Date: Feb 2003
Location: Toronto Canada
Posts: 16,743 r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 3 Weeks 2 Days 21 h 15 m 22 sec
Reputation Power: 870
see, that's the problem with table names that have to be qualified, i can't tell which is a table name and which is a user prompt

something like this perhaps?
Code:
SELECT *
  FROM tblCustomer2
 WHERE (
       69.1 
     * ( tblAll_Zips_Lat_Long.[Longitude] 
       - [Enter Zip Code Longitude]
       ) 
     * cos( tblAll_Zips_Lat_Long.[Latitude] / 57.3 )
       ) ^ 2 
     + (
       69.1 
     * ( tblAll_Zips_Lat_Long.Latitude 
       - [Enter Zip Code Latitude]
       )
       ) ^ 2
     < 50 ^ 2


now the only problem you might have is reconciling the FROM table of tblCustomer2 with the qualifying tablename tblAll_Zips_Lat_Long which is apparently not defined anywhere...

Reply With Quote
  #11  
Old May 18th, 2004, 11:43 AM
phoe22 phoe22 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 11 phoe22 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I ended up getting it to work a different way.

SELECT tblCustomer2.*, Sqr((69.1*([tblAll_Zips_Lat_Long].[Longitude]-(SELECT tblAll_Zips_Lat_Long.Longitude FROM tblAll_Zips_Lat_Long WHERE [tblAll_Zips_Lat_Long].[ZipCode] = [Enter Zip Code]))*Cos(([tblAll_Zips_Lat_Long].[Latitude])/57.3))^2+(69.1*([tblAll_Zips_Lat_Long].[Latitude]-(SELECT tblAll_Zips_Lat_Long.Latitude FROM tblAll_Zips_Lat_Long WHERE [tblAll_Zips_Lat_Long].[ZipCode] = [Enter Zip Code])))^2) AS Distance
FROM tblAll_Zips_Lat_Long INNER JOIN tblCustomer2 ON tblAll_Zips_Lat_Long.ZipCode = tblCustomer2.ZipCode
WHERE ((((69.1*([tblAll_Zips_Lat_Long].[Longitude]-(SELECT tblAll_Zips_Lat_Long.Longitude FROM tblAll_Zips_Lat_Long WHERE [tblAll_Zips_Lat_Long].[ZipCode] = [Enter Zip Code]))*Cos(([tblAll_Zips_Lat_Long].[Latitude])/57.3))^2+(69.1*([tblAll_Zips_Lat_Long].[Latitude]-(SELECT tblAll_Zips_Lat_Long.Latitude FROM tblAll_Zips_Lat_Long WHERE [tblAll_Zips_Lat_Long].[ZipCode] = [Enter Zip Code])))^2)<[Enter distance in miles]^2));

How can i Order By Distance??
Every time i try it it gives me a syntax error.
Thanks for your help

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > POW() SQL Function, CF4, and Access 2000


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.