You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Emmanuel Dupont <em...@jwaretechnologies.com> on 2003/12/04 19:05:18 UTC

Oracle and Char[size]

All,

 

I am working with Ojb RC4, Oracle 9i. 

 

I have a table with a PK with char[5] size. When I update with the value
"FR" OJB tries to insert "FR   ". And so it does an insert instead of an
update when I still have a "FR" value in my PK.

 

I didn't have this trouble with SQLServer..I quiet sure it should be
possible to specify this somewhere .? No ?

 

I didn't find anything in the archive on it.

 

 

Thanks a lot in advance.

 

 

 


RE : Oracle and Char[size]

Posted by Emmanuel Dupont <em...@jwaretechnologies.com>.
Thanks a lot Martin !!



-----Message d'origine-----
De : Martin Kalén [mailto:martin.kalen@curalia.se] 
Envoyé : jeudi 4 décembre 2003 19:08
À : OJB Users List
Objet : Re: Oracle and Char[size]

Emmanuel Dupont wrote:

> I have a table with a PK with char[5] size. When I update with the value
> "FR" OJB tries to insert "FR   ". And so it does an insert instead of an
> update when I still have a "FR" value in my PK.

You could:

A) comply with char[5] and use the String "FR   " with OJB.

B) define the PK as varchar[5] where "FR" would work just fine (not sure 
wether Ora9i would like varchar as PK though?).


Same thing goes for Oracle and OJB Criteria. If you did
critera.addEqualTo("pkAlias", "'FR'")
char[5] would give you a miss, but varchar[5] would give a hit.

criteria.addEqualTo("pkAlias", "'FR   '") is the only one that would 
match char[5]
(or addLike("pkAlias", "'FR%'") but that is ambigous).

Cheers,
  Martin

-- 
Martin Kalén
Curalia AB              Web:  http://www.curalia.se
Orrspelsvägen 2B        Mail: info@curalia.se
SE-182 79  Stocksund    Tel:  +46-8-410 064 40


---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: Oracle and Char[size]

Posted by Martin Kalén <ma...@curalia.se>.
Emmanuel Dupont wrote:

> I have a table with a PK with char[5] size. When I update with the value
> "FR" OJB tries to insert "FR   ". And so it does an insert instead of an
> update when I still have a "FR" value in my PK.

You could:

A) comply with char[5] and use the String "FR   " with OJB.

B) define the PK as varchar[5] where "FR" would work just fine (not sure 
wether Ora9i would like varchar as PK though?).


Same thing goes for Oracle and OJB Criteria. If you did
critera.addEqualTo("pkAlias", "'FR'")
char[5] would give you a miss, but varchar[5] would give a hit.

criteria.addEqualTo("pkAlias", "'FR   '") is the only one that would 
match char[5]
(or addLike("pkAlias", "'FR%'") but that is ambigous).

Cheers,
  Martin

-- 
Martin Kalén
Curalia AB              Web:  http://www.curalia.se
Orrspelsvägen 2B        Mail: info@curalia.se
SE-182 79  Stocksund    Tel:  +46-8-410 064 40


---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org