Problem with stored proc parameter of 30 charcter length

Discussion of open issues, suggestions and bugs regarding usage of dbExpress drivers for Oracle in Delphi and C++Builder
Post Reply
uno
Posts: 4
Joined: Thu 18 Feb 2016 07:41

Problem with stored proc parameter of 30 charcter length

Post by uno » Mon 14 Feb 2022 12:42

Hi, I have a problem when using TSqlStoredProc, last character of param name is replaced by #1 when length is 30

Delphi 10.4
Oracle 19
Driver 8.0.2

this call raises exception Parameter not found

Proc.Params.ParamByName('sVeryLong_30_Symbols_ParamName').AsString := 'test';

procedure

Code: Select all

  
create user test30 identified by 111;

grant connect to test30;

create or replace procedure Test30.TestLongParamName(sVeryLong_30_Symbols_ParamName in Varchar2, sParamName in Varchar2) as
begin
    null;
end;
pas

Code: Select all

unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Data.DB, Data.SqlExpr,
  {DBXDevartOracle,} Data.FMTBcd, dbxdynalink, Vcl.ExtCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Edit1: TEdit;
    Edit2: TEdit;
    Edit3: TEdit;
    RadioGroup1: TRadioGroup;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
  Conn: TSQLConnection;
  Proc: TSQLStoredProc;
  I: Integer;
begin
  Conn := TSQLConnection.Create(nil);
  if RadioGroup1.ItemIndex = -1 then
    raise Exception.Create('Choose driver');
  if RadioGroup1.ItemIndex = 0 then
  begin
    Conn.DriverName := 'DevartOracle';
    Conn.ConnectionName := 'Devart oracle';
  end
  else
  begin
    Conn.DriverName := 'DevartOracleDirect';
    Conn.ConnectionName := 'Devart oracle direct';
  end;
  Conn.LoadParamsFromIniFile('dbxconnections.ini');
  Conn.Params.Values['USEUNICODE'] := 'True';
  Conn.Params.Values['UNICODEENVIRONMENT'] := 'True';
  Conn.Params.Values['DATABASE'] := Edit1.Text;
  Conn.Params.Values['USER_NAME'] := Edit2.Text;
  Conn.Params.Values['PASSWORD'] := Edit3.Text;
  Conn.Open;
  Proc := TSQLStoredProc.Create(nil);
  Proc.SQLConnection := Conn;
  try
    Proc.CommandText := 'Test30.TestLongParamName';
    Proc.PrepareStatement;
    try
      Proc.Params.ParamByName('sParamName').AsString := 'test';
      Proc.Params.ParamByName('sVeryLong_30_Symbols_ParamName').AsString := 'test';
      Proc.ExecProc;
    except
      on E: Exception do
      begin
        E.Message := E.Message + #13#10'Param names are ';
        for I := 0 to Proc.Params.Count - 1 do
          E.Message := E.Message + #13#10 + Proc.Params[I].Name;
        raise;
      end;
    end;
  finally
    Proc.Free;
    Conn.Close;
    Conn.Free;
  end;
end;

end.
dfm

Code: Select all

object Form1: TForm1
  Left = 0
  Top = 0
  Caption = 'Form1'
  ClientHeight = 263
  ClientWidth = 447
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'Tahoma'
  Font.Style = []
  OldCreateOrder = False
  PixelsPerInch = 96
  TextHeight = 13
  object Label1: TLabel
    Left = 24
    Top = 88
    Width = 46
    Height = 13
    Caption = 'Database'
  end
  object Label2: TLabel
    Left = 24
    Top = 115
    Width = 51
    Height = 13
    Caption = 'User name'
  end
  object Label3: TLabel
    Left = 24
    Top = 144
    Width = 46
    Height = 13
    Caption = 'Password'
  end
  object Button1: TButton
    Left = 182
    Top = 180
    Width = 75
    Height = 25
    Caption = 'Button1'
    TabOrder = 0
    OnClick = Button1Click
  end
  object Edit1: TEdit
    Left = 88
    Top = 85
    Width = 169
    Height = 21
    TabOrder = 1
    Text = 'Edit1'
  end
  object Edit2: TEdit
    Left = 88
    Top = 112
    Width = 121
    Height = 21
    TabOrder = 2
    Text = 'Edit2'
  end
  object Edit3: TEdit
    Left = 88
    Top = 141
    Width = 121
    Height = 21
    TabOrder = 3
    Text = 'Edit3'
  end
  object RadioGroup1: TRadioGroup
    Left = 24
    Top = 8
    Width = 233
    Height = 65
    Caption = 'Driver'
    Items.Strings = (
      'DevartOracle'
      'DevartOracleDirect')
    TabOrder = 4
  end
end

Post Reply