User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 397,590 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,898 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 1539 | Replies: 0
Reply
Join Date: Aug 2005
Posts: 1
Reputation: BinFrog is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
BinFrog BinFrog is offline Offline
Newbie Poster

calling a SQL UDF?

  #1  
Aug 16th, 2005
Hi everyone,

I have a SQL statement that runs just fine:

select
distinct(b.swName), a.mwBillToCompanyID, a.mwPaymentTerm, c.swCountry, d.mwCommCode, e.mwGRWarehouse, e.mwDongle,
case when e.mwExportStatus in ('B','C','EL','EUS') then
'End Use Required'
else
'No End Use Required'
end as 'EndUse', dbo.mw_Get_Distrib_Countries(a.mwBillToCompanyID) as 'Countries in Territory',
mwDiscountName, dbo.mw_Get_Distrib_Discounts(a.mwBillToCompanyID) as 'Discount Amounts'
from mw_office_info a
join sw_customer b on a.mwBillToCompanyID = swCustomerID
join sw_address c on b.swCustomerID = c.swObjectID and c.swObjectType = 'CUSTOMER'
join sw_Provider_Grp d on b.mwProviderGrpID = d.swProviderGrpID
join mw_Country e on c.swCountry = e.mwCountry
join sw_territory f on d.swTerritoryID = f.swTerritoryID
join sw_coverage on f.swTerritoryID = sw_coverage.swTerritoryID and f.swActive='1'
join sw_Region r on sw_coverage.swregionID =r.swRegionID
JOIN MW_DISCOUNT_PROGRAMS p on a.mwChannelDiscountID = p.mwDiscountID
JOIN MW_DISCOUNT_XREF dx ON dx.mwDiscountId = p.mwDiscountId
JOIN MW_DISCOUNT_RULES r1 ON dx.mwRuleId = r1.mwruleId
JOIN MW_RULES_XREF rx ON r1.mwRuleId = rx.mwRuleId
JOIN MW_DISCOUNT_CONSTRAINTS c1 ON c1.mwConstraintId = rx.MwConstraintId
where c.swCountry = 'AU'
and mwEffectiveFrom<=getDate() AND mwEffectiveTo>=getDate() AND
mwValue='95' AND mwConstraintName='ProductLineConstraint'
ORDER BY mwDiscountName


As you can see, the last 2 columns are from user-defined functions. For some reason PHP doesn't like the syntax though and it seems to think they are some sort of table. I have tried everything. I created a very simple UDF and tried to get PHP to display the results, and that works just fine. I tried embedding the SQL above into a stored procedure and calling the SP, but it fails. However, like I did with a simple UDF, I created a simple SProc which ran just fine. So for some reason it seems to just not like that SQL I wrote, even though the SQL itself runs just fine in Query Analyzer.

Any ideas how to get PHP to stop trying to do anything to the code and just let SQL handle it entirely? It's like PHP is trying to do some sort of error handling and code validation and it doesn't like that part of the SQL code for some reason.

Thanks!
AddThis Social Bookmark Button
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb PHP Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 6:03 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC