473,416 Members | 1,918 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,416 software developers and data experts.

Access 2000 bug?

Dan
I hate it when people think that their own misunderstandings are bugs
in the program, but this time I think I've got something.

If I run the following SQL code in Access 2000, I get unexpected
results:

SELECT MY_FIELD
FROM
(
SELECT NULL AS MY_FIELD FROM DUAL
UNION ALL
SELECT 1.1 AS MY_FIELD FROM DUAL
)
WHERE MY_FIELD IS NOT NULL;

(I used a dummy table 'DUAL' to simplify the test, but you can get the
same results from any table)

I expect '1.1' to be the result, but I get nothing. Yet, if you replace
the '1.1' in the query with a string (say, "hello"), you get the
"hello" just as you should. Date values are also lost. So far, strings
seem to be the only values that survive the SELECT. Integers produce
junk characters sometimes.

In case anyone is confused by my example, here's an explanation:

The the inner expression (SELECT NULL AS MY_FIELD FROM DUAL UNION ALL
SELECT 1.1 AS MY_FIELD FROM DUAL) is expected to result in a temporary
relation (table) that consists of this:

MY_FIELD
--------
NULL
1.1

If you just run that much in Access, everything's fine.

Now, when we select the non-null value out of the relation (WHERE
MY_FIELD IS NOT NULL), you should get 1.1, but you don't. You get a
blank row.

Here's just the outer expression:

SELECT MY_FIELD
FROM
()
WHERE MY_FIELD IS NOT NULL;

Not very complex.

The weirdness really comes out when you replace the 1.1 with "hello".
Then everything works fine. Replace it with #1/1/01#, and it breaks
again. I'm pretty sure that the type of the field really shouldn't
matter, but it does.

Oh yea, and if you reverse the order of the SELECTs in the UNION ALL
expression, it also works properly. As far as I know, the order of the
SELECTs in a UNION ALL shouldn't influence the result (except in the
ordering of the resulting rows)

If you don't like my example, you can do something like this to
reproduce the same problem:

Given the tables:

-- MY_FRIENDS --

FULL_NAME BIRTHDATE
--------- ---------
JILL NULL

and

-- YOUR_FRIENDS --

FULL_NAME BIRTHDATE
--------- ---------
BILL 1/1/2001

You can do this:

(
SELECT * FROM MY_FRIENDS
UNION ALL
SELECT * FROM YOUR_FRIENDS
)

And get:

FULL_NAME BIRTHDATE
--------- ---------
JILL NULL
BILL 1/1/2001

Now, try to select the rows that aren't NULL:

SELECT * FROM
(
SELECT * FROM MY_FRIENDS
UNION ALL
SELECT * FROM YOUR_FRIENDS
)
WHERE BIRTHDATE IS NOT NULL;

You'd expect 'BILL 1/1/2001', right? Well, you get a row, but it's
blank. Put another row in YOUR_FRIENDS (with a non-NULL birthdate) and
you get two blank rows! Again, using strings instead or reordering the
SELECT's fixes it. That just doesn't make sense.

So, can someone point out my misunderstanding?

Dan

Nov 13 '05 #1
3 1920
Hi Dan

JET determines the data type of a calculated/literal query field by looking
at the first few rows. In the case of a UNION query, it is the first few
rows of the SELECT query. If the field is Null in all rows (as in your
example), JET settles on it being a Text field, even though the following
SELECT is a numeric value. This results in the non-text data of the
following SELECTs being incorrectly interpreted.

The usual workaround is to use an IIf() expression to give Access some way
to figure out the data type to use for Null. Try:
SELECT IIf(False, 1, NULL) AS MY_FIELD FROM DUAL
UNION ALL
SELECT 1.1 AS MY_FIELD FROM DUAL

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Dan" <da************@gmail.com> wrote in message
news:11*********************@z14g2000cwz.googlegro ups.com...
I hate it when people think that their own misunderstandings are bugs
in the program, but this time I think I've got something.

If I run the following SQL code in Access 2000, I get unexpected
results:

SELECT MY_FIELD
FROM
(
SELECT NULL AS MY_FIELD FROM DUAL
UNION ALL
SELECT 1.1 AS MY_FIELD FROM DUAL
)
WHERE MY_FIELD IS NOT NULL;

(I used a dummy table 'DUAL' to simplify the test, but you can get the
same results from any table)

I expect '1.1' to be the result, but I get nothing. Yet, if you replace
the '1.1' in the query with a string (say, "hello"), you get the
"hello" just as you should. Date values are also lost. So far, strings
seem to be the only values that survive the SELECT. Integers produce
junk characters sometimes.

