Re: How to delete a record with the key which contains "%20"(space) in the front?
Posted in 2003
David, I made a test scenario:
CREATE MY_TABLE
( my_char char(6));
ALTER TABLE MY_TABLE
ADD CONSTRAINT
UNIQUE (my_char) CONSTRAINT u1_my_table;
INSERT INTO MY_TABLE VALUES("kerry ");
Then upon trying to insert ("kerry")
268: Unique constraint (informix.u1_my_table) violated.
100: ISAM error: duplicate value for a record with unique key.
Error in line 1Near character position 35
This proves that "kerry " and "kerry" are the same.
So why be concerned about them?
Then I inserted the " kerry" value. This was allowed as " kerry" and
"kerry " are different.
Then I deleted the "kerry " value and inserted "kerry". This also was
allowed as " kerry" and "kerry" are different.
Now I deleted only " kerry" not "kerry" with subscripting.
DELETE FROM MY_TABLE WHERE my_char[1] = " ";
HTH,
Zev Berezin
Informix DBA
B&H Photo ~ http://www.bhphoto.com
Email: zevb@bhphoto.com
On 26 May 2003, at 18:29, David wrote:
> When adding record, there are a lot of cases that user accidently add
> space sign "%20" in the front or end of the key.
>
> Let's say:
>
> Key is defined as "name".
>
> When the user put " Kerry" or "Kerry " as key and create this record,
> it will cause Database error when the second guy adds "Kerry"(No
> spaces)
>
> What SQL syntax will make sure deleting " Kerry" and "Kerry " safely?
> Thx
>
>
>
>
>
>