Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Passing parameters via URL
codename_
I set a query like "Select * from mydb where id = ?"
then i set the parameter as "id, integer, default value = 0"
then my url "
http://localhost:8080/WebViewerExample/preview?__report=new_report_1.rptdesign&id=1"
;
but it doest pass the parameter...how to solve this?
Find more posts tagged with
Comments
codename_
what's wrong with my procedure?
kclark
Hi codename, have you linked the query to the parameter in the parameters tab in edit data set?
codename_
Hi Kclark...
I only did set the parameter as "id, integer, default value = 0"
do i need to configure property binding? I dont want to enter any id in the dialog box that's why I choose to have the paremeter in my url.
codename_
Do i need to link it to report parameter?But I dont want to prompt for parameter...
kclark
You'd still need to link the parameter. As long as you keep "Is Required" unchecked you won't be prompted for a parameter and you can pass it in the URL. I've attached an example, I passed the state to the report using this:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>http://localhost:8080/birt/frameset?__report=paramsexample.rptdesign&NewParameter=CA</pre>
codename_
@kclark
Ive got some error
Table (id = 7):
+ An exception occurred during processing. Please see the following message for details:
Failed to prepare the query execution for the data set: Data Set
Cannot set a null value to parameter 1.
org.eclipse.birt.report.data.oda.jdbc.JDBCException: Cannot set preparedStatement null value.
SQL error #1:Parameter metadata not available for the given statement
kclark
Can you post your rptdesign please?
codename_
what I did was I make a query first
select *
from news_item
where id = ?
then I set the parameter to the parameters tab
Name=id
DataType=int
Direction=input
Linked to Report Parameter=(ParamName with "isRequired Unchecked")
Then my URL "
http://localhost:8080/WebViewerExample/preview?__report=new_report_1.rptdesign&id=1"
;
Why still have errors?
codename_
Here is my design<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'><?xml version="1.0" encoding="UTF-8"?>
<report xmlns="http://www.eclipse.org/birt/2005/design" version="3.2.23" id="1">
<property name="createdBy">Eclipse BIRT Designer Version 3.7.2.v20120213 Build <3.7.2.v20120214-1408></property>
<list-property name="propertyBindings">
<structure>
<property name="name">queryText</property>
<property name="id">24</property>
</structure>
<structure>
<property name="name">queryTimeOut</property>
<property name="id">24</property>
</structure>
<structure>
<property name="name">rowFetchSize</property>
<property name="id">24</property>
</structure>
</list-property>
<property name="units">in</property>
<property name="iconFile">/templates/blank_report.gif</property>
<property name="bidiLayoutOrientation">ltr</property>
<property name="imageDPI">96</property>
<parameters>
<scalar-parameter name="NewParameter" id="33">
<property name="valueType">static</property>
<property name="isRequired">false</property>
<property name="dataType">integer</property>
<property name="distinct">true</property>
<list-property name="selectionList"/>
<property name="paramType">simple</property>
<property name="controlType">text-box</property>
<structure name="format">
<property name="category">General Number</property>
<property name="pattern">General Number</property>
</structure>
</scalar-parameter>
</parameters>
<data-sources>
<oda-data-source extensionID="org.eclipse.birt.report.data.oda.jdbc" name="Data Source" id="23">
<list-property name="privateDriverProperties">
<ex-property>
<name>metadataBidiFormatStr</name>
<value>ILYNN</value>
</ex-property>
<ex-property>
<name>disabledMetadataBidiFormatStr</name>
</ex-property>
<ex-property>
<name>contentBidiFormatStr</name>
<value>ILYNN</value>
</ex-property>
<ex-property>
<name>disabledContentBidiFormatStr</name>
</ex-property>
</list-property>
<property name="odaDriverClass">com.mysql.jdbc.Driver</property>
<property name="odaURL">jdbc:mysql://localhost:3307/publisher</property>
<property name="odaUser">root</property>
<encrypted-property name="odaPassword" encryptionID="base64">cm9vdA==</encrypted-property>
</oda-data-source>
</data-sources>
<data-sets>
<oda-data-set extensionID="org.eclipse.birt.report.data.oda.jdbc.JdbcSelectDataSet" name="Data Set" id="24">
<property name="nullsOrdering">nulls lowest</property>
<list-property name="parameters">
<structure>
<property name="name">id</property>
<property name="dataType">integer</property>
<property name="position">1</property>
<expression name="defaultValue" type="javascript">2</expression>
<property name="isInput">true</property>
<property name="isOutput">false</property>
</structure>
</list-property>
<structure name="cachedMetaData">
<list-property name="resultSet">
<structure>
<property name="position">1</property>
<property name="name">id</property>
<property name="dataType">integer</property>
</structure>
<structure>
<property name="position">2</property>
<property name="name">title</property>
<property name="dataType">string</property>
</structure>
<structure>
<property name="position">3</property>
<property name="name">url</property>
<property name="dataType">string</property>
</structure>
</list-property>
</structure>
<property name="dataSource">Data Source</property>
<list-property name="resultSet">
<structure>
<property name="position">1</property>
<property name="name">id</property>
<property name="nativeName">id</property>
<property name="dataType">integer</property>
</structure>
<structure>
<property name="position">2</property>
<property name="name">title</property>
<property name="nativeName">title</property>
<property name="dataType">string</property>
</structure>
<structure>
<property name="position">3</property>
<property name="name">url</property>
<property name="nativeName">url</property>
<property name="dataType">string</property>
</structure>
</list-property>
<xml-property name="queryText"><![CDATA[select *
from news_item
where id = ?]]></xml-property>
<xml-property name="designerValues"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
<model:DesignValues xmlns:design="http://www.eclipse.org/datatools/connectivity/oda/design" xmlns:model="http://www.eclipse.org/birt/report/model/adapter/odaModel">
<Version>2.0</Version>
<design:ResultSets derivedMetaData="true">
<design:resultSetDefinitions>
<design:resultSetColumns>
<design:resultColumnDefinitions>
<design:attributes>
<design:identifier>
<design:name>id</design:name>
<design:position>1</design:position>
</design:identifier>
<design:nativeDataTypeCode>4</design:nativeDataTypeCode>
<design:precision>11</design:precision>
<design:scale>0</design:scale>
<design:nullability>NotNullable</design:nullability>
<design:uiHints>
<design:displayName>id</design:displayName>
</design:uiHints>
</design:attributes>
<design:usageHints>
<design:label>id</design:label>
<design:formattingHints>
<design:displaySize>11</design:displaySize>
</design:formattingHints>
</design:usageHints>
</design:resultColumnDefinitions>
<design:resultColumnDefinitions>
<design:attributes>
<design:identifier>
<design:name>title</design:name>
<design:position>2</design:position>
</design:identifier>
<design:nativeDataTypeCode>12</design:nativeDataTypeCode>
<design:precision>21845</design:precision>
<design:scale>0</design:scale>
<design:nullability>NotNullable</design:nullability>
<design:uiHints>
<design:displayName>title</design:displayName>
</design:uiHints>
</design:attributes>
<design:usageHints>
<design:label>title</design:label>
<design:formattingHints>
<design:displaySize>21845</design:displaySize>
</design:formattingHints>
</design:usageHints>
</design:resultColumnDefinitions>
<design:resultColumnDefinitions>
<design:attributes>
<design:identifier>
<design:name>url</design:name>
<design:position>3</design:position>
</design:identifier>
<design:nativeDataTypeCode>12</design:nativeDataTypeCode>
<design:precision>21845</design:precision>
<design:scale>0</design:scale>
<design:nullability>NotNullable</design:nullability>
<design:uiHints>
<design:displayName>url</design:displayName>
</design:uiHints>
</design:attributes>
<design:usageHints>
<design:label>url</design:label>
<design:formattingHints>
<design:displaySize>21845</design:displaySize>
</design:formattingHints>
</design:usageHints>
</design:resultColumnDefinitions>
</design:resultSetColumns>
<design:criteria/>
</design:resultSetDefinitions>
</design:ResultSets>
</model:DesignValues>]]></xml-property>
</oda-data-set>
</data-sets>
<styles>
<style name="report" id="4">
<property name="fontFamily">sans-serif</property>
<property name="fontSize">10pt</property>
</style>
<style name="crosstab-cell" id="5">
<property name="borderBottomColor">#CCCCCC</property>
<property name="borderBottomStyle">solid</property>
<property name="borderBottomWidth">1pt</property>
<property name="borderLeftColor">#CCCCCC</property>
<property name="borderLeftStyle">solid</property>
<property name="borderLeftWidth">1pt</property>
<property name="borderRightColor">#CCCCCC</property>
<property name="borderRightStyle">solid</property>
<property name="borderRightWidth">1pt</property>
<property name="borderTopColor">#CCCCCC</property>
<property name="borderTopStyle">solid</property>
<property name="borderTopWidth">1pt</property>
</style>
<style name="crosstab" id="6">
<property name="borderBottomColor">#CCCCCC</property>
<property name="borderBottomStyle">solid</property>
<property name="borderBottomWidth">1pt</property>
<property name="borderLeftColor">#CCCCCC</property>
<property name="borderLeftStyle">solid</property>
<property name="borderLeftWidth">1pt</property>
<property name="borderRightColor">#CCCCCC</property>
<property name="borderRightStyle">solid</property>
<property name="borderRightWidth">1pt</property>
<property name="borderTopColor">#CCCCCC</property>
<property name="borderTopStyle">solid</property>
<property name="borderTopWidth">1pt</property>
</style>
</styles>
<page-setup>
<simple-master-page name="Simple MasterPage" id="2">
<page-footer>
<text id="3">
<property name="contentType">html</property>
<text-property name="content"><![CDATA[<value-of>new Date()</value-of>]]></text-property>
</text>
</page-footer>
</simple-master-page>
</page-setup>
<body>
<table id="7">
<property name="dataSet">Data Set</property>
<list-property name="paramBindings">
<structure>
<property name="paramName">id</property>
<simple-property-list name="expression">
<value type="javascript">params["NewParameter"].value</value>
</simple-property-list>
</structure>
</list-property>
<list-property name="boundDataColumns">
<structure>
<property name="name">id</property>
<text-property name="displayName">id</text-property>
<expression name="expression" type="javascript">dataSetRow["id"]</expression>
<property name="dataType">integer</property>
</structure>
<structure>
<property name="name">title</property>
<text-property name="displayName">title</text-property>
<expression name="expression" type="javascript">dataSetRow["title"]</expression>
<property name="dataType">string</property>
</structure>
<structure>
<property name="name">url</property>
<text-property name="displayName">url</text-property>
<expression name="expression" type="javascript">dataSetRow["url"]</expression>
<property name="dataType">string</property>
</structure>
</list-property>
<column id="20"/>
<column id="21"/>
<column id="22"/>
<header>
<row id="8">
<cell id="9">
<label id="25">
<text-property name="text">id</text-property>
</label>
</cell>
<cell id="10">
<label id="27">
<text-property name="text">title</text-property>
</label>
</cell>
<cell id="11">
<label id="29">
<text-property name="text">url</text-property>
</label>
</cell>
</row>
</header>
<detail>
<row id="12">
<property name="height">0.40625in</property>
<cell id="13">
<data id="26">
<property name="resultSetColumn">id</property>
</data>
</cell>
<cell id="14">
<data id="28">
<property name="resultSetColumn">title</property>
</data>
</cell>
<cell id="15">
<data id="30">
<property name="resultSetColumn">url</property>
</data>
</cell>
</row>
</detail>
<footer>
<row id="16">
<cell id="17"/>
<cell id="18"/>
<cell id="19"/>
</row>
</footer>
</table>
</body>
</report>
</pre>
codename_
OH! I figured out the problem. I set id to my url instead of using the paramName