In case anyone is confused by my example, here's an explanation:

The the inner expression (SELECT NULL AS MY_FIELD FROM DUAL UNION ALL
SELECT 1.1 AS MY_FIELD FROM DUAL) is expected to result in a temporary
relation (table) that consists of this:

MY_FIELD
--------
NULL
1.1

If you just run that much in Access, everything's fine.

Now, when we select the non-null value out of the relation (WHERE
MY_FIELD IS NOT NULL), you should get 1.1, but you don't. You get a
blank row.

Here's just the outer expression:

SELECT MY_FIELD
FROM
()
WHERE MY_FIELD IS NOT NULL;

Not very complex.

The weirdness really comes out when you replace the 1.1 with "hello".
Then everything works fine. Replace it with #1/1/01#, and it breaks
again. I'm pretty sure that the type of the field really shouldn't
matter, but it does.

Oh yea, and if you reverse the order of the SELECTs in the UNION ALL
expression, it also works properly. As far as I know, the order of the
SELECTs in a UNION ALL shouldn't influence the result (except in the
ordering of the resulting rows)

If you don't like my example, you can do something like this to
reproduce the same problem:

Given the tables:

-- MY_FRIENDS --

FULL_NAME BIRTHDATE
--------- ---------
JILL NULL

and

-- YOUR_FRIENDS --

FULL_NAME BIRTHDATE
--------- ---------
BILL 1/1/2001

You can do this:

(
SELECT * FROM MY_FRIENDS
UNION ALL
SELECT * FROM YOUR_FRIENDS
)

And get:

FULL_NAME BIRTHDATE
--------- ---------
JILL NULL
BILL 1/1/2001

Now, try to select the rows that aren't NULL:

SELECT * FROM
(
SELECT * FROM MY_FRIENDS
UNION ALL
SELECT * FROM YOUR_FRIENDS
)
WHERE BIRTHDATE IS NOT NULL;

You'd expect 'BILL 1/1/2001', right? Well, you get a row, but it's
blank. Put another row in YOUR_FRIENDS (with a non-NULL birthdate) and
you get two blank rows! Again, using strings instead or reordering the
SELECT's fixes it. That just doesn't make sense.

So, can someone point out my misunderstanding?

Dan

Nov 13 '05 #2
Dan,
To back Allen up, if you invert your UNION ALL

SELECT MY_FIELD
FROM
(
SELECT 1.1 AS MY_FIELD FROM DUAL
UNION ALL
SELECT NULL AS MY_FIELD FROM DUAL
)
WHERE MY_FIELD IS NOT NULL;

Or if you explicitly say the field is numeric e.g.

SELECT csng(MY_FIELD)
FROM
(
SELECT 1.1 AS MY_FIELD FROM DUAL
UNION ALL
SELECT NULL AS MY_FIELD FROM DUAL
)
WHERE MY_FIELD IS NOT NULL;

You will get the result you originally expected

--
Terry Kreft
MVP Microsoft Access
"Allen Browne" <Al*********@SeeSig.Invalid> wrote in message
news:42***********************@per-qv1-newsreader-01.iinet.net.au...
Hi Dan

JET determines the data type of a calculated/literal query field by looking at the first few rows. In the case of a UNION query, it is the first few
rows of the SELECT query. If the field is Null in all rows (as in your
example), JET settles on it being a Text field, even though the following
SELECT is a numeric value. This results in the non-text data of the
following SELECTs being incorrectly interpreted.

The usual workaround is to use an IIf() expression to give Access some way
to figure out the data type to use for Null. Try:
SELECT IIf(False, 1, NULL) AS MY_FIELD FROM DUAL
UNION ALL
SELECT 1.1 AS MY_FIELD FROM DUAL

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Dan" <da************@gmail.com> wrote in message
news:11*********************@z14g2000cwz.googlegro ups.com...
I hate it when people think that their own misunderstandings are bugs
in the program, but this time I think I've got something.

If I run the following SQL code in Access 2000, I get unexpected
results:

SELECT MY_FIELD
FROM
(
SELECT NULL AS MY_FIELD FROM DUAL
UNION ALL
SELECT 1.1 AS MY_FIELD FROM DUAL
)
WHERE MY_FIELD IS NOT NULL;

(I used a dummy table 'DUAL' to simplify the test, but you can get the
same results from any table)

I expect '1.1' to be the result, but I get nothing. Yet, if you replace
the '1.1' in the query with a string (say, "hello"), you get the
"hello" just as you should. Date values are also lost. So far, strings
seem to be the only values that survive the SELECT. Integers produce
junk characters sometimes.

