简体   繁体   English

Birt报告-未从Postgres RefCursor获取数据

[英]Birt Report - Not gettting data from Postgres RefCursor

I have this: 我有这个:

POSTGRES 邮编

/*THE PARAMETER in_test_id IS ONLY A TEST!!*/
CREATE OR REPLACE FUNCTION public.test_birt(in_test_id bigint DEFAULT NULL::bigint)
  RETURNS refcursor AS
$BODY$
DECLARE
    query text;
    tcursor   refcursor = 'tcursor';
BEGIN
    query := 'SELECT * FROM MY_TABLE';

    OPEN tcursor FOR execute query;
    return tcursor;
END;
$BODY$
  LANGUAGE plpgsql VOLATILE
  COST 100;

BIRT BIRT

DATASET --> MyDataset --> select * from test_birt(?::bigint) 数据集-> MyDataset-> select * from test_birt(?::bigint)

Here the screenshots: 这里的截图:

Report Design 报告设计 在此处输入图片说明

Report Preview 报告预览 在此处输入图片说明

I need that Birt shows the values of MY_TABLE !!. 我需要Birt显示MY_TABLE的值! In this case, this table have one varchar field, with the values: TEST1 , TEST2 , TEST3 . 在这种情况下,此表具有一个varchar字段,其值是: TEST1TEST2TEST3 The Birt Version is 3.2 and the postgres is 9.2 . Birt版本是3.2 ,而postgres9.2

NOTE The unique solution that i found was create a datatype and change the return datatype from my function, something like this: 注意我发现的唯一解决方案是创建一个数据类型并从函数中更改返回数据类型,如下所示:

RETURNS SETOF my_type AS

But I need that Bird can read this RefCursor. 但我需要Bird可以阅读此RefCursor。

You miss a FETCH statement. 您错过了一条FETCH语句。

When you call a function, then cursor "tcursor" is created (and opened). 调用函数时,将创建(并打开)游标“ tcursor”。 But nobody try to read from it. 但是没有人尝试阅读它。 And without explicit support in Birt is impossible to call function and fetch data from cursor. 如果没有Birt的明确支持,就无法调用函数并从游标中获取数据。 You can try a hack - that can work or not (depends on implementation in Birt) - use following commands as source for dataset: 您可以尝试破解-是否有效(取决于Birt中的实现)-使用以下命令作为数据集的来源:

SELECT test_birt(?::bigint); FETCH ALL FROM tcursor;

I found link that shows so Birt didn't support it 5 years ago. 我发现显示的链接使Birt在5年前不支持它。

On second hand. 另一方面。 In 9.2 you don't need to define own types for returning tables. 在9.2中,您不需要为返回表定义自己的类型。 You can use a table types - when you can return all columns or you can define output columns via TABLE keywords: 您可以使用表类型-当您可以返回所有列或可以通过TABLE关键字定义输出列时:

 CREATE TABLE foo(a int, b int); -- automatically it defined type foo

 CREATE OR REPLACE FUNCTION read_from_foo_1(_a int)
 RETURNS SETOF foo AS $$
   SELECT * FROM foo WHERE foo.a = _a;
 $$ LANGUAGE SQL;

or 要么

 CREATE OR REPLACE FUNCTION read_from_foo_2()
 RETURNS TABLE(a int, b int, c int) AS $$
   SELECT a, b, a + b FROM foo;
 $$ LANGUAGE SQL;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 从多个Birt报表中获取数据到单个BIRT报表中 - Fetching Data from Multiple Birt Report into a single BIRT Report 为什么在Postgres中不获取显示自refcursor的数据? - Why isn't fetch showing data from refcursor in Postgres? Postgres存储过程在Birt报告中重现光标 - Postgres Stored Procedures returing cursor in birt report POSTGRES:从函数返回的反射器上选择查询 - POSTGRES: Select query on a refcursor returned from a function 无法打开驱动程序的连接:org.eclipse.birt.report.data.oda.jdbc。 使用数据库 postgres - Cannot open the connection for the driver: org.eclipse.birt.report.data.oda.jdbc. using database postgres 从 postgres function 返回带有错误代码和消息的 refcursor - returning a refcursor with error code and message from postgres function 如何在pgadmin postgresql中从refcursor查看数据 - how can view data from refcursor in pgadmin postgresql CodeIgniter和PostgreSQL-从函数返回的refcursor中检索数据 - CodeIgniter and PostgreSQL - Retrieving data from Function returning refcursor Birt报表引发PSQLException - Birt Report Throws PSQLException 从postgres db中获取节点js中的多个Refcursor(使用pg-promise) - Fetch multiple Refcursor in node js from postgres db (using pg-promise)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM