1000 0 1 1 2 0 0 Log ktluser 3. Augta 2008 18:31 ktluser 16. Septa 2008 20:20 48,24 1,16,13,576,228,17 Arial, 15 0,Model Rdbreader,2,2,0,1,C:\temp\RDB_reader_3.ANA Var info 0 272,24,1 160,16 1,0,0,1,0,0,0,214,0,1 Var_info Var result 0 272,56,1 160,16 1,0,0,1,0,0,0,214,0,1 Var_result Var result 1 272,88,1 160,16 1,0,0,1,0,0,0,72,0,1 Var_result ODBC Contains the parameters for the open database connectivity (ODBC). 'Driver={MySQL ODBC 5.1 Driver};Server=10.66.10.102;Database=resultdb;User=result_reader; Password=ora4ever;Option=3' 56,152,1 48,12 1,1,0,1,1,1,0,,0, (var_name:text, run_id:optional) Readdata Reads the data about the var_name variable from the result database. Uses the run_id run if specified; otherwise uses the newest run of that variable. PARAMETERS: * Var_name: the name of the variable in the result database. * Run_id: the identifier of the run from which the results will be brought. If omitted, the newest result will be brought. if isnotspecified(run_id) then run_id:= newestrun(var_name); index i:= DBquery(Odbc,'SELECT Variable.var_name, var_unit, Loc_of_result.result_id, result, sample, dim_name, ind_name, location, Run.run_id, run_method FROM Variable, Result, Loc_of_result, Location, Dimension, `Index`, Run_list, Run WHERE Variable.var_name = "'&Var_name&'" AND Run.run_id = '&Run_id&' AND Variable.var_id = Loc_of_result.var_id AND Loc_of_result.result_id = Result.result_id AND Loc_of_result.loc_id = Location.loc_id AND Loc_of_result.ind_id = `Index`.ind_id AND Location.dim_id = Dimension.dim_id AND Loc_of_result.result_id = Run_list.result_id AND Run_list.run_id = Run.run_id'); index j:= dblabels(i); dbtable(i,j) 56,88,1 48,16 2,739,343,516,428 39325,65535,39321 var_name,run_id (var_name:text) Newestrun This function checks for the newest result (according to run_id) of the variable. The function is used if the user does not define the run_id as an optional parameter in functions Do_first and Readdata. PARAMETERS: * Var_name: the name of the variable in the result database. * Run_id: the identifier of the run from which the results will be brought. If omitted, the newest result will be brought. index i:= DBquery(Odbc,'SELECT Run_id FROM Variable , Loc_of_result, Run_list WHERE Variable.var_name = "'&Var_name&'" AND Variable.var_id = Loc_of_result.var_id AND Loc_of_result.result_id = Run_list.result_id'); index j:= dblabels(i); max(max(dbtable(i,j),i),j) 56,120,1 48,16 2,687,222,476,566 39325,65535,39321 var_name (var_name:text; run_id, textornot:optional) RDB to var Brings the data from the result database and transforms it into variables of the correct form. NOTE! All necessary indices must be created before running this function. The necessary indices can be viewed by calling the function Do_first with the same parameters as this function. PARAMETERS: * Var_name: the name of the variable in the result database. * Run_id: the identifier of the run from which the results will be brought. If omitted, the newest result will be brought. * Textornot: Tells whether the result is numerical or text. If parameter is omitted or false, numerical is assumed, otherwise text. 1) Brings the data and makes indices for index list, locations, and result_id's. 2) Makes an array containing result_id, indexed by all indices and all locations. 3) Makes an array containing result_id, indexed by the indices of the variable itself. 4) Brings the results into the structure created in 3). Makes the sample fo along the index Run. var data:= readdata(var_name, run_id); var a:= data[.j='ind_name']; index ind_name:= a[.i=unique(a,a.i)]; a:= data[.j='location']; index location:= a[.i=unique(a,a.i)]; a:= data[.j='result_id']; index result_id:= a[.i=unique(a,a.i)]; var x:= 1; a:= null; while x<= size(data.i) do ( var b:= data[@.i=x]; a:= if location = b[.j='location'] and ind_name = b[.j='ind_name'] and result_id = b[.j='result_id'] then b[.j='result_id'] else a; x:= x+1); var c:= result_id; x:= 1; while x<=size(ind_name) do ( c:= if c= a[location=evaluate(ind_name[@ind_name=x]), @ind_name=x] then result_id else 0; x:=x+1); c:= sum(c,result_id); a:= data[.j='sample']; index sample:= a[.i=unique(a,a.i)]; x:= 1; a:= null; while x<= size(data.i) do ( var b:= data[@.i=x]; a:= if c = b[.j='result_id'] and sample = b[.j='sample'] then b[.j='result'] else a; x:= x+1); a:= if max(sample)>0 then a[sample=run] else a[@sample=1]; if isnotspecified(textornot) or textornot=false then evaluate(a) else a 56,56,1 48,16 2,797,5,476,803 var_name,run_id,textornot (var_name:text; run_id:optional) Do first This function brings the variable from the Result Database and analyses its structure. Each index used will be shown as a column along '.Ind_name', and each location of that index will be shown along '.K'. The last row of '.K' shows the samplesize of the variable. Use this information to create the necessary indices for your model and to adjust the samplesize of the model. If the samplesize of the model is smaller than in the result database, the remaining samples are omitted; if larger, the cells with no results in the database are replaced with null. NOTE! The indices created should be lists of labels (not lists of numbers). PARAMETERS: * Var_name: the name of the variable in the result database. * Run_id: the identifier of the run from which the results will be brought. If omitted, the newest result will be brought. if isnotspecified(run_id) then run_id:= newestrun(var_name); var data:= readdata(var_name, run_id); index j:= ['ind_name','location']; var a:= data[.j=j]; index i:= unique(a,a.i); a:= a[.i=i]; index ind_name:= a[i=unique(a[j='ind_name'], i), j='ind_name']; a:= if ind_name=a[j='ind_name'] then a[j='location']; index b:= ['Sample size']; var d:= array(b,[max(data[.j='sample'])]); concat(a,d,i,b) 56,24,1 48,16 2,304,371,476,436 var_name,run_id Var info do_first('Testvariable') 168,128,1 48,12 [Formnode Var_info1] Var result rdb_to_var('Testvariable') 168,152,1 48,12 [Formnode Var_result1, Formnode Var_result2] Dimensions index i:= DBquery(odbc,'SELECT Dim_id, Dim_name FROM `Dimension` '); index j:= ['Dim_id','Dim_name']; DBTable(i, j ) 376,128,1 48,12 1,1,0,1,1,1,0,0,0,0 2,922,53,316,489,0,MIDM 39325,65535,39321 [Sys_localindex('J'),Sys_localindex('I')] Indices index i:= DBquery(odbc,'SELECT Ind_id, Ind_name, Dimension.Dim_id, Dim_name FROM `Index`, Dimension WHERE `Index`.Dim_id=Dimension.Dim_id '); index j:= ['Ind_id','Ind_name','Dim_id','Dim_name']; DBTable(i, j ) 376,152,1 48,12 1,1,0,1,1,1,0,0,0,0 2,-73,97,476,296 2,740,152,481,493,0,MIDM 39325,65535,39321 [Sys_localindex('J'),Sys_localindex('I')] Locations index i:= DBquery(odbc,'SELECT Loc_id, Location, Dimension.Dim_id, Dim_name FROM `Location`, `Dimension` WHERE Location.Dim_id = Dimension.Dim_id '); index j:= ['Loc_id', 'Location', 'Dim_id', 'Dim_name']; DBTable(i, j) 272,128,1 48,12 1,1,0,1,1,1,0,0,0,0 2,102,90,476,445 2,530,55,696,521,0,MIDM 39325,65535,39321 [Sys_localindex('J'),Sys_localindex('I')] Variables This node checks the variables listed in Var_for_rdb and makes an index of those that are NOT found in the result database. This is then used as an index in Inp_var for adding variable information. index i:= DBquery(odbc,'SELECT Var_id, Var_name FROM `Variable` '); index j:= ['Var_id','Var_name']; var a:= DBTable(i, j ); a 272,152,1 48,12 1,1,0,1,1,1,0,0,0,0 2,254,142,493,501 2,529,143,331,437,0,MIDM 39325,65535,39321 [Sys_localindex('J'),Sys_localindex('I')] ['H1991'] [Self,1,Sys_localindex('I'),1,Sys_localindex('J'),1]