Print Thread
TLobLocator parameter in a writing Package function
#1109 10/17/00 06:52 PM
Joined: Oct 2000
Posts: 4
Reutlingen, Germany
S
Member
OP Offline
Member
S
Joined: Oct 2000
Posts: 4
Reutlingen, Germany
I have the following problem: I have a package function which expects a CLOB as an IN parameter and writes the passed data to the DB.

The Package Wizard creates the following prototype for this function:

[quote]
Code
PL/SLQ: 
function CL_Write( arg_key in varchar2,
                   arg_name in varchar2,
                   arg_value in clob )
                   return integer;

Delphi:
function ClWrite(const ArgKey: string; 
                 const ArgName: string; 
                 ArgValue: TLOBLocator): 
               Double;
[/quote]

When I try to write data using this function I get an access violation error. My test code is:
[quote]
Code
var
  LL: TLobLocator;
begin
  LL := TLobLocator.Create(Session, otClob);
  try
    ClWrite (aKey, aName, LL);
    LL.AsString := 'A';
  finally
    LL.Free;
  end;
end;
[/quote]

What's going wrong here?

Re: TLobLocator parameter in a writing Package function
#1110 10/20/00 05:33 PM
Joined: Aug 1999
Posts: 22,220
Member
Offline
Member
Joined: Aug 1999
Posts: 22,220
What does the PL/SQL code look like that sets the CLOB?

------------------
Marco Kalter
Allround Automations


Marco Kalter
Allround Automations
Re: TLobLocator parameter in a writing Package function
#1111 10/20/00 05:46 PM
Joined: Oct 2000
Posts: 4
Reutlingen, Germany
S
Member
OP Offline
Member
S
Joined: Oct 2000
Posts: 4
Reutlingen, Germany
[quote]
Code
  function CL_Write( arg_key in varchar2,
                  arg_name in varchar2,
                  arg_value in out clob )
                  return integer
  ...
  ... Retrieve lnPrefKey ...

  insert into g$prefvalues
  ( prefkey_id, name, datatype, clobvalue )
    values
  ( lnPrefKey, bv_arg_name, 'CL', arg_value );

  else

  update g$prefvalues
  set clobvalue = arg_value
  where bv_arg_name = name
        and
        prefkey_id = lnPrefKey;

  ...
[/quote]

[This message has been edited by Stefan Heymann (edited 20 October 2000).]

Re: TLobLocator parameter in a writing Package function
#1112 10/20/00 07:32 PM
Joined: Aug 1999
Posts: 22,220
Member
Offline
Member
Joined: Aug 1999
Posts: 22,220
In this PL/SQL Code the arg_value (which has now become in out by the way [Linked Image]) is never assigned a value. You must make sure that the LOB Locator is initialized in the PL/SQL Code. For example:
[quote]
Code
update g$prefvalues
  set clobvalue = empty_clob()
  where bv_arg_name = name
  and prefkey_id = lnPrefKey
  returning clobvalue into arg_value;
[/quote]
The returning .. into .. clause assigns the initialized CLOB to the parameter, which you can subsequently use to write the data.


------------------
Marco Kalter
Allround Automations


Marco Kalter
Allround Automations

Moderated by  support 

Link Copied to Clipboard
Powered by UBB.threads™ PHP Forum Software 7.7.4
(Release build 20200307)
Responsive Width:

PHP: 7.1.33 Page Time: 0.033s Queries: 13 (0.007s) Memory: 2.5098 MB (Peak: 3.0418 MB) Data Comp: Off Server Time: 2024-05-20 00:53:24 UTC
Valid HTML 5 and Valid CSS