1000 0 1 1 2 0 0 ktluser 3. Augta 2008 18:31 jtue 16. syyta 2008 16:49 48,24 1,16,13,466,228,17 Arial, 15 0,Model Rdbreader,2,2,0,1,C:\Documents and Settings\jtue\Local Settings\Temp\RDB_reader-3.ANA 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 (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