This looks like a BDE bug.
I have a VIEW on a table that contains 26591 rows.
The table looks like
CREATE TABLE People(
account character(12) NOT
NULL,
last_name character
varying(20)
NULL,
first_name character(15) NULL,
mi character(1) NULL,
name_prefix character(8) NULL,
name_suffix character(8) NULL,
addr1 character(30) NULL,
addr2 character(30) NULL,
city character(27) NULL,
state character(2) NULL,
zip character(10) NULL,
country_code character(2) NULL,
email character(50) NULL,
date_of_birth datetime NULL,
sex character(1) NULL,
ssno character(11) NULL,
file_number character(20) NULL
PRIMARY KEY (account))
There is a small table for phone numbers:
CREATE TABLE Pat_Phones(
account character(12) NOT
NULL,
phone_sequence integer NOT NULL,
phone_type character(10) NULL,
phone_number character(20) NULL)
and finally, the VIEW looks like
CREATE VIEW People_View
AS SELECT
PE.account,
name = ( last_name + ',' + first_name + ' ' + COALESCE(MI, '') ),
PE.addr1,
PE.city,
PE.state,
PE.zip,
PE.email,
PE.ssno,
PE.date_of_birth,
PP.phone_number
FROM
people PE
LEFT JOIN Pat_Phones PP
ON (PE.account = PP.account and PP.phone_sequence = 1)
So here's the problem:
When I do
SELECT * FROM People_View WHERE name >= 'A' AND name <= 'Azzzzzz'
I get a BDE error 13059 (null violation) and a native error 515
(indeed
this is the error code you get when you try to insert NULLs into a
column that doesn't allow them, but I am NOT doing an INSERT).
I am also getting an error dialog that says
General SQL Error.
Cannot insert the value NULL into column '', table ''; column does
not allow nulls.
This SELECT statement works PERFECTLY from ISQL/w (Called Query
Analyzer
now in SQL 7). It only gives the error when executing the query in
Delphi.
If I do a more restrictive query like
SELECT * FROM People_View WHERE name >= 'AAR' AND name <= 'AARzzzzzz'
it works fine everywhere. Anything that returns less that about 400
rows is OK with the WHERE clause.
Lastly,
SELECT * FROM People_View
works fine also.
I am using D4.03 c/s, BDE 5.01 (latest), SQL Links, and MSSQL 7
This only seems to occur on the People_View.name column. If I do the
selects on the base table it works find everywhere.
Can anyone suggest a solution to this problem? Is the BDE somehow
trying
to insert NULLs somewhere in a NOT NULL column?
Thanks!
Jim