Type Variant!!!

Hanen
Hanen Member Posts: 281
edited 2009-08-11 in SQL General
Hello,

Variant type for field table doesn't exist in navision?
I have a stored procedure that contains some fields and a sum of amounts and I call it from navision and the result is an error message even if I store the sum in field of mytable datatype decimal.
How can I resolve that problem????
I'll be greatful for your help!!!
Regards

Hanen TALBI

Comments

  • kriki
    kriki Member, Moderator Posts: 9,121
    Try first to store the variant in a local variable of type decimal. Then put that variable into the field of the table.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • ara3n
    ara3n Member Posts: 9,258
    hello

    Could you provide a little more information on how you are calling the stored proc?
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • garak
    garak Member Posts: 3,263
    maybe he must use the CAST() command in his SP.
    How looks your SP, how do you call it from NAV (ADO?) and how do you store the result of the SP?
    Do you make it right, it works too!
  • Hanen
    Hanen Member Posts: 281
    edited 2009-08-27
    That's the code:
    //************************************ Open sql connection *******************
    
    ltxtConnectionString:='Provider=SQLNCLI;Server=xxxxx;Database=xxxxxxxxx;Trusted_Connection=yes;';
    IF ISCLEAR(lADOConnection) THEN CREATE(lADOConnection);
    lADOConnection.ConnectionString:=ltxtConnectionString;
    lADOConnection.Open;
    
    //************************************ Execute SP *************************
    
    lvarActiveConnection := lADOConnection;
    IF ISCLEAR(lADOCommand) THEN CREATE(lADOCommand);
    lADOCommand.ActiveConnection := lvarActiveConnection;
    lADOCommand.CommandText := 'repartition';
    lADOCommand.CommandType := 4; 
    lADOCommand.CommandTimeout := 0;    
    
    
    lADOCommand.Execute; 
    
    IF ISCLEAR(lADORecordset) THEN 
    CREATE(lADORecordset);
    
    lADORecordset.ActiveConnection := lvarActiveConnection; 
    lADORecordset.Open(lADOCommand);    
     repartition007.DELETEALL;
    WHILE NOT lADORecordset.EOF DO BEGIN  
    
    repartition007.INIT;
    repartition007.Code := lADORecordset.Fields.Item('code').Value;
    repartition007.Designation:= lADORecordset.Fields.Item('designation').Value;
    repartition007.Nombre := lADORecordset.Fields.Item('nombre').Value;
    repartition007.Duree :=  lADORecordset.Fields.Item('duree').Value;
    repartition007.Montant := lADORecordset.Fields.Item('montant').Value;
    repartition007.PU := lADORecordset.Fields.Item('pu').Value;
    
    repartition007.INSERT;
    
    lADORecordset.MoveNext; 
    
    END;
    
    //******************************** Close sql connection **********************
    
    lADOConnection.Close; 
    CLEAR(lADOConnection);
    
    

    Regards

    Hanen TALBI
  • garak
    garak Member Posts: 3,263
    is one of these fields a decimal field?

    So you can add in yous SP select statement something like that (mean the CAST() method:
    Select cast (TheDecimalField as float)
    

    A good example you can find here: viewtopic.php?f=5&t=23038


    Regards
    Do you make it right, it works too!
  • Hanen
    Hanen Member Posts: 281
    I've tried with cast ( myfield as decimal) but id didn't work the result is too big :(
    Regards

    Hanen TALBI