Home
Analytics
Database value to dynamic text field
Mihsah
Hi!
I have a mySQL database consisting of several rows and columns. I am interested in a specific cell in the database.
The mySQL query finding the value of the cell is:
SELECT cellColumn FROM myDatabase WHERE idColumn = 'myUniqueID'
But how do I get this value into a dynamic text in BIRT? I have a column binding on "cellColumn" but don't know what expression to write in order to get the specific cell value.
Find more posts tagged with
Comments
Reji
Hi,
try
dataSetRow["cellColumn"]
as the expression for the data field.
Regs,
Reji
Mihsah
Hm, but that selects the entire column. I only want the cellColumn value where idColumn = 'myUniqueID'.
cypherdj
Where would the value for uniqueID be coming from? Another data cell?
If you can explain a bit further what you're trying to achieve with your SQL script, it may be easier to provide some help.
Mihsah
Sorry for not making myself clear.
The thing is that the database table contains two columns: idColumn and cellColumn. The values in idColumns contains unique id's (keys) and the values in cellColumn contains the corresponding values.
I want to find the value in cellColumn having the key 'myUniqueID' in idColumn.
Eg.
idColumn cellColumn
'one id' 3
'another_id' 4
'myUniqueID' 22
'hello' 1
In the example, I would want to get the value 22.
cypherdj
You could use a global variable, like in the example attached.
Note that I needed to display the dataset BEFORE displaying the dynamic text, or the global variable will not be set.
Obviously, if your dataset is bound to a parameter, then you will not have this problem.
Also, you will need to change the location of the log file, or remove the logging code which I added to test my code!
Hope that helps,
Cedric
Mihsah
Thanks, but the getPersistentGlobalVariable gives the value null even though I display the dataset at the top. Maybe my newer version of Birt ruins the code where the global variable is set? (I downloaded it just a few days ago).
EDIT: Now it works! It was only in the preview it didn't work. Thanks again!
Green
I also have the same that problem but that is after open database. I can't get the true value that i want.
Eg: i have 1 dataset called Item that has alot of row. so i want to get column i of row j. How to do that. Pls help me.
Thanks advance.