Oracle10gXe - the size problem
Moderators: gto, cipto_kh, EgonHugeist
Oracle10gXe - the size problem
I am getting this error when executing sql below, altough i check before with several cmds: ( fSongFieldSize = 60 )
song:= Copy(trackInfoRec.song,1,fSongFieldSize);
SetLength(song,fSongFieldSize);
fSongInsQuery.Params.ParamValues[SongColName]:='';
fSongInsQuery.Params.ParamValues[SongColName]:= song;
[Exception: SQL Error: ORA-12899: Wert zu groß für Spalte "FREEDB"."SONGS"."SONG" (aktuell: 61, maximal: 60)
This is more than strange, because debugger also says string only has length of 60, even if i shorten it to 60-1 the exception raises.
Does anyone had similar problems?
Furthermore it seems that i only have the problem for special strings of length (60), because some of same length are already written to db.
Does it maybe has sth to do with the charset?
NLS_CHARACTERSET AL32UTF8, NLS_NCHAR_CHARACTERSET AL16UTF16
Any help is appreciated..
song:= Copy(trackInfoRec.song,1,fSongFieldSize);
SetLength(song,fSongFieldSize);
fSongInsQuery.Params.ParamValues[SongColName]:='';
fSongInsQuery.Params.ParamValues[SongColName]:= song;
[Exception: SQL Error: ORA-12899: Wert zu groß für Spalte "FREEDB"."SONGS"."SONG" (aktuell: 61, maximal: 60)
This is more than strange, because debugger also says string only has length of 60, even if i shorten it to 60-1 the exception raises.
Does anyone had similar problems?
Furthermore it seems that i only have the problem for special strings of length (60), because some of same length are already written to db.
Does it maybe has sth to do with the charset?
NLS_CHARACTERSET AL32UTF8, NLS_NCHAR_CHARACTERSET AL16UTF16
Any help is appreciated..
fabian
-
- Fresh Boarder
- Posts: 8
- Joined: 29.05.2006, 08:42
Re: Oracle10gXe - the size problem
Unicode needs more than one byte for certain characters. Before you create your tables execute this:Terence wrote: [Exception: SQL Error: ORA-12899: Wert zu groß für Spalte "FREEDB"."SONGS"."SONG" (aktuell: 61, maximal: 60)
NLS_CHARACTERSET AL32UTF8, NLS_NCHAR_CHARACTERSET AL16UTF16
alter session set nls_length_semantics=char
This is only necessary while creating tables.
LP, Tomaž
Because i want to be independet of what length the db admin has defined for my field i check at initialization how long the field is via:
query.SQL.Append('SELECT '+SongColName);
query.SQL.Append('FROM '+SongTableName);
if not guessDbEmpty
then query.SQL.Append('WHERE '+SongIdColName+'=1');
query.Open;
fSongFieldSize:= query.FieldDefs.Find(SongColName).Size;
query.Close;query.Sql.Clear;
Then later i just use ...
song:= Copy(trackInfoRec.song,1,fSongFieldSize);
SetLength(song,fSongFieldSize);
..to make sure i got problems, but as i already imagined it is necesarry to calculate the allowed size dependet on the charset.
Does someone has an solution/idea how to do that, or a complete other way. That hast to work on all dbms (supported by zeos)!
Tx for hlp.
query.SQL.Append('SELECT '+SongColName);
query.SQL.Append('FROM '+SongTableName);
if not guessDbEmpty
then query.SQL.Append('WHERE '+SongIdColName+'=1');
query.Open;
fSongFieldSize:= query.FieldDefs.Find(SongColName).Size;
query.Close;query.Sql.Clear;
Then later i just use ...
song:= Copy(trackInfoRec.song,1,fSongFieldSize);
SetLength(song,fSongFieldSize);
..to make sure i got problems, but as i already imagined it is necesarry to calculate the allowed size dependet on the charset.
Does someone has an solution/idea how to do that, or a complete other way. That hast to work on all dbms (supported by zeos)!
Tx for hlp.
fabian
Re: Oracle10gXe - the size problem
Hi Toma!
" [Exception: SQL Error: ORA-12899: Wert zu groß für Spalte "FREEDB"."SONGS"."SONG" (aktuell: 64, maximal: 60)
I tried this, but error still remains, instead i get another length for the error - constantly 64, seetomazzupan wrote: Unicode needs more than one byte for certain characters. Before you create your tables execute this:
alter session set nls_length_semantics=char
This is only necessary while creating tables.
" [Exception: SQL Error: ORA-12899: Wert zu groß für Spalte "FREEDB"."SONGS"."SONG" (aktuell: 64, maximal: 60)
fabian
You can not change the character set after database creation, only by doing an export > create a new database with the new character set > import.
Understandably, as the present character set is "physically there". Still more so, if you want to change from a 1 byte to a 2 byte characterset. Do you want the database to "explode", changing instantly all characters from 1 to 2 bytes? And only for a session?
What you probably want ist the database to behave "as if" it had an 1 bit characterset, so zjat the data fits into your field. I didn't find such a parameter. Would be nice.
I didn't find a definition for NLS_NCHAR_CHARACTERSET and NLS_CHAR_CHARACTERSET (but didn't serch very thoroughly), I would also like to know it.
Greetings,
Rüdiger
Understandably, as the present character set is "physically there". Still more so, if you want to change from a 1 byte to a 2 byte characterset. Do you want the database to "explode", changing instantly all characters from 1 to 2 bytes? And only for a session?
What you probably want ist the database to behave "as if" it had an 1 bit characterset, so zjat the data fits into your field. I didn't find such a parameter. Would be nice.
I didn't find a definition for NLS_NCHAR_CHARACTERSET and NLS_CHAR_CHARACTERSET (but didn't serch very thoroughly), I would also like to know it.
Greetings,
Rüdiger
-
- Fresh Boarder
- Posts: 8
- Joined: 29.05.2006, 08:42
-
- Fresh Boarder
- Posts: 8
- Joined: 29.05.2006, 08:42
Re: Oracle10gXe - the size problem
Did you altered session *before* creating tables? If tables were created without this setting then length semantics for tables is set to byte.Terence wrote:Hi Toma!
I tried this, but error still remains, instead i get another length for the error - constantly 64, seetomazzupan wrote: Unicode needs more than one byte for certain characters. Before you create your tables execute this:
alter session set nls_length_semantics=char
This is only necessary while creating tables.
LP, Tomaž