Invalid cast in while calling Stored procedure

Posts   
 
    
Rostizh
User
Posts: 7
Joined: 25-Jan-2007
# Posted on: 20-Apr-2009 15:19:07   

We use LLBLGen Pro 2.6 build apr. 2009. We generated a DataLayer using the Oracle DB driver. Also, we want to call a stored procedure that accepts 4 parameters. The code generated accepts as the 3rd param an Int64 ref parameter. Every time we call the generated method, we get an Invalid Cast exception. In a line uses a converter class to convert the parameter to the Int64.

Thanks,

Roland

Rostizh
User
Posts: 7
Joined: 25-Jan-2007
# Posted on: 20-Apr-2009 15:26:15   

We're using the MS Oracle driver.

Rostizh
User
Posts: 7
Joined: 25-Jan-2007
# Posted on: 20-Apr-2009 15:32:35   

We did a rollback to LLBLGen 2.5 and it works normally. Any hints welcome.

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 20-Apr-2009 15:43:15   

Every time we call the generated method, we get an Invalid Cast exception. In a line uses a converter class to convert the parameter to the Int64

We need a code snippet, the exception text, and the stack trace.

Rostizh
User
Posts: 7
Joined: 25-Jan-2007
# Posted on: 20-Apr-2009 16:15:06   

Stack trace:

bij Specificaties.OracleUser.DataLayer.StoredProcedureCallerClasses.ActionProcedures.ApaoBomExplode(String aspartno, Int16 anmultilevel, Decimal& returnValue, Int64& anuniqueid) in D:\\Projecten\\Ontwikkeling\\Specificaties\\OracleUserDataLayer\\StoredProcedureCallerClasses\\ActionProcedures.cs:regel 64

Exception message:

The specified cast is invalid

The code that calls the LLBLGen code:

        
decimal procesStatus = 0;
long bomReferentienummer = 0;
        OracleUser.DataLayer.StoredProcedureCallerClasses.ActionProcedures.ApaoBomExplode(procesData.Artikelnummer, procesData.ExplosionNiveau, ref procesStatus, ref bomReferentienummer);

The generated code: (we're not doing anything that has to do with a detonation of any kind, I promise :-)) The line with ** is where the exception occurs.

        
public static int ApaoBomExplode(System.String aspartno, System.Int16 anmultilevel, ref System.Decimal returnValue, ref System.Int64 anuniqueid)
{
   // create parameters
  OracleParameter[] parameters = new OracleParameter[4];
  parameters[0] = ParameterCreator.Create("RETURN_VALUE", OracleDbType.Decimal, ParameterDirection.ReturnValue, 0, 22, 0, returnValue);
  parameters[1] = ParameterCreator.Create("ASPARTNO", OracleDbType.Varchar2, ParameterDirection.Input, 4000, 0, 0, aspartno);
  parameters[2] = ParameterCreator.Create("ANMULTILEVEL", OracleDbType.Decimal,  ParameterDirection.Input, 0, 1, 0, anmultilevel);
  parameters[3] = ParameterCreator.Create("ANUNIQUEID", OracleDbType.Decimal,     ParameterDirection.Output, 0, 13, 0, anuniqueid);
  // Call the stored proc.
  int toReturn = DbUtils.CallActionStoredProcedure("INTERSPC.APAO_BOM.EXPLODE", parameters, null);
            if((ValueConverter.Convert(parameters[0])!=null) && (ValueConverter.Convert(parameters[0])!=System.DBNull.Value))
            {
                returnValue = (System.Decimal)ValueConverter.Convert(parameters[0]);
            }
            if((ValueConverter.Convert(parameters[3])!=null) && (ValueConverter.Convert(parameters[3])!=System.DBNull.Value))
            {
        **anuniqueid = (System.Int64)ValueConverter.Convert(parameters[3]);         }
            for(int i=0;i<4;i++)
            {
                if(parameters[i] != null)
                {
                    parameters[i].Dispose();
                }
            }
            return toReturn;
        }
daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 21-Apr-2009 05:44:31   

Stack trace:

Please post the complete stack trace.

Also please post the script of your stored procedure, to see whether or not the problem resides on the SP script.

David Elizondo | LLBLGen Support Team
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39859
Joined: 17-Aug-2003
# Posted on: 21-Apr-2009 10:25:58   

Also, please mention the type the anuniqueid parameter has in the designer. It should be decimal, MS Oracle doesn't support any other type for numbers besides Decimal.

Frans Bouma | Lead developer LLBLGen Pro