Tag Archives: error

[Pascal Error] YourUnit.pas(224): E2015 Operator not applicable to this operand type

I’ve got this error when was concatinating stings to build pl/sql call. Here’s an example code:

      sql := 'begin '  +
        packageName + '.calc_report(' +
          ' in_dateend=>to_date('''+ LMRFrm.a_Date2_i + ''',''dd/mm/yyyy''),' +
          ' in_code_list=>''' + LMRFrm.a_ListCat_i + ''',' +
          ' in_currency=>''' + LMRFrm.a_currency + ''',' +
          ' in_kr=>''' + LMRFrm.a_kr + ''',' +
          ' in_vseason=>''' + LMRFrm.a_season + ''',' +
          ' in_level=>''' + IfThen( ( 1 = LMRFrm.a_family_agg ), 'FAMILYSC', 'SC' ) + ''',' +
          ' in_filter=>''' + LMRFrm.a_filter + ''',' +
          ' in_report_code=>''' + LMRFrm.a_tpl_code + ''',' +
          ' in_version=>''' + IfThen( _useDevPackage , 'DEV' , 'PROD' ) + ''',' +
          ' in_week_data=>''' + IfThen( ( 1 = LMRFrm.a_week_data) , 'WEEK_DATA ', '' ) + IfThen( ( '1' = LMRFrm.a_show_sparks ), 'TRENDS ', '' ) +  IfThen( ( 1 = LMRFrm.a_full ) , 'FINANCIAL ', '' ) + ''',' +
          ' in_cache_options=>''' + IfThen( LMRFrm.a_use_cache, '', 'BYPASS' ) + ''''
          + ' ); '
          + packageName + '.create_xls( ''' + LMRFrm.a_tpl_code + ''',''' + IfThen( _useDevPackage , 'DEV' , 'PROD' ) + ''');'
          + packageName + '.fill_tmp_lmr_flat; ' + // tmp_lmr_flat используется для выгрузки картинок
      + 'end;';

Can you spot an error? Don’t think you can do it at a glance. Neither could I. So I had to comment line after a line till I found an extra plus sign near the last comment.
So the error was saying: I can not increment the string that I’ve build so far. Strings are not numbers dude.
‘Operator not applicable to this operand type’ is not very informative message. And it came without pointing to the exact line. As always.

VBA: Run-time error 3001 Arguments Are Of The Wrong Type… when setting ADODB.Command object members

This forum post saved my day.
I was trying to run Oracle stored procedure with output parameters from Excel VBA with the following piece of code:


Dim cmd As Object
Dim resultSet As Object
Set cmd = CreateObject("ADODB.Command")
With cmd
.CommandText = "PK_AUTH.LOGON"
.NamedParameters = True
.Parameters.Append .CreateParameter("login", adVarChar, adParamInput, 50, login_)
.Parameters.Append .CreateParameter("pass", adVarChar, adParamInput, 50, pass_)
.Parameters.Append .CreateParameter("ldb", adVarChar, adParamOutput, 50)
.Parameters.Append .CreateParameter("pdb", adVarChar, adParamOutput, 50)
.CommandType = adCmdStoredProc
.ActiveConnection = GetConn_()
Set resultSet = .Execute
ldb_ = .Parameters.Item("ldb")
End With

And I always got Run-time error 3001 ‘Arguments Are Of The Wrong Type, Are Out Of The Acceptable Range, or are in conflict with one another’ upon invocation of

.CommandType = adCmdStoredProc

or

.Parameters.Append .CreateParameter(...)

no matter which statement I placed first.
After fighting for a while I found this post that stated that error is fired because of late binding of library references, so VB simply did not know of adCmdStoredProc and other constants
That meant that this error has nothing to do with ADODB or Ole or, I just said that it does not know the value of constant. Not very informative in fact…
So, I simply added


Const adVarChar As Long = 200
Const adParamInput As Long = &H1
Const adParamOutput As Long = &H2
Const adCmdStoredProc As Long = &H4

to the Sub header and everything worked fine. Constants are defined in c:Program FilesCommon FilesSystemadoadovbs.inc