Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » BIRT » Cannot call a function when creating a dataset(Need help in calling a function when creating a dataset)
Cannot call a function when creating a dataset [message #658777] Wed, 09 March 2011 13:28 Go to next message
anna.w.teittinen is currently offline anna.w.teittinen
Messages: 23
Registered: February 2011
Junior Member
Hello,

I ran into a problem I hope someone can help.

I created a function in Oracle 10g XE as such:

------
create or replace package GetEmployeeCursors is
type empResultSet is REF CURSOR;
function Funct1 return empResultSet;
end GetEmployeeCursors;
/


create or replace package body GetEmployeeCursors is function Funct1 return empResultSet is
tmpResultSet empResultSet;
begin
open tmpResultSet for
select * from employee;
return tmpResultSet;
end Funct1;
end GetEmployeeCursors;
/
------

The goal is simply to return a result set cursor so that I can query it when I create a new dataset in a BIRT report.

From the sqlplus command line, I am able to call function GetEmployeeCursors.Funct1 successfully in 2 different ways:

(1)
SQL> select GetEmployeeCursors.Funct1 FROM dual;

(2)
SQL> variable cursor_ret refcursor;
SQL> exec :cursor_ret := getEmployeecursors.funct1;


In creating a new dataset within BIRT, I set the Data Set Type to "SQL Select Query". On the Query screen, I entered:
select GetEmployeeCursors.Funct1
from FROM dual;
But I got the following error when I tried to preview the resutls:

A BIRT exception occurred.
Plug-in Provider:Eclipse.org
Plug-in Name:BIRT Data Engine
Plug-in ID:org.eclipse.birt.data
Version:2.5.2.v20100209
Error Code:odaconsumer.CannotGetResultSetMetaData
Error Message:Cannot get the result set metadata.
SQL statement does not return a ResultSet object.
SQL error #1: ORA-00903: invalid table name


If this works on the sqlplus command line, why doesn't it work within BIRT?
I thought the function returns a ResultSet object.
Can anyone pinpoint what should I be doing instead to call that function?

Thanks so much advance,
--Anna
Re: Cannot call a function when creating a dataset [message #658793 is a reply to message #658777] Wed, 09 March 2011 14:27 Go to previous messageGo to next message
Richard A. Polunsky is currently offline Richard A. Polunsky
Messages: 197
Registered: July 2009
Location: Houston TX
Senior Member

It looks like you have the word "from" twice there. Remove the extra FROM and see if it works.
Re: Cannot call a function when creating a dataset [message #658797 is a reply to message #658793] Wed, 09 March 2011 14:37 Go to previous messageGo to next message
anna.w.teittinen is currently offline anna.w.teittinen
Messages: 23
Registered: February 2011
Junior Member
Hello Richard,

Thank you for noticing that typo error I had.
I re-typed my query on the query window correctly:

select GetEmployeeCursors.Funct1
from dual;

I still get an error message:

A BIRT exception occurred.
Plug-in Provider:Eclipse.org
Plug-in Name:BIRT Data Engine
Plug-in ID:org.eclipse.birt.data
Version:2.5.2.v20100209
Error Code:odaconsumer.CannotGetResultSetMetaData
Error Message:Cannot get the result set metadata.
SQL statement does not return a ResultSet object.
SQL error #1: ORA-00911: invalid character

Do you I am missing something from the Funct1 implementation? I can't figure out why the select statement above works on the Oracle cmd line but not within BIRT.

Thanks so much again,
--Anna

Re: Cannot call a function when creating a dataset [message #658806 is a reply to message #658777] Wed, 09 March 2011 15:39 Go to previous messageGo to next message
Richard A. Polunsky is currently offline Richard A. Polunsky
Messages: 197
Registered: July 2009
Location: Houston TX
Senior Member

Here is what I did some time back. I haven't checked to see if it still works:

PROC DEFINITION:

create or replace package status_report AS
type t_cursor is REF CURSOR;
procedure get_statuses(io_cursor IN OUT t_cursor);
END status_report;
/
create or replace package body status_report as
procedure get_statuses(io_cursor IN OUT t_cursor)
IS
v_cursor t_cursor;
BEGIN
OPEN v_cursor FOR
SELECT name, id, description, is_active, is_default, status_type
FROM status;

io_cursor := v_cursor;
END get_statuses;
END status_report;
/

I'l have to see whether that works in 2.5.0 and Oracle 11.
Re: Cannot call a function when creating a dataset [message #658817 is a reply to message #658777] Wed, 09 March 2011 17:20 Go to previous messageGo to next message
Richard A. Polunsky is currently offline Richard A. Polunsky
Messages: 197
Registered: July 2009
Location: Houston TX
Senior Member

I have the following working under BIRT 2.3:

In Oracle:

create or replace package birt_support AS
type t_cursor is REF CURSOR;
END birt_support;
/
create or replace procedure get_stattest( outcursor OUT birt_support.t_cursor )
as
begin
open outcursor for select name, id, description, is_active, is_default, status_type from status;
end get_stattest;
/

In BIRT:
Create a new report with an Oracle datasource pointed to my schema.
Create a dataset of type SQL Stored Procedure Query
For the query, either drag and drop or directly enter:

{call ROME.GET_STATTEST(?)}

If you drag and drop, the parameter should be automatically created. Otherwise you will need to do that yourself. In either case you want to check that you have:

Parameter Name = outcursor
Type = Any
Direction = Output

I'll have to post the XML of my test report separately. You'll have to translate the data connection to your own environment, of course.
Re: Cannot call a function when creating a dataset [message #658818 is a reply to message #658817] Wed, 09 March 2011 17:22 Go to previous messageGo to next message
Richard A. Polunsky is currently offline Richard A. Polunsky
Messages: 197
Registered: July 2009
Location: Houston TX
Senior Member

<?xml version="1.0" encoding="UTF-8"?>
<report xmlns="http://www.eclipse.org/birt/2005/design" version="3.2.16" id="1">
<property name="createdBy">Eclipse BIRT Designer Version 2.3.0.v20080606 Build &lt;2.3.0.v20080618-0630></property>
<property name="units">in</property>
<property name="iconFile">/templates/blank_report.gif</property>
<data-sources>
<oda-data-source extensionID="org.eclipse.birt.report.data.oda.jdbc" name="Data Source" id="6">
<property name="odaDriverClass">oracle.jdbc.OracleDriver</property>
<property name="odaURL">jdbc:oracle:thin:@demo17:1521:rome1020a</property >
<property name="odaUser">myschema</property>
<encrypted-property name="odaPassword" encryptionID="base64">cjPtZQ==</encrypted-property>
</oda-data-source>
</data-sources>
<data-sets>
<oda-data-set extensionID="org.eclipse.birt.report.data.oda.jdbc.SPSelectDataSet " name="Data Set" id="7">
<structure name="cachedMetaData">
<list-property name="resultSet">
<structure>
<property name="position">1</property>
<property name="name">NAME</property>
<property name="dataType">string</property>
</structure>
<structure>
<property name="position">2</property>
<property name="name">ID</property>
<property name="dataType">decimal</property>
</structure>
<structure>
<property name="position">3</property>
<property name="name">DESCRIPTION</property>
<property name="dataType">string</property>
</structure>
<structure>
<property name="position">4</property>
<property name="name">IS_ACTIVE</property>
<property name="dataType">string</property>
</structure>
<structure>
<property name="position">5</property>
<property name="name">IS_DEFAULT</property>
<property name="dataType">string</property>
</structure>
<structure>
<property name="position">6</property>
<property name="name">STATUS_TYPE</property>
<property name="dataType">string</property>
</structure>
</list-property>
</structure>
<property name="dataSource">Data Source</property>
<list-property name="parameters">
<structure>
<property name="name">OUTCURSOR</property>
<property name="nativeName">OUTCURSOR</property>
<property name="nativeDataType">-10</property>
<property name="position">1</property>
<property name="allowNull">true</property>
<property name="isOutput">true</property>
</structure>
</list-property>
<list-property name="resultSet">
<structure>
<property name="position">1</property>
<property name="name">NAME</property>
<property name="nativeName">NAME</property>
<property name="dataType">string</property>
</structure>
<structure>
<property name="position">2</property>
<property name="name">ID</property>
<property name="nativeName">ID</property>
<property name="dataType">decimal</property>
</structure>
<structure>
<property name="position">3</property>
<property name="name">DESCRIPTION</property>
<property name="nativeName">DESCRIPTION</property>
<property name="dataType">string</property>
</structure>
<structure>
<property name="position">4</property>
<property name="name">IS_ACTIVE</property>
<property name="nativeName">IS_ACTIVE</property>
<property name="dataType">string</property>
</structure>
<structure>
<property name="position">5</property>
<property name="name">IS_DEFAULT</property>
<property name="nativeName">IS_DEFAULT</property>
<property name="dataType">string</property>
</structure>
<structure>
<property name="position">6</property>
<property name="name">STATUS_TYPE</property>
<property name="nativeName">STATUS_TYPE</property>
<property name="dataType">string</property>
</structure>
</list-property>
<property name="queryText">{call MYSCHEMA.GET_STATTEST(?)}</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>1.0</Version>
<design:DataSetParameters>
<design:parameterDefinitions>
<design:inOutMode>Out</design:inOutMode>
<design:attributes>
<design:name>OUTCURSOR</design:name>
<design:position>1</design:position>
<design:nativeDataTypeCode>-10</design:nativeDataTypeCode>
<design:precision>0</design:precision>
<design:scale>0</design:scale>
<design:nullability>Nullable</design:nullability>
</design:attributes>
</design:parameterDefinitions>
</design:DataSetParameters>
</model:DesignValues>
]]></xml-property>
</oda-data-set>
</data-sets>
<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="8">
<property name="width">100%</property>
<property name="dataSet">Data Set</property>
<list-property name="boundDataColumns">
<structure>
<property name="name">NAME</property>
<property name="displayName">NAME</property>
<expression name="expression">dataSetRow["NAME"]</expression>
<property name="dataType">string</property>
</structure>
<structure>
<property name="name">ID</property>
<property name="displayName">ID</property>
<expression name="expression">dataSetRow["ID"]</expression>
<property name="dataType">decimal</property>
</structure>
<structure>
<property name="name">DESCRIPTION</property>
<property name="displayName">DESCRIPTION</property>
<expression name="expression">dataSetRow["DESCRIPTION"]</expression >
<property name="dataType">string</property>
</structure>
<structure>
<property name="name">IS_ACTIVE</property>
<property name="displayName">IS_ACTIVE</property>
<expression name="expression">dataSetRow["IS_ACTIVE"]</expression>
<property name="dataType">string</property>
</structure>
<structure>
<property name="name">IS_DEFAULT</property>
<property name="displayName">IS_DEFAULT</property>
<expression name="expression">dataSetRow["IS_DEFAULT"]</expression>
<property name="dataType">string</property>
</structure>
<structure>
<property name="name">STATUS_TYPE</property>
<property name="displayName">STATUS_TYPE</property>
<expression name="expression">dataSetRow["STATUS_TYPE"]</expression >
<property name="dataType">string</property>
</structure>
</list-property>
<column id="42"/>
<column id="43"/>
<column id="44"/>
<column id="45"/>
<column id="46"/>
<column id="47"/>
<header>
<row id="9">
<cell id="10">
<label id="11">
<text-property name="text">NAME</text-property>
</label>
</cell>
<cell id="12">
<label id="13">
<text-property name="text">ID</text-property>
</label>
</cell>
<cell id="14">
<label id="15">
<text-property name="text">DESCRIPTION</text-property>
</label>
</cell>
<cell id="16">
<label id="17">
<text-property name="text">IS_ACTIVE</text-property>
</label>
</cell>
<cell id="18">
<label id="19">
<text-property name="text">IS_DEFAULT</text-property>
</label>
</cell>
<cell id="20">
<label id="21">
<text-property name="text">STATUS_TYPE</text-property>
</label>
</cell>
</row>
</header>
<detail>
<row id="22">
<cell id="23">
<data id="24">
<property name="resultSetColumn">NAME</property>
</data>
</cell>
<cell id="25">
<data id="26">
<property name="resultSetColumn">ID</property>
</data>
</cell>
<cell id="27">
<data id="28">
<property name="resultSetColumn">DESCRIPTION</property>
</data>
</cell>
<cell id="29">
<data id="30">
<property name="resultSetColumn">IS_ACTIVE</property>
</data>
</cell>
<cell id="31">
<data id="32">
<property name="resultSetColumn">IS_DEFAULT</property>
</data>
</cell>
<cell id="33">
<data id="34">
<property name="resultSetColumn">STATUS_TYPE</property>
</data>
</cell>
</row>
</detail>
<footer>
<row id="35">
<cell id="36"/>
<cell id="37"/>
<cell id="38"/>
<cell id="39"/>
<cell id="40"/>
<cell id="41"/>
</row>
</footer>
</table>
</body>
</report>
Re: Cannot call a function when creating a dataset [message #658826 is a reply to message #658818] Wed, 09 March 2011 17:49 Go to previous messageGo to next message
anna.w.teittinen is currently offline anna.w.teittinen
Messages: 23
Registered: February 2011
Junior Member
Hello Richard,

Thank you so much for all your help.
I will try out everything you mentioned!

--Anna
Re: Cannot call a function when creating a dataset [message #658827 is a reply to message #658817] Wed, 09 March 2011 18:01 Go to previous message
anna.w.teittinen is currently offline anna.w.teittinen
Messages: 23
Registered: February 2011
Junior Member
Hello Richard,

Thank you so very much!
The stored procedure works now!

The following was set by default:

Parameter Name = outcursor
Type = Any
Direction = Output

Thanks so much again!
I will follow your example the next time around too!
--Anna
Previous Topic:create a report in code
Next Topic:Can't get year from date using getYear or getFullYear
Goto Forum:
  


Current Time: Sat Apr 19 11:41:41 EDT 2014

Powered by FUDForum. Page generated in 0.02040 seconds