Posted: Tue Oct 03, 2006 6:10 am Post subject: Using Variable column names with DB
Apprentice
Joined: 13 Oct 2005 Posts: 41 Location: Egypt
Hi All
Im using WBIMB6, Im trying to use the following select Statemnet
The table name and Column Name are both variables
It is as followed
SET ExistedCode = 'XYZ' ;
SET TableName = Environment.Variables.Code_Table;
SET StandardTableName = nvironment.Variables.Standard_Table;
SET StandardFieldName = Environment.Variables.Standard_Field;
SET Environment.Variables.Standard[] =( SELECT ITEM ST.ID FROM Database.AL.{StandardTableName}AS ST WHERE Database.AL.{StandardTableName}.{StandardFieldName} = ExistedCode);
but this is not working, I tried Also:
SET Environment.Variables.Standard[] =( SELECT ITEM ST.ID FROM Database.AL.{StandardTableName}AS ST WHERE ST.{StandardFieldName} = ExistedCode);
it didnt work either
is it possible to give the column name as variable
hi all
I found some work around to solve my problem, but I hope I can find better solution
SET Quotation =SUBSTRING('g''h' FROM 2 FOR 1); -- in order to have Quotation ='
SET SQL_STATMENT = 'SELECT ID FROM AL.' || StandardTableName ||' WHERE '|| StandardFieldName||' = '||Quotation||ExistedCode||Quotation ;
SET Environment.Variables.PASSTHRU_Standard[] =PASSTHRU(SQL_STATMENT);
as this statement returned the name value paire I had to do the following select to get the value only
SET Environment.Variables.Standard[]= (SELECT ITEM E.ID FROM Environment.Variables.PASSTHRU_Standard[] AS E);
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum