Options

How does Navision execute Stored Procedure in Nav SQL DB?

jemmyjemmy Member Posts: 247
Dear Folks,

A little question:
How does Navision execute Stored Procedure in Navision SQL DB?

Anyone could explain to me briefly, better with a few examples. :?

Still reading chapter 3 in Navision Solution Dev....

Thanks in advance,

Jemmy

Comments

  • Options
    ArhontisArhontis Member Posts: 667
    Hi Jemmy,

    I I understand correctly, you want to execute an sp from an SQL Server.

    I will write a quick example of connecting, getting an sp from a db, executing and displaying some data:
    Automation variables:
      autSQLServer 'Microsoft SQLDMO Object Library'.SQLServer	
      autDatabases 'Microsoft SQLDMO Object Library'.Databases	
      autDB 'Microsoft SQLDMO Object Library'.Database	
      autStoredProcedures 'Microsoft SQLDMO Object Library'.StoredProcedures
      autSP 'Microsoft SQLDMO Object Library'.StoredProcedure	
      res 'Microsoft SQLDMO Object Library'.QueryResults	
    
    the code you could use:
      CREATE(autSQLServer);
      autSQLServer.Connect(servername, username, password);
      //get databases
      autDatabases:=autSQLServer.Databases;
      //get first db (master)
      autDB:=autDatabases.ItemByID(1);
      //get stored procedures list
      autStoredProcedures:=autDB.StoredProcedures;
      //find the dt_verstamp006 stored procedure
      i:=1;
      WHILE autStoredProcedures.Item(i).Name <> 'dt_verstamp006' DO
        i:=i+1;
      autSP:=autStoredProcedures.Item(i);
      res:=autDB.ExecuteWithResults(autSP.Name);
      
      MESSAGE(res.GetColumnString(1,1));
      
      autSQLServer.DisConnect;
      autSQLServer.Close;
      CLEARALL;
    
  • Options
    jemmyjemmy Member Posts: 247
    Hi Arhontis,

    This is great, buddy! :D:D
    Thanks, I think you are very good on these.. (you write quickly) :!:
    I'll try and let you know the result...
Sign In or Register to comment.