Page 1 of 1

Detect OraSession.Options.CharLength don't work

Posted: Thu 23 Jun 2005 07:29
by nschmied
Hello,
In your help file you say
Setting CharLength to zero will instruct TOraSession to interrogate Oracle server for the actual character length.
OK greats, I have test this fonction

Code: Select all

  OraSession1.Open;
  OraSession1.Options.CharLength := 0;
  SHowMessage('CharLength '+IntToStr(OraSession1.Options.CharLength));
But ShowMessage display always "CharLength 0".

You make work this option CharLength ????

Tanks you,

Posted: Fri 24 Jun 2005 14:40
by Alex
This is designed behaviour, value 0 in CharLength property indicates that next time we will query CharLength from server again. This can be useful when you connect to different servers using one TOraSession object.

Posted: Mon 27 Jun 2005 07:05
by nschmied
OK it's a designed behaviour.
I place value 0 in design time, and in runtime I open the session.

Code: Select all

  OraSession1.Open; 
  //OraSession1.Options.CharLength := 0;
  SHowMessage('CharLength '+IntToStr(OraSession1.Options.CharLength));
But the value is always 0. I have make test with different server was different char length, but the property return 0 !!!!!

Posted: Mon 27 Jun 2005 15:08
by Alex
As I mentioned earlier it is designed behaviour that CharLength property doesn't change its value from 0 to exact server char length, the value 0 indicates to user and ODAC that exact value will be obtained automatically. If you need to get charlentgh you should do it manually, for example with such SQL :

Code: Select all

BEGIN
  SELECT Nvl(Lengthb(Chr(65536)), Nvl(Lengthb(Chr(256)), 1)) INTO :CharLength FROM dual
END

Posted: Thu 30 Jun 2005 06:02
by nschmied
OK well but I does not understand for which reason, you return 0 value whereas you know the real value.

Code: Select all

function TOCIConnection.GetProp(Prop: integer; var Value: variant): boolean;
begin
  Result := True;
  case Prop of
    prMaxStringSize:
      Value := GetMaxStringSize;
    prCharLength:
      if FQueryCharLength then
        Value := 0
      else
        Value := FCharLength;
    prCharset:
{...}  else
    Result := inherited GetProp(Prop, Value);
  end;
end;
whats happen if I puts this in comment

Code: Select all

//      if FQueryCharLength then
//        Value := 0
//      else

Posted: Thu 30 Jun 2005 09:28
by Alex
This will bring unsatisfactory design-time behaviour : when you set CharLength property to 0, connect and get other property value. There is an opportunity to split design-time and run-time CharLength behaviour, but such decision is out of ODAC concept.

Posted: Thu 30 Jun 2005 09:56
by nschmied
OK, but finally I have My own property CharacterSize, and I use
your code

Code: Select all

BEGIN
  SELECT Nvl(Lengthb(Chr(65536)), Nvl(Lengthb(Chr(256)), 1)) INTO :Result FROM dual;
END;
It's better for ODAC Update :wink: