How do I insert CLOB into LOB attribute of a TOracleQueue.Payload

ajeeth

Member
Im trying to enqueue a text message (size greater than 4000 ) into an Oracle Queue of message type AQ$_JMS_TEXT_MESSAGE. As per Oracle documentation, I must insert the message into the TEXT_LOB field of the object if size is greater than 4000. I have tried using the following Delphi code:

Code:
var
 myMsg: TOracleObject;
 myMsg2: TOracleObject;
 myText_LOB: TLOBLocator;
 msg2send: String;
begin
// Try to connect, create the queue objects, and start it if necessary
  if not SendSession.Connected then
    begin
     SendSession.LogOn;
    end;
  myMsg := SendQueue.Payload;
  msg2send := SendMessageEdit.Text;
  if Length(msg2send) > 4000 then
  begin
  myMsg2 := myMsg.Reference.Pin(poAny, plNone);
  myText_LOB :=        myMsg2.LOBAttr('TEXT_LOB');
  if myText_LOB.IsNull then
  begin
    myText_LOB.SetEmpty;
    myMsg2.Flush;
    myMsg2.Refresh;
  end
  else begin
    myMsg2.Lock;
  end;
  myText_LOB.Write(msg2send, Length(msg2send));
  myText_LOB.Trim;
  myMsg2.SetAttr('TEXT_LEN', Length(msg2send));
  myText_LOB.Free;
end
else begin
  myMsg.SetAttr('TEXT_LEN', Length(msg2send));
  myMsg.SetAttr('TEXT_VC', msg2send);
end;
  //Send to queue and commit
  SendQueue.Enqueue;
  SendSession.Commit;
Running the above code, I get the following error message if I try to enqueue a message greater than 4000 bytes.

Code:
Project xyz.exe raised exception class EOracleError wit message 'OCI-21710: argument is expecting a valid memory address of an object'
For smaller messages, enqueueing work without a problem.
I have also tried using the set_text procedure of AQ$_JMS_TEXT_MESSAGE to set the message using the following delphi code

Code:
myMsg.CallMethod('SET_TEXT', ['PAYLOAD', msg2send]);
But this raises exception with the following message:

Code:
'Overloaded methods not supported:SET_TEXT. Use a PL/SQL block instead.'
--
FYI: Im using Delphi5 + DOA 4.0.6 + Oracle 10g (10.1.0.2)database
 
Back
Top