Birt Report Multiple Parameter - birt

Currently I'm using Birt Report to generate report from my system. I'm using input parameter to send parameter from my system to Birt Report. The problem is when I'm trying to send multiple parameter from my system.
Example: SQL statement at Birt Report for one parameter
select column1 from table1 where column2 = ?
When I use this query for one parameter, it work.
What I'm trying to achieve now,
select column1 from table1 where column2 = ? AND column1 = ?
I tried SQL like this
select column1 from table1 where column2 = params["column2"].value AND column1 = params["column1"].value
I already created parameter at data set and report parameter but it's still can't gets to work

No difference if you have one or multiple parameters.
In the 'Edit Data Set' dialog add your query in the 'Query' section with ?
then switch to the 'Parameters' section and add parameters with 'Default Value' params["prmName"].value or even simpler 'Linked To Report Parameter' prmName
e.g. for your example
Query
select column1 from table1 where column2 = ? AND column1 = ?
Parameters
Name Data Type Direction Default Value Linked To Report Parameter
column2 Decimal Input column2
column1 Decimal Input column1
You can move the parameters up and down. Parameters are matched to the ? in your query by this order. The Name is irelevant...

Related

Oracle DB: custom field delimiter for sql query

Query:
select * from tableA;
result:
column1 column2
------- -------
row1-1 row1-2
row2-1 row2-2
row3-1 row3-1
How can I turn the result above into something below.
column1|column2
------- -------
row1-1 | row1-2
row2-1 | row2-2
row3-1 | row3-1
The assumptions here is that the user will not know what are the columns in the table in advance. This means that using || to do string concatenation on the result set is not preferred.
select column1 ||,|| column2 from tableA <---- This is not what I am looking for.
Note: These tables are already created and I do not have the admin rights to modify the table schema.
If you are running your query in sqlplus, you can do
set colsep '|'
before your query and you should get the output as listed, though the header separator line will also have the same column separator -------|-------
This will apply to all subsequent queries

how to get column names from Hive table, if that column contains null values?

I tried with following queries, these queries giving only the count of null values, What i need was to do a null check and return the column name.
select count(*)-count(columnA), count(*)-count(columnB) from table;
select count(*) from table where columnA is null;
You can also do
SELECT
SUM(IF(columnA is NULL,1,0)) as canulls,
SUM(IF(columnB is NULL,1,0)) as cbnulls
FROM table;
This will also give you the number of null fields for each columns.

How to get all not null columns in a table

I have a requirement to find all not-null columns in a table. For example, my table is the below one
Lets say, Column1, Column2 and Column3 have not-null constraints and Column4, Column5 and Column6 are of nullable types. Is there any query in Oracle that list the column names that are of not-null types, ie I need to get the column names Column1, Column2 and Column3.
DESIRED OUTPUT
Column1
Column2
Column3
I know there should be a simple way to achieve this, but am new to Oracle. Any help would be highly appreciated.
You can query the all_tab_columns table:
select column_name
from all_tab_columns
where table_name = 'TABLE1'
and nullable = 'N';
I know there should be a simple way to achieve this, but am new to Oracle.
Well, online documentation is exactly what you need to look into.
Depending on the privilege, you need to look into [DBA|USER|ALL]_TAB_COLUMNS.
ALL_TAB_COLUMNS
Column Datatype Description
NULLABLE VARCHAR2(1) Indicates whether a column allows NULLs.
The value is N if there is a NOT NULL constraint
on the column or if the column is part of a PRIMARY KEY.
The constraint should be in an ENABLE VALIDATE state.
So, per the documentation, you need to use the filter:
NULLABLE = 'N'

filter tablix without datasource values in ssrs

I have SSRS report and I need to filter a static table that I created inside the report based on parameter. There is no data source to this table and I'm entering the data manually.
The tablix contain 3 columns.
How can I filter the columns based on parameter?
I tried in the expression =#param1 for example but it doesn't work.
For now I only manage to filter if the expression is on data source fields.
Do you literally have a table with a number of values in it written directly into the report? If so I don't think you will be able to perform any filtering on it as effectively all you've done it write data into textboxes that are displayed.
I would imagine your best option would be to instead create a new dataset and populate this with your static data, e.g.
SELECT 'A' AS Letter, 'English' AS Language
UNION
SELECT 'B' AS Letter, 'French' AS Language
UNION
SELECT 'A' AS Letter, 'German' AS Language
To give you a table as follows
Letter | Language
-------+----------
A | English
B | French
A | German
That you could then filter on Letter = A
So essentially you have a Tablix that has 3 columns pre-populated with information you have manually entered into the text boxes themselves? Since you've already entered that data, I don't believe there is a way to filter that at run time. That data is hard coded in essence. The Filter ability in SSRS is used as a WHERE clause so it restricts what is brought forth into the report from the query.
I would create a data source connection to a dummy database, create a DataSet, and create a query that fills a temporary table will all the information that you've manually entered. Once you create the temporary table and inserted values into it, you can then perform a SELECT with a parameter. Your Tablix will only be populated with information that matches the parameter. Something to the effect of this:
CREATE TABLE #TempTable (
ID INT
,Name VARCHAR(MAX)
,Email VARCHAR(MAX)
)
INSERT INTO #TempTable (
ID
,Name
,Email
)
VALUES (
1
,'Bob'
,'bob#email.com'
)
,(
2
,'Frank'
,'frank#email.com'
)
,(
3
,'Jim'
,'jim#email.com'
)
SELECT
*
FROM
#TempTable
WHERE
ID = #ID
DROP TABLE #TempTable

how to pass parameter to oracle update statement from csv file and excluding null values from csv

I have a situation where I have following csv file(say file.csv) with following data:
AcctId,Name,OpenBal,closingbal
1,abc,1000,
2,,0,
3,xyz,,
4,,,
how can I loop through this file using unix shell and say for example for column $2 (Name) , I want to get all occurances of Name column accept null values and pass it to for example following oracle query with single quotes '','' format?
select * from account
where name in (collection of values from csv file column name
but excluding null values)
and openbal in
and same thing for column 3 (collection of values from csv file column Openbal
but excluding null values)
and same thing for column 4 (collection of values from csv file column
closingbal but excluding null values)
In short what I want is pass the csv column values as input parameter to oracle sql query and update query too ? but again I dont want to include null values in it. If a column is entirely null for all rows I want to exclude it too?
Not sure why you'd want to loop through this file in a unix shell script: perhaps because you can't think of any better approach? Anyway, I'm going to skip that and offer a pure Oracle solution.
We can expose data in CSV files to the database using external tables. These are like regular tables except their data comes from files in OS directories on the database server (rather than the database's storage). Find out more.
Given this approach it is easy to write the query you want. I suggest using sub-query factoring to select from the external table once.
with cte as ( select name, openbal, closingbal
from your_external_tab )
select *
from account a
where a.name in ( select cte.name from cte )
and a.openbal in ( select cte.openbal from cte )
and a.closingbal in ( select cte.closingbal from cte )
The behaviour of the IN clause is to exclude NULL from consideration.
Incidentally, that will return a different (larger) result set from this:
select a.*
from account a
, your_external_table e
where a.name = e.name
and a.openbal= e.openbal
and a.closingbal = e.closingbal

Resources