Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi, I have my config table like this
an with the following code
LET vNumTab = NoOfRows('TabConfig');
For j=1 to $(vNumTab)
LET vSchemaTemp = peek('Schema', $(j)-1, 'TabConfig' );
LET vDatabaseObjectTemp = peek('DB_Obj', $(j)-1,' TabConfig' );
LET vTableNameTemp = peek('TableName', $(j)-1, 'TabConfig' );
LET vCampoDateTemp = peek('CampoDate', $(j)-1, 'TabConfig' );
Trace >>> $(j) di $(vNumTab): $(vSchemaTemp).$(vDatabaseObjectTemp) for $(vTableNameTemp);
[.. other things, the error is above..]
I get this :
As you can see, the first look goes smoothly, but the second, ONLY the DB Objet is null, while the others are correct.
What's happening? What am I missing?
Thank you very much
have a great day
I could imagine that the table-name TabConfig is wrong. In this case peek() couldn't refer to the table - but it won't return an error else just referencing to the last loaded table. In your first iteration this is the config-table but not in the second iteration because the last load were your oracle-query.
Therefore take another look on the table-name if you fetched the right one and spelled it properly. You may it also including within your trace-logic, with something like:
let vTable = tablename(nooftables());
trace LastLoadedTable is: $(vTable);
I think I would comment the load-part within the loop and look what the trace returned for all the other iterations. If anything is wrong it would be probably more often as just for one variable-value in the second run. If so it may give valuable hints to the real cause - maybe a not existing table TabConfig or this table has another content as expected.
Nice idea, and it got me an interesting result: the loop is working correctly if I comment the following code, but gives me again the error once un-commented it.
Hence the second part of the code is somehow related to the error.
These are the following parts of the code:
LET vSoubRoutineType = if(len(vCampoDateTemp)>0, 'His','Simple'); //this is fine
CALL Datawarehouse_$(vSoubRoutineType) (vServer, vSchemaTemp, vDatabaseObjectTemp, vTableNameTemp,vCampoDateTemp); //this seems to be fine, but once I coment it, the loops works 🙂
Tha call (in another Sections) are the following:
Sub Datawarehouse_Simple (vServer,vSchema,vDatabaseObject,vTableName,vCampoDate)
LIB CONNECT TO '$(vServer)';
$(vTableName): SQL SELECT * FROM $(vSchema).$(vDatabaseObject);
Store $(vTableName) into $(vStore_QVD_00)\$(vTableName).qvd (qvd);
DisConnect;
End Sub
//and the second Sub:
Sub Datawarehouse_His (vServer,vSchema,vDatabaseObject,vTableName,vCampoDate)
LIB CONNECT TO '$(vServer)';
$(vTableName): SQL SELECT * FROM $(vSchema).$(vDatabaseObject) where $(vCampoDate) = (select max($(vCampoDate)) from $(vSchema).$(vDatabaseObject));
Store $(vTableName) into $(vStore_QVD_00)\$(vTableName).qvd (qvd);
DisConnect;
End Sub.
Long story short: Datawarehouse_Simple is a Load * from,
Datawarehouse_His is a load * where date is max.
What could the error possibly be?
I could imagine that the table-name TabConfig is wrong. In this case peek() couldn't refer to the table - but it won't return an error else just referencing to the last loaded table. In your first iteration this is the config-table but not in the second iteration because the last load were your oracle-query.
Therefore take another look on the table-name if you fetched the right one and spelled it properly. You may it also including within your trace-logic, with something like:
let vTable = tablename(nooftables());
trace LastLoadedTable is: $(vTable);
Love what are you doing here, it would have taken me ages to come up to this 🙂 Thank you very much!
The problem was indeed a typo in the code (a space to be precise: ' TabConfig' instead of 'TabConfig', ffs)
Again thank you,
Best regards
P