LogResult database connectionHP_Omistaja9. maata 2008 10:42ktluser30. Augta 2008 20:05 48,241,0,0,1,1,1,0,0,0,01,32,57,824,511,17Arial, 150,Model Result_database_conn,2,2,-32766,1,Result database connection.ANA100,1,1,1,2,9,2970,2100,15,0Inp dim0144,168,1128,161,0,0,1,0,0,0,78,0,152425,39321,65535Input_dimLocs0144,272,1128,161,0,0,1,0,0,0,72,0,152425,39321,65535Locations2Inp run0144,448,1128,161,0,0,1,0,0,0,72,0,152425,39321,65535Input_runInp var0144,344,1128,161,0,0,1,0,0,0,72,0,152425,39321,65535Input_varVar for rdb0144,416,1128,161,0,0,1,0,0,0,70,0,152425,39321,65535Var_for_rdbDetailsjtue18. heita 2008 10:14 48,24744,288,148,241,236,12,969,495,17Concatenation UDFsThis library contains functions to make various instances of concatenation more convenient. Concat3 thru Concat10 are generalizations of the built-in Concat function which concatenate from 3 to 10 arrays in a single call (while the built-in Concat concatenates two arrays). ConcatRows concatenates all the rows of a single array.David Kendall & Lonnie ChrismanMon, Jan 26, 2004 8:49 AMLonnieWed, Sep 05, 2007 3:23 PM48,2472,248,168,241,0,0,1,1,1,0,0,0,01,39,36,798,452,23(A1, A2, A3: ArrayType; I1, I2, I3, J: IndexType )Concat3Concatenates three arrays, A1, A2, and A3. I1, I2, and I3 are the indexes that are joined; J is the index of the new array; J usually is the concatenation of I1, I2, and I3Index I12 := Concat(I1,I2);
Concat( Concat( A1,A2,I1,I2,I12 ), A3, I12, I3, J )88,64,148,262,56,56,986,596A1,A2,A3,I1,I2,I3,J(A1, A2, A3, A4: ArrayType; I1, I2, I3, I4, J: IndexType )Concat4Concatenates four arrays, A1, A2, A3, and A4. I1, I2, I3, and I4 are the indexes that are joined; J is the index of the new array; J usually is the concatenation of I1, I2, I3, and I4.Index I12 := Concat(I1,I2);
Index I123:= Concat(I12, I3);
Concat(
Concat(
Concat( A1,A2,I1,I2,I12 ),
A3, I12, I3, I123),
A4, I123, I4, J);
192,64,148,242,30,30,986,596A1,A2,A3,A4,I1,I2,I3,I4,J0(A1, A2, A3, A4, A5, A6, A7, A8, A9: ArrayType; I1, I2, I3, I4, I5, I6, I7, I8, I9, J: IndexType)Concat9Concatenates nine arrays, A1, ..., A9. I1, ..., I9 are the indexes joined; J is the index of the new array; J usually is the concatenation of I1, ..., I9.Index I12 := Concat(I1,I2);
Index I123 := Concat(I12, I3);
Index I1234 := Concat(I123, I4);
Index I12345 := Concat(I1234, I5);
Index I123456 := Concat(I12345, I6);
Index I1234567 := Concat(I123456, I7);
Index I12345678 := Concat(I1234567, I8);
Concat(
Concat(
Concat(
Concat(
Concat(
Concat(
Concat(
Concat( A1,A2,I1,I2,I12 ),
A3, I12, I3, I123),
A4, I123, I4, I1234),
A5, I1234, I5, I12345),
A6, I12345, I6, I123456),
A7, I123456, I7, I1234567),
A8, I1234567, I8, I12345678),
A9, I12345678, I9, J);88,232,148,242,27,120,469,638A1,A2,A3,A4,A5,A6,A7,A8,A9,I1,I2,I3,I4,I5,I6,I7,I8,I9,J0(A1, A2, A3, A4, A5: ArrayType; I1, I2, I3, I4, I5, J: IndexType )Concat5Concatenates five arrays, A1, ..., A5. I1, ..., I5 are the indexes joined; J is the index of the new array; J usually is the concatenation of I1, ..., I5.Index I12 := Concat(I1,I2);
Index I123:= Concat(I12, I3);
Index I1234 := Concat(I123, I4);
Concat(
Concat(
Concat(
Concat( A1,A2,I1,I2,I12 ),
A3, I12, I3, I123),
A4, I123, I4, I1234),
A5, I1234, I5, J);88,120,148,242,160,160,986,596A1,A2,A3,A4,A5,I1,I2,I3,I4,I5,J(A1, A2, A3, A4, A5, A6: ArrayType; I1, I2, I3, I4, I5, I6, J: IndexType )Concat6Concatenates six arrays, A1, ..., A6. I1, ..., I6 are the indexes joined; J is the index of the new array; J usually is the concatenation of I1, ..., I6.Index I12 := Concat(I1,I2);
Index I123:= Concat(I12, I3);
Index I1234 := Concat(I123, I4);
Index I12345 := Concat(I1234, I5);
Concat(
Concat(
Concat(
Concat(
Concat( A1,A2,I1,I2,I12 ),
A3, I12, I3, I123),
A4, I123, I4, I1234),
A5, I1234, I5, I12345),
A6, I12345, I6, J);192,120,148,242,644,94,602,712A1,A2,A3,A4,A5,A6,I1,I2,I3,I4,I5,I6,J0(A1, A2, A3, A4, A5, A6, A7: ArrayType; I1, I2, I3, I4, I5, I6, I7, J: IndexType )Concat7Concatenates seven arrays, A1, ..., A7. I1, ..., I7 are the indexes joined; J is the index of the new array; J usually is the concatenation of I1, ..., I7.Index I12 := Concat(I1,I2);
Index I123:= Concat(I12, I3);
Index I1234 := Concat(I123, I4);
Index I12345 := Concat(I1234, I5);
Index I123456 := Concat(I12345, I6);
Concat(
Concat(
Concat(
Concat(
Concat(
Concat( A1,A2,I1,I2,I12 ),
A3, I12, I3, I123),
A4, I123, I4, I1234),
A5, I1234, I5, I12345),
A6, I12345, I6, I123456),
A7, I123456, I7, J);88,176,148,242,580,98,551,565A1,A2,A3,A4,A5,A6,A7,I1,I2,I3,I4,I5,I6,I7,J(A1, A2, A3, A4, A5, A6, A7, A8: ArrayType; I1, I2, I3, I4, I5, I6, I7, I8, J: IndexType )Concat8Concatenates eight arrays, A1, ..., A8. I1, ..., I8 are the indexes joined; J is the index of the new array; J usually is the concatenation of I1, ..., I8.Index I12 := Concat(I1,I2);
Index I123:= Concat(I12, I3);
Index I1234 := Concat(I123, I4);
Index I12345 := Concat(I1234, I5);
Index I123456 := Concat(I12345, I6);
Index I1234567 := Concat(I123456, I7);
Concat(
Concat(
Concat(
Concat(
Concat(
Concat(
Concat( A1,A2,I1,I2,I12 ),
A3, I12, I3, I123),
A4, I123, I4, I1234),
A5, I1234, I5, I12345),
A6, I12345, I6, I123456),
A7, I123456, I7, I1234567),
A8, I1234567, I8, J);192,176,148,242,12,98,561,737A1,A2,A3,A4,A5,A6,A7,A8,I1,I2,I3,I4,I5,I6,I7,I8,J0(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10: ArrayType; I1, I2, I3, I4, I5, I6, I7, I8, I9, I10, J: IndexType)Concat10Concatenates ten arrays, A1, ..., A10. I1, ..., I10 are the indexes joined; J is the index of the new array; J usually is the concatenation of I1, ..., I10.Index I12 := Concat(I1,I2);
Index I123 := Concat(I12, I3);
Index I1234 := Concat(I123, I4);
Index I12345 := Concat(I1234, I5);
Index I123456 := Concat(I12345, I6);
Index I1234567 := Concat(I123456, I7);
Index I12345678 := Concat(I1234567, I8);
Index I123456789 := Concat(I12345678, I9);
Concat(
Concat(
Concat(
Concat(
Concat(
Concat(
Concat(
Concat(
Concat( A1,A2,I1,I2,I12 ),
A3, I12, I3, I123),
A4, I123, I4, I1234),
A5, I1234, I5, I12345),
A6, I12345, I6, I123456),
A7, I123456, I7, I1234567),
A8, I1234567, I8, I12345678),
A9, I12345678, I9, I123456789),
A10, I123456789, I10, J);192,232,148,242,542,93,632,744A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,I1,I2,I3,I4,I5,I6,I7,I8,I9,I10,J0(A : ArrayType ; RowIndex,ColIndex,ResultIndex : IndexType)ConcatRows (A,I,J,K)Takes an array, A indexed by RowIndex & ColIndex, and concatenates each row, henceforth flattening the array by one dimension. The result is indexed by ResultIndex, which must be an index with size(RowIndex) * size(ColIndex) elements.index L := [ identifier of RowIndex, identifier of ColIndex, "val"];
slice(Mdarraytotable(A,ResultIndex,L),L,3)320,64,164,242,30,320,478,348A,RowIndex,ColIndex,ResultIndexVar for rdbTable(Self,Vari)(
'Bw1',1,
'H1991',0
)['item 1','item 2']224,136,148,161,1,1,1,1,1,0,0,0,02,102,90,476,4812,406,325,416,303,0,MIDM2,355,348,653,303,0,MIDM[Formnode Var_for_rdb1]52425,39321,65535[Vari,Self][Self,Vari][1,1,1,0][Sys_localindex('I'),1,Sys_localindex('F'),1,Sys_localindex('G'),1]Inp result1) The process is done for each variable one at a time (this is indexed by x).
2) The variable is given index runn which is equal to run if probabilistic and 0 if not.
3) The array is flattened first to 2-D, the value only is kept, added with sample and result_id.
4) Variables are concatenated to each other.
5) Row is made the index of the implicit index.var output:= 0;
var e:= card_res;
var x:= 1;
while x<= size(var_for_rdb)/size(vari) do (
var c:= slice(Var_for_rdb,var_for_rdb,x);
index runn:= if c[Vari='Probabilistic?']=1 then copyindex(run) else [0];
var b:= getfract(mid(evaluate(c[vari='Var_name'])),0.5);
var a:= if c[Vari='Probabilistic?']=1 then (
var d:= sample(evaluate(c[vari='Var_name']));
d[run=runn])
else (
var d:= b;
if runn=0 then d else d);
index endscen:= 1+e..size(b)+e;
index row2:= 1..size(endscen)*size(runn);
index l:= concat(indexnames(b),['Value']);
a:= mdarraytotable(a,endscen,l);
a:= a[.l='Value'];
var f:= if c[vari='Var_name']= Variables[.j='Var_name'] then Variables[.j='Var_id'] else 0;
f:= sum(f,f.i);
a:= array(iresult,[endscen,f,a,runn]);
a:= concatrows(a,endscen,runn,row2);
output:= if x= 1 then a else for y:= iresult do (
concat(output[iresult=y],a[iresult=y]) );
e:= e+size(b);
x:= x+1);
index row:= 1..size(output)/size(iresult);
for y:= iresult do (slice(output[iresult=y],row))520,64,148,162,31,17,528,6462,624,21,529,601,0,MIDM[Iresult,Sys_localindex('ROW')][0,0,0,0][1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24][Sys_localindex('RUNN'),1,Iresult,3,Sys_localindex('ENDSCEN'),1]Write indexdbwrite(odbc_write, appendtablesql(inp_ind,Indices_missing,Inp_ind.j,'`Index` '));
'Done'640,360,148,1665535,45873,39321[Sys_localindex('A'),Iind][]ODBC LibraryLonnieThu, Sep 11, 1997 2:15 PMLonnieTue, Feb 05, 2008 10:03 AM48,2456,304,152,241,1,1,1,1,1,0,0,0,01,-151,272,499,497,17Arial, 13(A:ArrayType;I:IndexType;L:IndexType;row;dbTableName)InsertRecSqlGenerates the SQL "INSERT INTO" statement for one line of table A. A is a 2-D table indexed by rows I and columns L. L's domain serves as the column names in the database table. dbTableName is the name of the table in the database. The result begins with two semi-colons, since it will be used with an SQL statement preceeding it.
29.8.2008 Jouni Tuomisto
I added the parameter IGNORE because it ignores rows that would cause duplicate-key violations. This way, there is no need to check for e.g. existing locations of new indices.(';;INSERT IGNORE INTO ' & dbTableName & '(' & JoinText(L,L,',') & ') VALUES (' & Vallist(A[I=row],L)) & ')'184,32,152,242,41,136,487,423A,I,L,row,dbTableName(V:ArrayType;I:IndexType)ValListTakes a list of values, and returns a string which the concatenation of each value, separated by commas, and with each value quoted.JoinText( '''' & V & '''', I, ',')72,32,052,24V,I1,F,4,14,0,0(Tabl:ArrayType;RowIndex:IndexType;LabelIndex:IndexType;dbTableName)WriteTableSql(Table,Rows,Labels,dbTableName)Returns the SQL that will write the table to the database table.
This can be used as the second argument to DBWrite.
This SQL statement replaces the entire contents of an existing table with the new data.'DELETE FROM '& Dbtablename & JoinText(Insertrecsql(Tabl, Rowindex, Labelindex, Rowindex, Dbtablename),RowIndex)328,32,188,242,728,341,510,476Tabl,RowIndex,LabelIndex,dbTableName(Tabl:ArrayType;RowIndex:IndexType;LabelIndex:IndexType;dbTableName)WriteTableSql(Table,Rows,Labels,dbTableName)Returns the SQL that will write the table to the database table.
This can be used as the second argument to DBWrite.
This SQL statement replaces the entire contents of an existing table with the new data.JoinText(Insertrecsql(Tabl, Rowindex, Labelindex, Rowindex, Dbtablename),RowIndex)328,88,188,242,52,65,510,476Tabl,RowIndex,LabelIndex,dbTableNameInp_indvar a:= if Dimensions[.j='Dim_name']=Input_ind[iind='Dim_name'] then Dimensions[.j='Dim_id'] else 0;
a:= sum(a,dimensions.i);
index j:= ['Ind_id','Ind_name','Dim_id'];
array(j,[
Card_ind+@Indices_missing,
indices_missing,
a])['item 1']520,360,148,162,197,430,416,303,0,MIDM19661,48336,65535[Iind,Self][Indices_missing,Sys_localindex('J')]['item 1'][Indices_missing,1,Sys_localindex('CO'),1,Sys_localindex('I'),1]iind['Ind_title','Dim_name']56,384,148,13['Ind_title','Dim_name']Input dimTable(Idim)(
'''Finnish municipalities''','''-'''
)['item 1']168,320,148,162,209,427,767,303,0,MIDM2,330,482,558,303,0,MIDM[Formnode Inp_dim1]52425,39321,65535[Idim,Dimensions_missing][Dimensions_missing,Idim]['item 1']idim['Dim_title','Dim_unit']168,344,148,13['Dim_title','Dim_unit']Inp rowvar a:= if New_locs[.j='Ind_name'] = Indices[.j='Ind_name'] then Indices[.j='Ind_id'] else 0;
a:= sum(a,Indices.i);
var b:= if New_locs[.j='Location'] = Locations[.j='Location'] and New_locs[.j='Dim_name'] = Locations[.j='Dim_name'] then Locations[.j='Loc_id'];
b:= sum(b,Locations.i);
index j:= ['Ind_id','Row_number','Loc_id'];
a:= array(j,[a,New_locs[.j='Row_number'],b]);
['item 1']520,440,148,162,617,386,598,2242,250,441,416,303,0,MIDM2,41,53,404,209,0,MIDM19661,48336,65535[Irow,Self][New_locs,Sys_localindex('J')]['item 1']Inp locvar b:= if New_locs[.j='Dim_name'] = Locations[.j='Dim_name'] then Locations[.j='Dim_id'];
b:= sum(b,Locations.i);
index j:= ['Loc_id','Dim_id','Location'];
array(j,[card_loc+@New_locs.New_locs, b, New_locs[.j='Location']])['item 1','item 2','item 3','item 4','item 5','item 6','item 7','item 8','item 9','item 10','item 11','item 12','item 13','item 14','item 15','item 16','item 17','item 18','item 19','item 20','item 21']520,400,148,162,319,169,421,433,0,MIDM2,17,366,405,302,0,MIDM19661,48336,65535[Iloc,Self][Sys_localindex('J'),New_locs]['item 1','item 2','item 3','item 4','item 5','item 6','item 7','item 8','item 9','item 10','item 11','item 12','item 13','item 14','item 15','item 16','item 17','item 18','item 19','item 20','item 21'][Sys_localindex('J'),3,Sys_localindex('K'),1]Card ind{Reset;
index a:= DBquery(odbc,'SELECT Ind_id
FROM `Index` ');
index b:= ['Ind_id'];
max(max(DBTable(a, b ),a),b)}
13376,360,148,1639325,65535,39321Card dim{Reset;
index a:= DBquery(odbc,'SELECT Dim_id
FROM `Dimension` ');
index b:= ['Dim_id'];
max(max(DBTable(a, b ),a),b)}
15376,320,148,1639325,65535,39321Card loc{Reset;
index a:= DBquery('DSN=resultdatabase','SELECT Loc_id
FROM `Location` ');
index b:= ['Loc_id'];
max(max(DBTable(a, b ),a),b)}
179376,400,148,1639325,65535,39321Write dimensiondbwrite(odbc_write, appendtablesql(Inp_dim,Dimensions_missing,Inp_dim.j,'Dimension '));
'Done'640,320,148,162,312,322,698,303,0,MIDM65535,45873,39321[]Card res{Reset;
index a:= DBquery(odbc,'SELECT Result_id
FROM `Result` ');
index b:= ['Result_id'];
max(max(DBTable(a, b ),a),b);}
180376,136,148,1639325,65535,39321Inp loc of resultgetfract forces the effect of sample() away, while mid doesn't
1) Does the process for each variable one at a time. Only the deterministic information about variables are considered (therefore getfract).
2) Flattens the array. The value is discarded and only the location info is kept.
3) Gets the Dimension (Dim_id) for each index of h.
4) Gets the Location (Loc_id) for each cell in a, given the dimension and location.
5) Flattens the array a.
6) Concatenates the results of all variables.
7) Makes Row the index of the implicit index.var output=0;
var e:= card_res;
var x:= 1;
while x<= size(var_for_rdb)/size(vari) do (
var c:= slice(Var_for_rdb,var_for_rdb,x);
var a:= getfract(mid(evaluate(c[vari='Var_name'])),0.5);
index h:= indexnames(a);
index l:= concat(h,['Value']);
index roww:= 1..size(a)*size(h);
index endscen:= 1+e..size(a)+e;
e:= e+size(a);
a:= mdarraytotable(a,endscen,l);
a:= a[l=h];
var dim:= if h=indices[.j='Ind_name'] then indices[.j='Dim_id'] else 0;
dim:= sum(dim,indices.i);
a:= if a=Locations[.j='Location'] and dim=Locations[.j='Dim_id'] then Locations[.j='Loc_id'] else 0;
a:= sum(a,Locations.i);
a:= array(Ilocres,[endscen,a]);
a:= concatrows(a,a.h,endscen,roww);
output:= if x= 1 then a else for y:= ilocres do (
concat(output[ilocres=y],a[ilocres=y]) );
x:= x+1);
index row:= 1..size(output)/size(ilocres);
for y:= ilocres do (slice(output[ilocres=y],row))520,136,148,162,616,21,518,6352,40,27,546,367,0,MIDM[Sys_localindex('ROW'),Ilocres][Sys_localindex('I'),3,Sys_localindex('H'),1,Sys_localindex('ENDSCEN'),1]Write locresdbwrite(odbc_write, appendtablesql(inp_loc_of_result,inp_loc_of_result.row,Ilocres,'Loc_of_result '));
'Done'640,136,148,1665535,45873,39321[]iresult['Result_id','Var_id','Result','Sample']520,96,148,13[]['Result_id','Var_id','Result','Sample']ilocres['Result_id','Loc_id']520,168,148,13Inp run listvar output:= 0;
var e:= card_res;
var x:= 1;
while x<= size(var_for_rdb)/size(vari) do (
var c:= slice(Var_for_rdb,var_for_rdb,x);
var b:= getfract(mid(evaluate(c[vari='Name'])),0.5);
index endscen:= 1+e..size(b)+e;
var a:= array(irunlist,[endscen,card_run+1]);
output:= if x= 1 then a else for y:= irunlist do (
concat(output[irunlist=y],a[irunlist=y]) );
e:= e+size(b);
x:= x+1);
index row:= 1..size(output)/size(irunlist);
for y:= irunlist do (slice(output[irunlist=y],row))520,208,148,162,102,90,476,5782,773,40,372,741,0,MIDM[Irunlist,Sys_localindex('ROW')]Card run{Reset;
index a:= DBquery(odbc,'SELECT Run_id
FROM `Run` ');
index b:= ['Run_id'];
max(max(DBTable(a, b ),a),b);}
5376,208,148,161,1,1,1,1,1,0,0,0,039325,65535,39321irunlist['Result_id','Run_id']520,240,148,131,1,1,1,1,1,0,0,0,0Input runTable(Irun)(
'26.8.2008','Jouni','Analytica 4.1.0.9, Finmerac_Harjavalta_model, 10000 iterations')280,280,148,162,364,311,629,303,0,MIDM2,415,466,457,303,0,MIDM[Formnode Inp_run1]52425,39321,65535[Irun,Self][Self,Irun]2,D,4,2,0,0,4,0,$,0,"yyyy-mm-dd",0['item 1']irun['Run_date','Run_who','Run_method']280,304,148,13['Run_date','Run_who','Run_method']Input varTable(Ivar,Variables_missing)(
0,'Weight of a dinosaur',
0,'kg'
)224,24,148,162,239,183,675,4532,196,346,794,301,0,MIDM2,152,434,886,303,0,MIDM[Formnode Inp_var1]52425,39321,65535[Ivar,Variables_missing][Ivar,Variables_missing]2,D,4,2,0,0,4,0,$,0,"yyyy-mm-dd",0['item 1','item 2']ivar['Var_title','Var_unit']224,48,148,12['Var_title','Var_unit']Write vardbwrite(odbc_write, appendtablesql(var1,Variables_missing,var1.co,'Variable '));
'Done'640,24,148,1665535,45873,39321[]Write rundbwrite(odbc_write, appendtablesql(Inp_run,Inp_run.i,Inp_run.j,'Run '));
'Done'640,280,148,1665535,45873,39321[]Write runlistdbwrite(odbc_write, appendtablesql(inp_run_list,inp_run_list.row,Irunlist,'Run_list '));
'Done'640,208,148,1665535,45873,39321[]Write resultdbwrite(odbc_write, appendtablesql(inp_result,inp_result.row,Iresult,'Result '));
'Done'640,64,148,1665535,45873,39321[]Write locationdbwrite(odbc_write, appendtablesql(inp_loc,New_locs,inp_loc.j,'Location '));
'Done'640,400,148,1665535,45873,39321[]Write rowdbwrite(odbc_write, appendtablesql(inp_row,New_locs,inp_row.j,'Rows '));
'Done'640,440,148,1665535,45873,39321[]vari['Var_name','Probabilistic?']224,160,148,12['Var_name','Probabilistic?']Reset6556,40,148,121,1,0,1,1,1,0,0,0,0New locsThis is based on an assumption that the index Ind_var is always the outermost index and therefore last. Then it is sliced away.var a:= indices_used;
var b:= evaluate(a[@.i=1]);
var c:= if b=0 then a[@.i=1] else a[@.i=1];
var e:= 1..size(b);
var x:= 2;
while x<=size(a.i) do (
var d:= evaluate(a[@.i=x]);
b:= concat(b,d);
c:= concat(c,(if d=0 then a[@.i=x] else a[@.i=x]));
e:= concat(e,1..size(d));
x:= x+1);
index k:= 1..size(b);
b:= slice(b,k);
c:= slice(c,k);
e:= slice(e,k);
var d:= Input_ind[iind='Dim_name',indices_missing=c];
d:= if d=null then 0 else d;
index j:= ['Dim_name','Location','Ind_name','Row_number'];
a:= array(j,[d,b,c,e]);
a[k=subset(a[.j='Dim_name'])]376,456,148,242,59,53,476,6032,10,57,487,303,0,MIDM[Sys_localindex('J'),Self][Index New_locations]['Age1','Municipality_fin1','Inp_var'][Inp_ind,1,Indices_missing,1,Self,1]ODBC'Driver={MySQL ODBC 5.1 Driver};Server=10.66.10.102;Database=resultdb;User=result_reader; Password=ora4ever;Option=3'56,16,148,121,1,0,1,1,1,0,,0,2,102,90,476,224Dimensions{Reset;
index a:= DBquery(odbc,'SELECT Dim_id, Dim_name
FROM `Dimension` ');
index b:= ['Dim_id','Dim_name'];
DBTable(a, b )}
index j:= ['Dim_id','Dim_name'];
var a:= array(j,[12,'Municipality_fin']);
index i:=1..1;
array(i,[a])56,136,148,121,1,0,1,1,1,0,0,0,02,120,130,316,489,0,MIDM39325,65535,39321[Sys_localindex('I'),Sys_localindex('J')]Variables missingThis 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.var a:= Variables[.j='Dim_name'];
var e:= Var_for_rdb[vari='Var_name'];
a:= ','&jointext(a,a.i,',');
a:= if findintext(','&e&',',a)>0 then 0 else 1;
e[var_for_rdb=subset(a)]224,80,148,221,1,1,1,1,1,0,0,0,02,254,142,493,5012,529,143,702,489,0,MIDM39321,39325,65535[Self,Vari]['Bw1','H1991']Old partsjtue29. elota 2008 11:11 48,24904,296,148,241,0,1,1,1,1,0,,0,1,1,7,550,300,17DBindicesDBTable(Dbindex, Dbindexlabel )96,39,148,152,54,74,1024,686,0,MIDM39325,65535,39321[Dbindexlabel,Dbindex]['Loc_id','Result_id','Dim_id','Location']DBindexLabelDBlabels(Dbindex)104,95,156,122,102,90,476,353['Var_id','Var_name','Var_scope','Var_unit','Validity_date','Run_id','Run_time']DBindexReset;
DBquery('DSN=resultdatabase','SELECT Rows.Ind_id, Ind_name, row_number, Location.Loc_id, Location
FROM `Location`, `Rows`, `Index`
WHERE Location.Loc_id = Rows.Loc_id and
`Index`.Ind_id = Rows.Ind_id')96,71,148,132,102,90,476,4102,280,290,416,303,0,MIDM[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]DBresultReset;
DBquery('DSN=resultdatabase','SELECT var_name, Restat.*, var_unit, Indices.*, Run.*
FROM Variable, Run_list, Run, Loc_of_result,
(SELECT var_id, result_id, avg(result) as result, min(result) as minimum, max(result) as maximum, count(sample) as n
FROM Result
GROUP BY result_id) as Restat,
(SELECT Dimension.Dim_id, Dimension.Dim_name, Rows.Ind_id, Ind_name, row_number, Location.Loc_id, Location
FROM `Dimension`, `Location`, `Rows`, `Index`
WHERE Dimension.Dim_id = Location.Dim_id and
Location.Loc_id = Rows.Loc_id and
`Index`.Ind_id = Rows.Ind_id) as Indices
WHERE Variable.var_id = Restat.var_id and
Restat.result_id = Run_list.result_id and
Run_list.run_id = Run.run_id and
Restat.result_id = Loc_of_result.result_id and
Loc_of_result.loc_id = Indices.loc_id
ORDER BY run_id DESC, var_id, result_id')100,72,148,132,280,290,416,303,0,MIDM[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]DBresultsDBTable(Dbresult, Dbreslabel)100,40,148,162,17,34,1187,497,0,MIDM39325,65535,39321[Dbreslabel,Dbresult]['Loc_id','Result_id','Dim_id','Location']DBresLabeldblabels(Dbresult)108,96,160,132,280,290,416,469,0,MIDM[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]irow['Ind_id','Row_number','Loc_id']96,37,148,13iloc['Loc_id','Dim_id','Location']96,37,148,13Locations['0','0.02','0.05','0.1','0.25','0.4','0.45','0.5','0.55','0.65','0.75','0.9','1']96,88,148,16[Formnode Locs1]52425,39321,65535Year_11..296,72,148,13(1..3)*1096,96,148,12(1..4)*10096,120,148,12Test variableYear_1+Cause_of_death_1+Cause_of_death_296,40,148,162,328,338,416,303,0,MIDM[Cause_of_death_2,Cause_of_death_1][In5,2,In6,1,In7,1]1596,40,148,161,1,1,1,1,1,0,0,0,0[Formnode Dime1]52425,39321,65535Variable cardinality{Reset;
index a:= DBquery(odbc,'SELECT Var_id
FROM `Variable` ');
index b:= ['Var_id'];
max(max(DBTable(a, b ),a),b);}
13112,136,148,161,1,1,1,1,1,0,0,0,02,376,386,416,303,0,MIDM39325,65535,39321[]Ind name'Comp_fr_1'['item 1']432,184,148,162,457,448,416,303,0,MIDM[Formnode Ind_name1]52425,39321,65535[Iind,Self][Self,Iind]['item 1']var output=0;
var e:= card_res;
var x:= 1;
while x<= size(var_for_rdb)/size(vari) do (
var c:= slice(Var_for_rdb,var_for_rdb,x);
var a:= getfract(mid(evaluate(c[vari='Name'])),0.5);
index h:= indexnames(a);
index l:= concat(h,['Value']);
index roww:= 1..size(a)*size(h);
index endscen:= 1+e..size(a)+e;
e:= e+size(a);
a:= mdarraytotable(a,endscen,l);
a:= a[l=h];
var b:= if Dbindices[Dbindexlabel='Ind_name']=h then Dbindices[Dbindexlabel='row_number'] else '';
index d:= 1..max(max(b,Dbindex),h);
b:= Positioninindex(b , d, Dbindex );
b:= Dbindices[Dbindex=b, Dbindexlabel='Loc_id'];
var w:=1;
while w<= size(h) do (
index m:= evaluate(slice(h,w));
var z:= 1;
while z<=size(m) do (
var g:= slice(m,z);
var f:= slice(slice(b,h,w),d,z);
a:= if a=g then f else a;
z:= z+1);
w:= w+1);
a:= array(Ilocres,[endscen,a]);
a:= concatrows(a,a.h,endscen,roww);
output:= if x= 1 then a else for y:= ilocres do (
concat(output[ilocres=y],a[ilocres=y]) );
x:= x+1);
index row:= 1..size(output)/size(ilocres);
for y:= ilocres do (slice(output[ilocres=y],row))208,168,148,242,145,21,476,7862,145,365,416,303,0,MIDM[Sys_localindex('ROW'),Ilocres]subtable(Input_var[ivar=['Var_name','Var_unit']])312,184,148,24[Self,Input_var]['Var_name','Var_unit']Var dataTable(Self,Ivar)(
'Human body weight','kg',
0,0
)['item 1','item 2']392,144,148,162,239,183,675,4532,37,340,794,301,0,MIDM2,152,434,886,303,0,MIDM52425,39321,65535[Ivar,Self][Ivar,Self]2,D,4,2,0,0,4,0,$,0,"yyyy-mm-dd",0array(ivar,[
evaluate(Variables_missing),
evaluate(Variables_missing)])408,96,148,24[Ivar,Variables_missing][Variables_missing,Ivar]Weight of a dinosaurkg
array(f,[2000])96,48,148,24[2000]var a:= Input_ind[iind='Ind_title'];
var b:= evaluate(Indices_missing);
b264,120,148,242,337,60,416,303,0,MIDM[Municipality_fin1,Indices_missing]Inp_indTable(Self,Iind)(
ind_name,dime
)['item 1']248,48,148,162,197,430,416,303,0,MIDM1,49155,65535[Iind,Self][Self,Iind]New locationsThis node checks the indices listed in variables 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.
Definition of e is based on the assumption that var_for_rdb is always the outermost index and therefore is always the last.var c:= if d=Ind_and_loc[.j=b] then 1 else 0;
c:= sum(product(c,b),a);
c:= if c=1 then Ind_and_loc else '';
96,46,148,221,1,1,1,1,1,0,0,0,02,52,49,493,6642,784,160,472,489,0,MIDM39325,65535,39321[Sys_localindex('J'),Sys_localindex('K')][Variable New_locs]['Municipality_fin1'][Sys_localindex('B'),1,Sys_localindex('A'),1,Va5,1]Ind and locThis is based on an assumption that the index Ind_var is always the outermost index and therefore last. Then it is sliced away.var a:= indices_used;
var b:= evaluate(a[@.i=1]);
var c:= if b=0 then a[@.i=1] else a[@.i=1];
var e:= 1..size(b);
var x:= 2;
while x<=size(a.i) do (
var d:= evaluate(a[@.i=x]);
b:= concat(b,d);
c:= concat(c,(if d=0 then a[@.i=x] else a[@.i=x]));
e:= concat(e,1..size(d));
x:= x+1);
index k:= 1..size(b);
b:= slice(b,k);
c:= slice(c,k);
e:= slice(e,k);
var d:= Input_ind[iind='Dim_name',indices_missing=c];
index j:= ['Dim_name','Location','Ind_name','Row_number'];
array(j,[d,b,c,e])96,48,148,242,59,53,476,6032,10,57,487,303,0,MIDM[Sys_localindex('J'),Sys_localindex('K')]['Age1','Municipality_fin1','Inp_var'][Inp_ind,1,Indices_missing,1,Self,1]New locationsThis node checks the indices listed in variables 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.
Definition of e is based on the assumption that var_for_rdb is always the outermost index and therefore is always the last.{Reset;
index a:= DBquery(odbc,'select Dim_name, Location from Location, Dimension
where Location.dim_id = Dimension.dim_id ');}
index b:= ['Dim_name','Location'];
{var d:= DBTable(a, b );}
index a:= 1..13;
var d:= array(a,['Bw1',
'Comptraf_scenoutput',
'Fig_3_cost_by_source',
'Fig_5a_societal_cost',
'Fig_5b_subsidies',
'Municipality_fin',
'Age1',
'H2201',
'H2202',
'H2204',
'H2205',
'Ppmconc_bustraffic',
'Testvariable']);
d:= array(b,[d,'Harjavalta']);
var c:= if d=New_locs[.j=b] then 1 else 0;
c:= sum(product(c,b),a);
c:= if c=1 then New_locs else '';
224,54,148,221,1,1,1,1,1,0,0,0,02,52,49,493,6642,784,160,472,489,0,MIDM39325,65535,39321[Sys_localindex('J'),Sys_localindex('K')]['Municipality_fin1'][Sys_localindex('B'),1,Sys_localindex('A'),1,Va5,1]f[1]96,88,148,24Inp loc of resultgetfract forces the effect of sample() away, while mid doesn'tvar output=0;
var e:= card_res;
var x:= 1;
while x<= size(var_for_rdb)/size(vari) do (
var c:= slice(Var_for_rdb,var_for_rdb,x);
var a:= getfract(mid(evaluate(c[vari='Var_name'])),0.5);
index h:= indexnames(a);
index l:= concat(h,['Value']);
index roww:= 1..size(a)*size(h);
index endscen:= 1+e..size(a)+e;
e:= e+size(a);
a:= mdarraytotable(a,endscen,l);
a:= a[l=h];
var b:= if Dbindices[Dbindexlabel='Ind_name']=h then Dbindices[Dbindexlabel='row_number'] else '';
index d:= 1..max(max(b,Dbindex),h);
b:= Positioninindex(b , d, Dbindex );
b:= Dbindices[Dbindex=b, Dbindexlabel='Loc_id'];
var w:=1;
while w<= size(h) do (
index m:= evaluate(slice(h,w));
var z:= 1;
while z<=size(m) do (
var g:= slice(m,z);
var f:= slice(slice(b,h,w),d,z);
a:= if a=g then f else a;
z:= z+1);
w:= w+1);
a:= array(Ilocres,[endscen,a]);
a:= concatrows(a,a.h,endscen,roww);
output:= if x= 1 then a else for y:= ilocres do (
concat(output[ilocres=y],a[ilocres=y]) );
x:= x+1);
index row:= 1..size(output)/size(ilocres);
for y:= ilocres do (slice(output[ilocres=y],row))104,40,148,162,589,15,518,7842,40,27,546,367,0,MIDM[Ilocres,Sys_localindex('ROW')]Indices missingThis node checks the indices listed in variables 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.
Definition of e is based on the assumption that var_for_rdb is always the outermost index and therefore is always the last.var a:= indices[.j='Ind_name'];
var e:= indices_used;
a:=','&jointext(a,a.i,',');
a:= if findintext(','&e&',',a)>0 then 0 else 1;
e[.i=subset(a)]56,416,148,221,1,1,1,1,1,0,0,0,02,483,17,493,5932,777,127,472,489,0,MIDM39321,39325,65535[Self,Vari]Input indTable(Iind,Indices_missing)(
'Municipalities in Finland, v1',
'Municipality_fin'
)56,360,148,162,27,178,416,303,0,MIDM2,14,97,520,238,0,MIDM52425,39321,65535[Indices_missing,Iind][Iind,Indices_missing]Indices usedThis lists all indices that are used by all of the variables that are to be inserted into the result database.
This is based on an assumption that the index Ind_var is always the outermost index and therefore last. Then it is sliced away.var a:= var_for_rdb[vari='Var_name'];
a:= indexnames(evaluate(a));
index i:= 1..size(a)-1;
a:= slice(a,i);
224,456,148,242,101,213,476,5662,36,50,416,303,0,MIDM[Sys_localindex('J'),Self]['Age1','Municipality_fin1','Inp_var'][Inp_ind,1,Indices_missing,1,Self,1]Dimensions missingThis node checks the indices listed in variables 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.
Definition of e is based on the assumption that var_for_rdb is always the outermost index and therefore is always the last.var a:= dimensions[.j='Dim_name'];
var e:= Input_ind[iind='Dim_name'];
a:=','&jointext(a,a.i,',');
a:= if findintext(','&e&',',a)>0 then 0 else 1;
e[indices_missing=subset(a)]168,376,148,221,1,1,1,1,1,0,0,0,02,763,42,493,5932,777,127,472,489,0,MIDM39321,39325,65535[Self,Vari]Varvar c:= Card_var;
index co:= ['Var_id','Var_name','Var_title','Var_unit','Page_id','Wiki_id'];
array(co,[
c+@Variables_missing,
Variables_missing,
Input_var[ivar='Var_title'],
Input_var[ivar='Var_unit'],
Selecttext( Input_var[ivar='Var_name'], 2),
Selecttext( Input_var[ivar='Var_name'], 1,1)])520,24,148,161,1,1,1,1,1,0,0,0,02,376,386,416,303,0,MIDM19661,48336,65535[Variables_missing,Sys_localindex('CO')]Indices{Reset;
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 )}
index j:= ['Ind_id','Ind_name','Dim_id','Dim_name'];
var a:= array(j,[17,'Municipality_fin1',10,'Municipality_fin']);
var b:= array(j,[18,'Age1',11,'Age']);
index i:=1..2;
array(i,[a,b])56,160,148,121,1,0,1,1,1,0,0,0,02,-73,97,476,2962,120,130,316,489,0,MIDM39325,65535,39321[Sys_localindex('I'),Sys_localindex('J')]Inp_dimindex j:= ['Dim_id','Dim_name','Dim_title','Dim_unit'];
array(j,[
Card_dim+@Dimensions_missing,
Dimensions_missing,
Input_dim[Idim='Dim_title'],
Input_dim[Idim='Dim_unit']])520,320,148,16[Dimensions_missing,Sys_localindex('J')]ODBC write'Driver={MySQL ODBC 5.1 Driver};Server=10.66.10.102;Database=resultdb;User='&username&'; Password='&password&';Option=3'56,112,148,121,1,0,1,1,1,0,,0,'Enter username'56,64,048,121,1,1,1,1,1,0,0,0,0[Formnode Username1]52425,39321,65535'Enter password'56,88,048,121,1,1,1,1,1,0,0,0,0[Formnode Password1]52425,39321,65535Inp runindex j:= ['Run_id','Run_date','Run_who','Run_method'];
index i:= 1..1;
var a:= Input_run[Irun=j];
a:= if j='Run_id' then Card_run+1 else a;
array(i,[a])520,280,148,162,168,178,528,303,0,MIDM[Sys_localindex('I'),Sys_localindex('J')]Locations{Reset;
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(a, b )}
index j:= ['Loc_id', 'Location', 'Dim_id', 'Dim_name'];
var a:= array(j,[179,'Harjavalta',10,'Municipality_fin']);
var b:= array(j,[190,'3',11,'Age']);
var c:= array(j,[191,'18-65',11,'Age']);
index i:=1..3;
array(i,[a,b,c])56,184,148,121,1,0,1,1,1,0,0,0,02,102,90,476,4452,15,111,316,489,0,MIDM39325,65535,39321[Sys_localindex('I'),Sys_localindex('J')]Card var{Reset;
index a:= DBquery(odbc,'SELECT Var_id
FROM `Variable` ');
index b:= ['Var_id'];
max(max(DBTable(a, b ),a),b)}
11376,24,148,161,1,1,1,1,1,0,0,0,02,376,386,416,303,0,MIDM39325,65535,39321VariablesThis 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.{Reset;
index i:= DBquery(odbc,'SELECT Var_id, Var_name
FROM `Variable` ');
index j:= ['Var_id','Var_name'];
var a:= DBTable(a, b );}
index j:= ['Var_id','Var_name'];
index i:= 1..13;
var a:= array(i,['Bw1',
'Comptraf_scenoutput',
'H1991',
'Fig_5a_societal_cost',
'Fig_5b_subsidies',
'Fig_5c_expanding',
'H1901',
'H2201',
'H2202',
'H2204',
'H2205',
'Ppmconc_bustraffic',
'Testvariable']);
array(j,[i+5,a])56,208,148,121,1,0,1,1,1,0,0,0,02,254,142,493,5012,529,143,702,489,0,MIDM39325,65535,39321[Sys_localindex('J'),Sys_localindex('I')]['H1991'][Self,1,Sys_localindex('I'),1,Sys_localindex('J'),1]This module saves model results into the Result Database. You need a password for that. Note that the necessary variable, index, dimension, and run information will be asked. You must add all tables before the process is completed.256,40,-1256,40Variables that must be up-to-date before running the write procedure:656,112,-1124,201,0,0,1,0,1,0,,0,65535,65532,19661Inp var592,344,-156,161,0,0,1,0,1,0,,0,65535,65532,19661Var for rdb,
Inp run592,420,-156,201,0,0,1,0,1,0,,0,65535,65532,19661Inp dim592,168,-156,161,0,0,1,0,1,0,,0,65535,65532,19661Dime, Ind_name, Locations592,253,-156,291,0,0,1,0,1,0,,0,65535,65532,19661Note! You can insert several variables at the same time. Each variable MUST have at least one index.664,40,-1144,32Insert a variable344,336,-6324,321,0,0,1,0,1,0,,0,Te11Insert a dimension340,160,-5324,321,0,0,1,0,1,0,,0,Te11Insert a variable result340,424,-4324,481,0,0,1,0,1,0,,0,Te11Insert an index340,248,-3324,481,0,0,1,0,1,0,,0,Dime0356,245,184,131,0,0,1,0,0,0,72,0,152425,39321,65535DimeInd name0144,245,1128,131,0,0,1,0,0,0,72,0,152425,39321,65535Ind_nameLog31.7.2008 Jouni Tuomisto
Identified problems:
* Inp_loc_of_result can calculate at least 800000 rows, but Write_locres is unable to write that data into the database.
* Inp_run_list does not work with composite traffic model cost variables. I attempted to write the following variables (from Var_fo_rdb node):
Fig_3_cost_by_source' 9 1
Fig_5a_societal_costs' 10 1
Fig_5b_subsidies' 11 0
Fig_5c_expanding' 12 1
but this resulted in an error message from Cap_variab_2: "first parameter in sortindex must be a table". This error does not occur when the node is calculated, only when I attempt to write it into the database. See an email to Dale Rice 31.7.2008.
0736,168,148,242,83,23,511,358Username0160,84,1152,121,0,0,1,0,0,0,118,0,152425,39321,65535UsernamePassword0160,108,1152,121,0,0,1,0,0,0,118,0,152425,39321,65535Password