Dynamic Column Headings - Function returning colon delimited column list
I created a SQL report using the report wizard.
In the report options, I chose a heading type of:
Function returning colon delimited list of columns
I then wrote a function that returns a VARCHAR2 string.
I return a string like this...
Jan-04:Jan-11:Jan-18:Jan-25:Feb-01
In the text area labeled "Function returning colon delimited list",
I simply entered the name of the function, in this case,
the name is "WeekHeader".
When I execute the report, I get this error:
unable to determine query headings:
ORA-06550: line 1, column 45:
PLS-00221: 'WEEKHEADER' is not a procedure or is undefined
ORA-06550: line 1, column 45:
PL/SQL: Statement ignored
failed to parse SQL query:
How can I get the report to use my function?
all you need to do is put the word "return" in front of your function name, and you should be good to go. before you say it, i'll acknowledge that we should probably be more clear about the syntax for that field, so i'll log the enhancement request.
hope this helps,
raj
Similar Messages
-
Function returning colon delimited headings
Is it possible to use data within a classic report inside the PL/SQL headings? If so, how do you address the data as I have tried using '#FIELD_NAME#' without success.
for example: I have report data -
Emp mon tue wed thu fri mon_hd tue_hd wed_hd thu_hd fri_hd
Smith, Joe 1.5 1.5 3.5 8 3.5 7-OCT 8-OCT 9-OCT 10-OCT 11-OCT
Lucky, Larry 1.5 0 0 8 8 7-OCT 8-OCT 9-OCT 10-OCT 11-OCT
Johnson, Don 1.5 1.5 3.5 8 3.5 30-SEP 1-OCT 2-OCT 3-OCT 4-OCT
And I need output as such:
Employee Name MON TUE WED THU FRI
7-OCT 8-OCT 9-OCT 10-OCT 11-OCT
Smith, Joe 1.5 1.5 3.5 8 3.5
Lucky, Larry 1.5 0 0 8 8
Employee Name MON TUE WED THU FRI
30-SEP 1-OCT 2-OCT 3-OCT 4-OCT
Johnson, Don 1.5 1.5 3.5 8 3.5
Any help would be appreciated.
Thankswhile it is possible to have data as headings of a classic report, i think your requirement more suits the use of unpivot operator.
i say this because, i see
Employee Name MON TUE WED THU FRI
as the heading and then data of a few columns moved as rows
7-OCT 8-OCT 9-OCT 10-OCT 11-OCT
read ORACLE-BASE - PIVOT and UNPIVOT Operators in Oracle Database 11g Release 1
let me know if it helps -
Including item names in report column headings
I have a report where I want to use page items in the column headings. Trying to define these using (for example) &P1_ITEM. in the report definition / custom heading does not seem to work. I can define a simple PL/SQL function to return the heading, but I have many columns and it will mean that I'll have to define a function for each column name which does not seem v elegant. Am I missing something obvious?
Thanks SimonHi Simon
Column Attributes
Headings Type: Column Names Column Names (InitCap) Custom PL/SQL None choose PL/SQL
Function returning colon delimited headings:
DECLARE
vHEADINGS VARCHAR2(1000);
BEGIN
vHEADINGS := 'NAME:SURNAME:CODE:CELL_NR:&P1_CELL_1.:&P1_CELL_2.:&P1_CELL_3.:' || :XXX || ':' || :YYY || ':' || :ZZZZ || :A || ':' || :B || ':' || :C;
RETURN vHEADINGS;
END;Regards
Mel -
LOV of column names with a report's custom column headings?
I have a list ov values definition that looks like this:
select column_name d, column_name r from all_tab_columns where table_name = 'DATABASE_LIST'
I'd like to list the custom column headings from a report as d, rather than repeating the column_name. How can I do this?As Anton said, the best thing is to store your custom headings in a table so that you can use the table for your LOV as well as for your report headings.
To use dynamic report headings, you can use the 'PL/SQL function body returning colon-delimited headings' feature on the Report Attributes page.
So, if your report headings are stored in table t that function body can be
declare
l_headings varchar2(4000)
begin
for rec in (select heading from t) loop
l_headings := l_headings||':'||rec.heading;
end loop;
return ltrim(l_heading,':');
end;Hope this helps. -
Problems with PL/SQL Column Headings
Hello,
I experienced a strange behaviour and perhaps someone can verify it. Perhaps it's a bug, perhaps only some misunderstanding ...<br>
I created a Region with the Wizard: <br>
FORM<br>
TABULAR FORM<br>
Update Only<br>
Table EMP (all Attributes)<br>
Accept rest of Wizard defaults<br>
Create Region<br>
OK, everything works fine.<br>
Now I switched the column Headings to the Type "PL/SQL" and entered in the opening entry field: return('X:EMPNO:ENAME ...... (all Names)...) <br>
As well everything works fine, the columns are well named. Now I included into the SQL-Statement an additional attribute as a constant.<br>
select <br>
"EMPNO",<br>
"EMPNO" EMPNO_DISPLAY,<br>
"ENAME",<br>
"JOB",<br>
'X', <--------------- <br>
"MGR",<br>
"HIREDATE",<br>
"SAL",<br>
"COMM",<br>
"DEPTNO"<br>
from "#OWNER#"."EMP"<br>
Now I went back to the Report Attributes to include the new column into my return statement.... but the statement vanished. The little entry field for the PL/SQL-Statement to return the colon delimited header-list is not there and no more available. In the Radiolist for the Headings type it is selected but -as said- not there. (When I go back and erase the additional constand column, the entry-field for the PL/SQL-Statement reappears.)<br>
Does someone has the same experience or better, a solution ? (APEX 2.2)<br>
Thanks<br>
Andree
Message was edited by:
AndreeWorks !<br><br>
Thank you, Scott !<br>
A. -
Need to create a vertical view from horizontal table w/delimited column
I would like to create a vertical view frm a table that has a colon delimited column.
I can get a single row to work. I need the level to reset to 1 when the row changes.
any Ideas? the key to the table is: sos,nr,prgm_cd,mth
here is my select for a single row w/where clause removed:
SELECT SOS,NR,PRGM_CD,trunc(sysdate-(30*LEVEL) , 'mm') MTH,
ADD_MONTHS(trunc(sysdate,'q'),-3*LEVEL) QTR,
SUBSTR(qty,
INSTR(qty,':',1,LEVEL) +1,
INSTR(qty,':',1,LEVEL+1) - INSTR(qty,':',1,LEVEL)-1) QTTY
FROM (SELECT SRC_SUPL_CD SOS,APPL_PRGM_DESIG_NR,TYP_PRGM_CD,':'||PAST_PRGM_QY||':' qty from
rssp_api_master )
CONNECT BY LEVEL < LENGTH(qty) - LENGTH(REPLACE(qty,':'))
ex. data
sos nr prgm_cd qty
aaa 3 xx 1:2:3:4:5:5
bbb 3 xx 9:10:11:12:13
need to look like this
aaa 3 xx 1
aaa 3 xx 2
bbb 3 xx 9
bbb 3 xx 10
bbb 3 xx 11See this thread
Re: rows into column
Nicolas. -
How to get item names as column headings???
Hi,
I've given all the items in my complex folder nice user-friendly names, which can be seen in Desktop and Plus, but when I pull them into a worksheet the column headings revert to the underlying column name. Also, in Plus the list of selected items shows this underlying column name while the list of items in the folder shows the user-friendly names! This is really confusing for users.
Is there a way to get Disco to use the item names? Or do I have to go back to the underlying tables and views and recreate them with my user-friendly names?
ThanksIn Administrator when I look at the item properties, it shows my user-friendly item Name as the item Heading as well, but when I go into Desktop and pull the items into a worksheet, the worksheet column headings SOMETIMES default to the item Identifiers (or the underlying table/view column name in the item Formula), NOT the item Headings.
Here's an example - I have 3 numerical items:
1. Name and Heading are both "IP EL Spells", Identifier is "MONTHLY_ACT_EL", Formula is ""V pbc running totals 0406".Monthly act el"
2. Name and Heading are both "IP EL Spells YTD", Identifier is "RUNNING_ACT_EL", Formula is ""V pbc running totals 0406".Running act el
3. Name and Heading are both "IP EL Spells Prev YTD", Identifier is "PREV_ACT_EL", Formula is ""V pbc running totals 0406".Prev act el"
When I pull these into a crosstab in Desktop to sum them, the column headers are:
1. IP EL Spells SUM
2. Running act el SUM 1
3. Prev Act El SUM
The first heading is correct, the second seems to be based on the Formula or Identifier but I don't know where the "1" comes from or why "act el" are in lower case, and the third also seems to be based on the Formula or Identifier, but in mixed case.
I'm baffled! -
I am using the PL/SQL function body returning colon-delimited string with the headings under Report Attributes.
Works fine, except...
When I want to style my headings with CSS styles using SPAN style=color:red and stuff like that, the colon (:) in the CSS directives trips up HTML DB's parsing for obvious reasons.
Is there a way to differentiate between the real colons that delimit the headings vs. the colons embedded in a heading? By somehow escaping them?
If not, can you please log this as an enhancement request?
ThanksWhy you do not use "span class=RedColumnHeading..."? Styles are defined on page header...
But for "javascript: ..."... I know olny one method - javascript "onload" like:
sl.innerHTML = "<a href=\"javascript: AddToSort('"
+ coll[ i ].id + "');\">" + sl.innerHTML + "</a>"; -
Fixed and dynamic field headings in field catalog
i have to develop an ALV Report where certain column headings are fixed and other column heading will be changing from time to time.
is there any method to do so.
that is i have to show the report for 3 months and the names of months will be changing in due course.
Waiting for a reply.
A.Reshmahi,
you have 4 texts
SELTEXT_L
SELTEXT_M
SELTEXT_S
and DDIC_TEXT (not sure about spelling)
change this text dynamicly with month of your choice.
Rgds -
PL/SQL function returning a colon delimited list of headings
Hello,
Apex version 4.1.0.23. I am editing an existing classic report which has the column heading option set to 'PL/SQL function returning a colon delimited list of headings'. I have been looking for some time but I cannot find where this PL/SQL function is defined. Can any one point me to the right direction? I do not see anything in the documentation either.
Thanks,
UsmanHi Usman,
I looked into this issue and found that there's some JavaScript code executed when opening the page with the PL/SQL headings option enabled, or when selecting that option after loading the page, and this JavaScript attempts to set a background color for the column heading fields. Since we only display attributes for up to 100 columns, this JavaScript fails once you have more than 100 columns.
I would certainly agree with Tony that 60 or 100 columns are a bit much. But there should be some indication why something is not working, even if it's only a message stating that there's only a certain number of columns supported. So I'll log a bug to improve this in APEX 5.0.
Thanks,
Marc -
Colon-delimited headings from function - with links?
hi folks
I'm generating a report from a collection where headings are not known until runtime, so they are generated by a function returning a colon-delimted string of column headings.
Is there a way to specific a different delimiter in this context, so that I can also add conditional hyperlinks to the headings? Or an alternative means of linking to a page passing the computed column heading in as a parameter to the target page?
Many thanks for any solutions.
Regards
ChrisWhat is stopping to use colon as a delimiter for adding hyperlinks?
Is it not possible to avoid using colons within your (html) column headers?
Another option would be using items as headings using &PX_COL1_HEADING. syntax for each column and populate the values into these items at before header point. -
Dynamic crystal report generation - issues with column headings
Hi All,<br>
I'm trying to generate a crystal report dynamically based on a "result set" data(Query: select REPORT_ID, REPORT_NAME, REPORT_DESC, RPT_FILE_NAME, LOCATION from IRS_REPORT_DETAILS). I'm able to generate the report run time, But the report is without columns heads. I would like to include the column headings as well. <br><br>
I searched the API(RAS) and found that there is a 'add(java.lang.String fieldName, java.lang.String headingText) " method present in "ReportObjectController" using which we can add the headings.<br><br>
ReportDefController reportDefController = clientDoc.getReportDefController();
ReportObjectController reportObjectController = reportDefController.getReportObjectController();
reportObjectController.add( "{Table.Field}", "FieldName" );
<br><br>
I'm facing problems in using this code. When trying to use this function for my fields(Ex: reportObjectController.add( "{ IRS_REPORT_DETAILS.REPORT_ID}", "Report ID" );) it is giving me the following error:<br><br>"com.crystaldecisions.sdk.occa.report.lib.ReportSDKGroupException: The field was not found.---- Error code:-2147213310 Error code name:fieldNotFound"<br><br>
<b>The following is my dynamic crystal report generation code:</b><br><br>
public ReportClientDocument execute(String repName, String query) {
ReportClientDocument boReportClientDocument = null;
try {
boReportClientDocument = new ReportClientDocument();
boReportClientDocument.newDocument();
// Add a table based on the given Resultset to the report.
dbConnResultSet mySampleResultSet = new dbConnResultSet();
//mySampleResultSet.execute(query);
boReportClientDocument.getDatabaseController().addDataSource(
mySampleResultSet.execute(query));
IReportSource test = boReportClientDocument.getReportSource();
// Access all the database fields
DatabaseController databaseController = boReportClientDocument
.getDatabaseController();
IDatabase database = databaseController.getDatabase();
Tables tables = database.getTables();
ITable table = (Table) tables.getTable(0);
int NO_OF_FIELDS = table.getDataFields().size();
int LEFT_POSITION = 200;
// Add all the database fields to the report document
for (int i = 0; i < NO_OF_FIELDS; i++) {
IField field = table.getDataFields().getField(i);
FieldObject fieldObject = new FieldObject();
fieldObject.setFieldValueType(field.getType());
fieldObject.setDataSource(field.getFormulaForm());
IReportObject rep = (IReportObject) fieldObject;
IObjectFormat objformat = rep.getFormat();
objformat.setEnableCanGrow(true);
objformat.setHorizontalAlignment(Alignment.from_int(1));
rep.setFormat(objformat);
rep.setLeft(LEFT_POSITION);
rep.setWidth(1000);
LEFT_POSITION = LEFT_POSITION + 1000 + 50;
ISection section = boReportClientDocument
.getReportDefController().getReportDefinition()
.getDetailArea().getSections().getSection(0);
//***************** Data being added to the report here, But headings are not added*****************
boReportClientDocument.getReportDefController()
.getReportObjectController().add(rep, section, i);
boReportClientDocument.createReport();
/*Some report saving code is present down*/
} catch (ReportSDKException ex) {
ex.printStackTrace();
} catch (Exception ex) {
ex.printStackTrace();
return boReportClientDocument;
<br><br>
appreciate your help.IField field = table.getDataFields().getField(i);
Here you are getting the first field in the array. This may not be the field you want to add since we aren't sure how the arrays are ordered when retrieving fields from the report. It is better to retrieve the fields with the findObjectByName method, thus ensuring you are retrieving the field you want to add to your heading. -
Column order in SQL Query (PL/SQL function returning a query)
Hi,
when I define a PL/SQL function returning a query inside a region, I often find that the column order is arbitrarily changed.
How do I enforce the column order ?
Bye,
FlavioI removed the 11th column called service_name from this dynamic query: and now the report says: report error:
ORA-01403: no data found. I messed around with the Headiuns Type. It was set to Custom. I changed it to Column Names. There is no difference.
I am not sure how to fix?
declare topqry varchar2(32000);
whereqry varchar2(32000);
finalqry varchar2(32000);
var_status varchar2(100);
division_status varchar2(50);
office_status varchar2(1000);
user_status varchar2(1000);
overdue_status varchar2(1000);
begin
if :P10_FALLBACK = 'All' then
var_status:= ' and vp.status in (''FA'',''FBA'',''FBI'',''25%'',''50%'',''90%'',''Closed'') ';
elsif :P10_FALLBACK = 'Active' then
var_status:= ' and vp.status in (''FA'',''25%'',''50%'',''90%'',''FBA'') ';
elsif :P10_FALLBACK = 'FB' then
var_status:= ' and vp.status in (''FBA'',''FBI'') ';
elsif :P10_FALLBACK = 'Closed' then
var_status:= ' and vp.status in (''Closed'') ';
elsif :P10_FALLBACK = 'Inactive' then
var_status:= ' and vp.status in (''FBI'') ';
end if;
if :P10_DIVISION = 'All' then
division_status:= ' and vp.vms_division in (''News'',''Ad Services'') ';
elsif :P10_DIVISION = 'News' then
division_status:= ' and vp.vms_division in (''News'') ';
elsif :P10_DIVISION = 'Ad' then
division_status:= ' and vp.vms_division in (''Ad Services'') ';
end if;
if :P10_OFFICE = '%' then
office_status:= ' and OFFICE_ID in (select office
from VMS_OFFICE_ACCESS
where user_id = lower(:P0_user) ) ';
else
office_status:= ' and OFFICE_ID in :P10_OFFICE ';
end if;
if :P10_LIMIT_USER = '%' then
user_status := ' and SALESPERSON in (select first_name || '' '' || last_name
from VMS_PROSPECT_users u
join vms_office_access o
on u.office_id = OFFICE
where o.user_id = lower(:P0_USER) ) ';
else
user_status:= ' and SALESPERSON in (:P10_LIMIT_USER ) ';
end if;
if :P10_SHOW_OVERDUE = 'Show' then
overdue_status:= ' and target_close_date <= sysdate ';
var_status:= ' and vp.status in (''25%'',''50%'',''90%'',''FBA'') ';
else
overdue_status:= ' and FIRST_APPOINTMENT between
nvl(to_date(:P10_FIRST_APPT_START, ''mm/dd/yyyy''),FIRST_APPOINTMENT) and
nvl(to_date(:P10_FIRST_APPT_END,''mm/dd/yyyy''),FIRST_APPOINTMENT) ';
end if;
topqry := 'SELECT OFFICE_ID ,vp.PROSPECT_ID ,ENTRY_DATE ,ACCOUNT , NEXT_CONTACT_DATE ,ACTION_STEP ,
TARGET_CLOSE_DATE ,vp.STATUS ,SALESPERSON ,vp.SALES_TYPE ,service_name , FIRST_APPOINTMENT ,MODIFY_DATE ,EST_ANNUAL_REVENUE ,EST_INCREMENTAL_REVENUE ,
pi.NOTES , pi.SALES_TYPE ,pi.STATUS ,Contact ,Origin_Source FROM VMS_PROSPECTING_ITEMS pi right outer join VMS_PROSPECTS vp on vp.PROSPECT_ID = pi.PROSPECT_ID left outer join VMS_SERVICES vs on vs.service_ID = pi.service_ID where 1 = 1 ';
whereqry := ' and (not exists (select *
from VMS_PROSPECTING_ITEMS i3
where vp.prospect_id = i3.prospect_id)
or exists (select *
from VMS_PROSPECTING_ITEMS i2
where i2.order_id = pi.order_id
and active = ''Y'' )) and instr(upper(ACCOUNT),upper(nvl(:P10_ACCOUNT,ACCOUNT))) > 0 ';
whereqry := whereqry || var_status || division_status || office_status || user_status || overdue_status;
finalqry := topqry || whereqry;
return finalqry ;
end; -
Db function returning three db number columns...
Hi ,
Is it possible a db function to return three number columns fetched from a table...??
If for example , there is a db function such as...:
function x
return number
is
begin
select number_col_1 , number_col_2 , number_col_3
into var1 , var2 , var3
from table_a
where <a_condition>;
return <the_three_columns_selected>;
end;
so as in a select statement should write:
select a , b , x from a_table
many thanks ,
SimonAlternatively you can return a SQL collection:
SQL> create or replace function x (empno integer)
2 return sys.dbms_debug_vc2coll
3 is
4 var1 emp.job%type;
5 var2 emp.sal%type;
6 var3 emp.deptno%type;
7 begin
8 select job, sal, deptno
9 into var1, var2, var3
10 from emp
11 where empno = x.empno;
12
13 return sys.dbms_debug_vc2coll (var1, var2, var3);
14 end;
15 /
Function created.
SQL>
SQL> select empno, ename, x(empno) x from emp
2 where empno in (7788,7900)
3 /
EMPNO ENAME X
7788 SCOTT DBMS_DEBUG_VC2COLL('ANALYST', '3000', '20')
7900 JAMES DBMS_DEBUG_VC2COLL('CLERK', '950', '30') -
Column Headings on PL/SQL returning SQL Query report- using br
Hi,
I would like to create a report region based upon a function returning a SQL query. As a dem oI have created the following:
create or replace function xxjk_retsql return varchar2
as
begin
return 'select i "column header" from wwv_flow_dual100';
end;I want to be able to insert a line break in the column header so it wraps over two lines. I tried this:
create or replace function xxjk_retsql return varchar2
as
begin
return 'select i "column<br>header" from wwv_flow_dual100';
end;however when the region is rendered, it appears to strip out the HTML tag. I also tried another tag, <i></i>, as a test and this is stripped out also.
Is there a way to include a break in a column header in this manner?
Thank-you,There is an option Strip HTML and it is turned on by default. Try changing that to see what happes.
Denes Kubicek
http://deneskubicek.blogspot.com/
http://www.opal-consulting.de/training
http://apex.oracle.com/pls/otn/f?p=31517:1
------------------------------------------------------------------------------
Maybe you are looking for
-
Please help me Automate an Aperture/Photoshop workflow
I'm trying to streamline the process of exporting a RAW file from Aperture to Photoshop for editing and then re-importing it into Aperture. I have zero experience with Automator, but someone else on the Discussions site was kind enough to share hte A
-
CS2 Error Could not complete your Request because there is not enough memory (RAM)"
Using, WinXP SP3, P4, 80G HD, 2G RAM I had a student try to place, open and copy a .jpg file into Illustrator and none of the ways worked. 1) Opened Illustrator selected FILE, PLACE and then directed to get photo. It shows an empty box. 2) Starting f
-
TThe question is in the title
-
10.8.1 won't shut down, grey screen
Fresh clean install on 2009 Nehalem Mac Pro with upgraded Kingston SSD drive. Everything was working flawlessly for 3 weeks. 1) Shut Down Dialogue 2) Desktop disappears 3) Computer hangs in a light grey screen, remain powered on. Mouse movements a
-
Recently my lab switched to using a 2GHz sampler (PXI-5152) from a 100MHz sampler (PXI-5122). The changes to the labview programming were trivial to make the 5152 work so I am intreagued by an anomoly in the data. We have a radioactive source rainin