Subject | Re: [firebird-support] Charset of OCTETS in PK causing problems? |
---|---|
Author | Helen Borrie |
Post date | 2004-06-16T14:53:15Z |
At 02:44 PM 16/06/2004 +0000, you wrote:
instead of a VARCHAR. Character set OCTETS is "just bytes" so all of those
blank spaces to the right are ascii(32). If your key is CHAR(13) then
'123DEF' is stored as '123DEF*******' (I'm representing blanks as *) and is
NOT equal to '123DEF'.
Convert them to VARCHAR and it will be fine.
/heLen
>I finally got around to changing all my Primary Keys and Foreign KeysHmm, the problem is probably that you are using a CHAR type for the PK,
>(which are 13 chars and only contain A-Z,0-9) to Charset of OCTETS to
>reduce the space used... with the idea that more space=more indicies
>on page=faster queries
>
>Everything went fine... but now when I run a query like this
>
>SELECT * FROM MYTABLE WHERE ID='123ABC'
>
>it does _not_ find the record ! and it is sitting right there
>
>Now if I change the query to read
>
>SELECT * FROM MYTABLE WHERE ID LIKE '123ABC%'
>
>then it finds the record... so I figured that were was maybe
>something funny with the rec... so then I did this
>
>INSERT INTO MYTABLE COLUMNS('ID','MYVALUE') VALUES('123DEF','FOO')
>
>I committed the changes, and then ran
>
>SELECT * FROM MYTABLE WHERE ID='123DEF'
>
>again it cannot find the record... and now I know the exact value
>because I just inserted the record...
>
>Can someone please tell me what is going on... is this because I am
>now using OCTETS...
instead of a VARCHAR. Character set OCTETS is "just bytes" so all of those
blank spaces to the right are ascii(32). If your key is CHAR(13) then
'123DEF' is stored as '123DEF*******' (I'm representing blanks as *) and is
NOT equal to '123DEF'.
Convert them to VARCHAR and it will be fine.
/heLen