Store Procedure

raffraff Member Posts: 2
edited 2004-05-04 in Navision Attain
How i can call a Store Procedure of SQL from navision 3.70

Tanks

Comments

  • wonmowonmo Member Posts: 139
    The c/ocx granule should be able to do this by using ado.
  • RobertMoRobertMo Member Posts: 484
    This is my boss' trick, so he should get all the credits:

    Make a table "Navi2SQL" with two fields:
    "Code" Code10 (Primary Key)
    "SQL Statement" Text255
    
    and set DataPerCompany=No

    Add a function:
    ExecuteSQL(MySQLStatement as Text255)
    BEGIN
    IF NOT GET THEN INSERT;
    "SQL Statement" := MySQLStatement;
    MODIFY;
    END;
    
    Then go to the SQL EM and open the table there, open triggers and add trigger onUpdate. write a sql code that takes new value of "SQL Statement" and runs exec on this (like exec @mystr)

    Example:
    To run SQL proceudre on button:
    define global or local:
    rNavi2SQL record Navi2SQL
    OnPush:
    rNavi2SQL.ExecuteSQL('spMySQLProcedure');

    this way you can run lots of different SQL statements from Navison... you are limited only by error handling and returning values, but you can extand the table with some error fields that you will handel in SQL trigger...
    usfull for UPDATE and DELETE (runs faster), but you should know very very well what are you doing !!!
               ®obi           
    ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Sign In or Register to comment.