In case anyone is confused by my example, here's an explanation:

The the inner expression (SELECT NULL AS MY_FIELD FROM DUAL UNION ALL
SELECT 1.1 AS MY_FIELD FROM DUAL) is expected to result in a temporary
relation (table) that consists of this:

MY_FIELD
--------
NULL
1.1

If you just run that much in Access, everything's fine.

Now, when we select the non-null value out of the relation (WHERE
MY_FIELD IS NOT NULL), you should get 1.1, but you don't. You get a
blank row.

Here's just the outer expression:

SELECT MY_FIELD
FROM
()
WHERE MY_FIELD IS NOT NULL;

Not very complex.

The weirdness really comes out when you replace the 1.1 with "hello".
Then everything works fine. Replace it with #1/1/01#, and it breaks
again. I'm pretty sure that the type of the field really shouldn't
matter, but it does.

Oh yea, and if you reverse the order of the SELECTs in the UNION ALL
expression, it also works properly. As far as I know, the order of the
SELECTs in a UNION ALL shouldn't influence the result (except in the
ordering of the resulting rows)

If you don't like my example, you can do something like this to
reproduce the same problem:

Given the tables:

-- MY_FRIENDS --

FULL_NAME BIRTHDATE
--------- ---------
JILL NULL

and

-- YOUR_FRIENDS --

FULL_NAME BIRTHDATE
--------- ---------
BILL 1/1/2001

You can do this:

(
SELECT * FROM MY_FRIENDS
UNION ALL
SELECT * FROM YOUR_FRIENDS
)

And get:

FULL_NAME BIRTHDATE
--------- ---------
JILL NULL
BILL 1/1/2001

Now, try to select the rows that aren't NULL:

SELECT * FROM
(
SELECT * FROM MY_FRIENDS
UNION ALL
SELECT * FROM YOUR_FRIENDS
)
WHERE BIRTHDATE IS NOT NULL;

You'd expect 'BILL 1/1/2001', right? Well, you get a row, but it's
blank. Put another row in YOUR_FRIENDS (with a non-NULL birthdate) and
you get two blank rows! Again, using strings instead or reordering the
SELECT's fixes it. That just doesn't make sense.

So, can someone point out my misunderstanding?

Dan


Nov 13 '05 #3
Dan
I see. I'm coming from a different background (Oracle, originally), so
I'm not very familiar with JET-specific behavior.

I'd *like* to think that ANSI SQL produces the same results regardless
of the DB engine behind it, but I know that that's not very realistic
at the moment.

Thanks for the expertise everyone.

Nov 13 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
by: chicha | last post by:
Hey people, I have to convert MS Access 2000 database into mysql database, the whole thing being part of this project I'm doing for one of my faculty classes. My professor somehow presumed I...
2
by: Scott | last post by:
Any help would be grateful :-) Problem: When I test my installation of Access 2000 MDE, I get the following error: "Unrecognised Format".. This means that Access 97 cannot read Access 2000. ...
3
by: Pat | last post by:
We have a database with Access 97 as the front-end and SQL7 as the back end. It is on a network server and accessed by joining a MS Access Workgroup. We are trying to add a new user and have...
3
by: Scott | last post by:
Hi, If we want to compile an Access 2002 database and distribute it to others, will the compiled software run on any PC, like Windows 98, Windows 2000, etc. Also, you don't have to have...
6
by: Serious_Practitioner | last post by:
....or lack thereof... I use Access 2000 which I own as part of Office 2000 Professional. I've had enough trouble with glitches to ask if these are common occurrences - 1. Sometimes the "Help"...
2
by: Jeff | last post by:
Does anyone know of any potential problems running a 2000 database with 2003? Also, what about installing all other Office products as 2003 versions but leaving Access as 2002 running a 2000...
47
by: ship | last post by:
Hi We need some advice: We are thinking of upgrading our Access database from Access 2000 to Access 2004. How stable is MS Office 2003? (particularly Access 2003). We are just a small...
0
by: com | last post by:
MS Access 2000 Password Recoverer 4.2 Screenshot - Soft30.com MS Access 2000 Password Recoverer will display the password to a MS Access database (*.mdb). This program works for MS Access files...
5
by: Mo | last post by:
Hello all, I'm trying to set up an access 2000 .adp project connecting to a SQL server 2005 database. I can set up the connection ok, but once I have completed the setup process, I get the...
3
by: NEWSGROUPS | last post by:
I am in the midst of trying to convert about 25 Access 2000 to Access 2003. The new environment consists of Office/Access 2003 and Outlook 2003. When converting the back ends I have no problems....
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.