The purpose of the ODBC interface is to make it possible to integrate VARKON applications with traditional database applications. A VARKON application could for example automatically fetch parameter values for a specific design, automatically generate a drawing or model, calculate new data and put that data back into the database.
Here is a short example:
MACRO MODULE show_price(INT dnr >"Detail number !"); STRING sql_statement*132,price*10; INT status; BEGINMODULE !* !***Connect to the database. !* status:=odbc_connect("My_database", "My_name", "My_password");
if status < 0 then exit(odbc_error()); endif; !* !***Build SELECT statement. !* sql_statement:="SELECT price FROM My_table WHERE dnr="+str(dnr,-1,0)); !* !***Execute. !* status:=odbc_execdirect(sql_statement);
if status < 0 then exit(odbc_error()); endif; !* !***Get first line of result. !* status:=odbc_fetch();
if status < 0 then exit(odbc_error()); endif; !* !***Get first data on this line. !* status:=getstring(price);
if status < 0 then exit(odbc_error()); endif; !* !***Close the connection. !* odbc_disconnect(); !* !***Display result. !* lst_ini(); lst_lin("Price is:"+price); lst_exi(); ENDMODULE
Copyright © Microform AB Henningholmsgatan 4 S-703 69 Örebro SWEDEN E-mail: info@microform.se
VARKON Homepage | Index |