Thoughts from Dan Miser RSS 2.0
# Monday, January 16, 2006
As I alluded to in an earlier post, I had troubles using the nz() function from a TADODataset in Delphi. Take the following SQL, which works just fine in Access itself:


SELECT DISTINCT ContestId, Hole, nz(Score,'MISSING')
FROM tblContestDetails

This query behaves like isnull() in MSSQL where if the Score column is null, it returns the value 'MISSING' instead. If Score isn't null, then the value of Score would be returned. To me, this syntax is very intuitive, corresponds well with other DBMS' isnull() functions, and clearly captures the intent of what you're trying to do in once concise statement. However, if you put this query in a TADODataset and try to open that dataset, you will be greeted with the following error: "Undefined function 'nz' in expression.". If you need this type of substitution in Access when executing from Delphi, I found the simplest way to get around this is to use the iif() and isnull() functions. It's more verbose, and I don't like it as much, but when you need things to work, some times you have to live with things that aren't aesthetically pleasing. The SQL above translates to this:


SELECT DISTINCT ContestId, Hole, iif(isnull(Score),'MISSING', Score)
FROM tblContestDetails
Monday, January 16, 2006 9:12:00 AM (Central Standard Time, UTC-06:00)  #    Comments [5] -
Delphi
Tracked by:
http://9np-information.info/79065331/index.html [Pingback]
http://9ng-information.info/30465174/index.html [Pingback]
http://9ne-information.info/11620345/index.html [Pingback]
http://9nn-information.info/09177368/index.html [Pingback]
http://9nv-information.info/42700593/index.html [Pingback]
http://9nb-information.info/35124514/index.html [Pingback]
http://9nq-information.info/27131041/index.html [Pingback]
http://9nw-information.info/92106675/index.html [Pingback]
http://9nh-information.info/54724631/index.html [Pingback]
http://9qg-information.info/55541280/iwc-orologio-concessionaria.html [Pingback]
http://9qe-information.info/03760093/guy-hair.html [Pingback]
http://9qb-information.info/49998659/index.html [Pingback]
http://9qf-information.info/00462180/index.html [Pingback]
http://9qd-information.info/09493030/index.html [Pingback]
http://9qh-information.info/71410561/index.html [Pingback]
http://9oa-information.info/80602183/mushroom-system-hair-test.html [Pingback]
http://9qi-information.info/57464798/my-font.html [Pingback]
http://9ol-information.info/66906765/index.html [Pingback]
http://9qk-information.info/82048888/index.html [Pingback]
http://9oh-information.info/78036263/index.html [Pingback]
http://9se-information.info/79486509/index.html [Pingback]
http://9ra-information.info/54987164/index.html [Pingback]
http://9sn-information.info/55621046/uhc.html [Pingback]
http://9so-information.info/74411793/gang-bang-pic.html [Pingback]
http://9rf-information.info/17921016/index.html [Pingback]
http://9rs-information.info/64128585/city-planner-training.html [Pingback]
http://9ru-information.info/98203867/index.html [Pingback]
http://9sg-information.info/78391118/index.html [Pingback]
http://9uaek-le-informazioni.info/80902870/index.html [Pingback]
http://9uaea-le-informazioni.info/45505675/index.html [Pingback]
http://9uafo-le-informazioni.info/97655312/index.html [Pingback]
http://9uaep-le-informazioni.info/30881389/index.html [Pingback]
http://9uaeo-le-informazioni.info/86749695/calendario-mese-aprile-2007.html [Pingback]
http://9uaea-le-informazioni.info/86252840/index.html [Pingback]
http://9uafd-le-informazioni.info/12774393/index.html [Pingback]
http://9uafa-le-informazioni.info/00826748/index.html [Pingback]
http://9uahj-le-informazioni.info/46568368/index.html [Pingback]
http://9uagl-le-informazioni.info/76088770/index.html [Pingback]
http://9uagc-le-informazioni.info/06680027/stemma-comune-casalbeltrame.html [Pingback]
http://9uaga-le-informazioni.info/43346194/index.html [Pingback]
http://9uagt-le-informazioni.info/85387599/index.html [Pingback]
http://9uahl-le-informazioni.info/90754480/graphic-book.html [Pingback]
http://9uahg-le-informazioni.info/68084344/casey-vidalenc.html [Pingback]
http://9uahn-le-informazioni.info/96952263/netmeeting-port-forwarding.html [Pingback]
Monday, January 16, 2006 9:06:00 PM (Central Standard Time, UTC-06:00)
Just curious, why are you using Access for this project? My opionion is that Access is suitable for home apps such as cookbooks and oil change schedules. I thought I read somewhere that MS was dropping it altogether. Don't have the link though, perhaps one of your readers could verify this. My last client used Access for a business app and this left a lot to be desired IMO. Specifically Ansi queries sometimes didn't work, the ole object type seemed to put 27 extra characters in front of the data therefore requiring an operation to strip off, the project required specific merge modules that weren't backwards compatible, and we had record locking problems early on. We were able to solve all of these but it was time consuming. Just my .02 for whatever it's worth. I've used Apollo with good success (which comes with .NET drivers and also Delphi) and I believe there's a host of others equally as good.
Johannes
Monday, January 16, 2006 9:18:00 PM (Central Standard Time, UTC-06:00)
This is not for a business app. I wanted something that was ubiqutous, stand-alone, and easy to use. Access fits all of those criteria, and not much else does.



The people that use this application are computer illiterate, so I won't entertain anything that can break, or anything that has extra install requirements. Furthermore, I don't want (or need) the extra overhead of something like Firebird.



Access works for the most part, but there are some issues (as you rightly noted). But that just gives me more reasons to learn and blog. :-)
Tuesday, January 17, 2006 7:25:00 AM (Central Standard Time, UTC-06:00)
Sometimes I just create the Query in the Access Database and call the Query. You lose the flexibility, but tends to save time in programming and execution. I had to place the following in a Query because a clients computer was not properly executing the SQL statement but was executing the Access Query. Update Techs Set Name = Mid(Name, 1, 23) where Mid(Name, 1, 24) = '*'. It worked on my machine no problem, but the client had 2 machines it would not work on.
Tom Birch
Tuesday, January 17, 2006 10:31:00 AM (Central Standard Time, UTC-06:00)
Agree with Tom Birch, also...if you create the query or queries in access as query objects, you can then call them on the client as stored procedures.
Johannes
Tuesday, January 17, 2006 10:45:00 AM (Central Standard Time, UTC-06:00)
Good point. That is a suitable work-around for these kinds of issues in a lot of cases. Still doesn't work for me because I want dynamic SQL stored in an INI file that is used to drive reports in the application.
Comments are closed.
Navigation
Archive
<February 2012>
SunMonTueWedThuFriSat
2930311234
567891011
12131415161718
19202122232425
26272829123
45678910
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2012
Dan Miser
Sign In
Statistics
Total Posts: 375
This Year: 3
This Month: 0
This Week: 0
Comments: 654
Themes
Pick a theme:
All Content © 2012, Dan Miser
DasBlog theme 'Business' created by Christoph De Baene (delarou)