<< ibec_SetEnvironmentVariable | IBEBlock | ibec_SetLength >>

ibec_SetGlobalVar

ibec_SetGlobalVar allows you to create/modify a global variable. This function always returns 0.

Syntax

 function ibec_SetGlobarVar
    (VarName : string; VarValue : variant):variant;

Description

If you're using the ibec_SetGlobalVar function within scripts executed with IBEScript, it is not necessary to free global variables - they will be destroyed automatically after the script has finished.

If you're using the ibec_SetGlobalVar function within IBExpert (SQL Editor or the Script Executive), any global variables created will continue to exist until you close IBExpert. So if necessary, you should free them manually using the ibec_FreeGlobalVar function.

Example

The following example illustrates the use of this function, together with ibec_GetGlobalVar, described within an SQL script:

     CONNECT ...;

     execute ibeblock
     as
     begin
       select myfield from mytable
       where something = 25
       into :MyVar;
       ibec_SetGlobalVar('MyGlobalVar', MyVar);
     end;

     ...

     execute ibeblock
     as
     begin
       MyVar = ibec_GetGlobalVar('MyGlobalVar', null);
       if (MyVar = 1) then
         insert into mytable ...;
       else if (MyVar = 2) then
         update mytable set ...;
     end;

back to top of page
<< ibec_SetEnvironmentVariable | IBEBlock | ibec_SetLength >>