Dynamic query report problem
I have followed the tutorial in on dynamic query and created a region where the type is SQL Query (PL/SQL function body returning SQL Query)
The source is
declare
q varchar2(4000);
teatid NUMBER := :P305_TARGET_ID;
begin
wwv_flow.debug('teatid = ' || teatid);
q:=' select f.id, ';
q:=q||' f.eat_id ';
q:=q||' from xmlTransactions f ';
q:=q||' where f.eat_id = ' || teatid; -- I've also tried putting :P305_TARGET_ID here
wwv_flow.debug('sql = ' || q);
return q;
end;
I have chosen "Use Generic Column Names...".
When I run the page, I get NO ROWS FOUND. However, when I cut and paste the SQL statement printed out by the debug statement and run it, it returns rows. Both debug statements print correct values.
I'm not sure what the problem is here, but basically, I want to do a query where I substitute a value passed into the page from another page.
In this case the value in P305_TARGET_ID is passed in via a button spawning a popup as in var url = 'f?p=&APP_ID.:305:&APP_SESSION.::::P305_TARGET_ID:' + targetID;
APEX version is 3.0.1.00.08
Thank you.
- JohnW
Hi, JohnW
I don't understand why you use a dynamic query for that.
A "direct" SQL query like this :
select f.id,f.eat_id from xmlTransactions f where f.eat_id=:P305_TARGET_ID;
should work.
Mike
Similar Messages
-
Multiple Parameter Dynamic Query/Report
I'm very much a newbie to both APEX and SQL. I want to create a page with two regions, one used to hold parameters (LOV Select Lists), and one to reflect a dynamic SQL report including filtering the results using the values of the items in the select lists.
I can do this with one Parameter/LOV select list - but am not clear on how to code for multiple parameters.
Can someone give me an example on how to code the query, to include multiple parameters (P1_Empl, P1_AssetNo, P1_AssetType, etc)? The query with 'null' parameters/filters gives you all records; with any or many parameters acting as filters the query and resulting report would reflect the value of the filters.
In addition, is there a specific type of region that needs to be used for the report region?
Implied is the question - how do you handle the initial page view, so no error messages are seen - I'd like to get all records as a default.
Thanks
Richsbkenned,
The referenced sql for that report gives me problems.
[ P3_Department_ID is the LOV of departments ]
[ Null allowed and null return value is -1 ]
<code>
SELECT e.EMPLOYEE_ID,
e.FIRST_NAME,
e.LAST_NAME,
e.HIRE_DATE,
e.SALARY,
e.COMMISSION_PCT,
calc_remuneration(salary, commission_pct) REMUNERATION,
e.DEPARTMENT_ID,
d.DEPARTMENT_NAME
FROM OEHR_EMPLOYEES e,
OEHR_DEPARTMENTS d
WHERE e.DEPARTMENT_ID = d.DEPARTMENT_ID(+) AND
(e.DEPARTMENT_ID = :P3_DEPARTMENT_ID or
(e.DEPARTMENT_ID is null and nvl(:P3_DEPARTMENT_ID,'-1') = '-1'))
</code>
The where clause: I'm guessing it is checking e.deptno = d.deptno
but then what is (+)?
can I use the '(+) and' to add on sections for each select list/parameter?
In the paran part of the where clause, I get the first part and the use of 'or' - but I'm not sure what the last statement is doing.
e.deptno is null AND ?? if there is a null value in P3_Department_ID return -1 otherwise return -1 ??
I'm lost at that point as I clearly don't understand the syntax.
Would you suggest multiple clauses in a where statement in order to add multiple filter values, and how do I handle nulls so those filters are not used/relfected?
I am not using a self submitting LOV select list - I am using a button to refresh the query region manually
I am comfortable with using an interactive report, but that interface is not what I need to present.
As I indicated - I'm weak in the SQL area and need an example on how to code this type of query.
Thanks.
Rich -
The problem about integrate Portal and R/3 : vendor query report problem
Hi everyone :
We want to achieve that our vendor can query R/3 report via our Portal. I had done SSO configuration.
But we had about 500 vendors, it is impossible that we create 500 R/3 users for our vendors, because the cost is too much .
And there is another problem, vendor who had the authorization to query report can query the other vendor's data at same time. But we expect that certain vendor can query his data only.
I think this is a general problem when integrate Portal and R/3, BW .
Is there somebody had solved this problem or give any advice?
Any discuss is welcome.
Best Regards,
Jianguo ChenHi,
I would say: get in contact with your SAP account manager anc check which options SAP can offer you...
Normally every user using a R/3 system has to have a valid user license in that system. Expecially when you want to access control to data on user (vendor) level you nedd to identifiy the user clearly and uniquely which by standard means you need a user for every vendor.
Hth,
Michael -
I copied all query reports from one old database to another new database using a copy express.
But while executing the query report in the current new database.
It is showing an error" FORM NOT FOUND [66000-9]"Sometimes the errors provide little information as feedback to correct the problem. I would suggest that you review the query iin both databases and see if have been copied correctly. Secondly make sure all field and table references in the query actually exists in the copied database.
Suda -
Problem on Dynamic Query Report
Hello,
I need to perform a report depend on the user who is accesing to my application,
I am using the following query:
declare
q varchar2(4000);
v_usuario varchar2(10);
begin
SET v_usuario = (CASE
WHEN :P101_USERNAME='janet' THEN v_usuario = 'JA'
WHEN :P101_USERNAME='cesar' THEN v_usuario = 'CC'
WHEN :P101_USERNAME='luisjavier' THEN v_usuario = 'LT'
WHEN :P101_USERNAME='mauricio' THEN v_usuario = 'MO'
WHEN :P101_USERNAME='enrique' THEN v_usuario = 'EH'
ELSE ' ')
q:=' select p.cliente, ';
q:=q||' p.partner, ';
q:=q||' p.channel_mgr, ';
q:=q||' p.fm_sales_rep, ';
q:=q||' p.status, ';
q:=q||' p.sc_leader, ';
q:=q||' p.sector, ';
q:=q||' p.fecha_inicio, ';
q:=q||' from adminorv.proyectosongoing p ';
q:=q||' where p.sc_leader = v_usuario';
return q;
end;
However, I got this error:1 error has occurred
Query cannot be parsed within the Builder. If you believe your query is syntactically correct, check the ''generic columns'' checkbox below the region source to proceed without parsing. ORA-06550: line 1, column 9: PLS-00103: Encountered the symbol "" when expecting one of the following: begin function package pragma procedure subtype type use form current cursor
Somebody can give a hint?You have a bunch of syntax errors there.
The code should look more like this:
declare
q varchar2(4000);
v_usuario varchar2(10);
begin
v_usuario := (CASE
WHEN :P101_USERNAME='janet' THEN 'JA'
WHEN :P101_USERNAME='cesar' THEN 'CC'
WHEN :P101_USERNAME='luisjavier' THEN 'LT'
WHEN :P101_USERNAME='mauricio' THEN 'MO'
WHEN :P101_USERNAME='enrique' THEN 'EH'
ELSE ' ' END);
q:=' select p.cliente, ';
q:=q||' p.partner, ';
q:=q||' p.channel_mgr, ';
q:=q||' p.fm_sales_rep, ';
q:=q||' p.status, ';
q:=q||' p.sc_leader, ';
q:=q||' p.sector, ';
q:=q||' p.fecha_inicio ';
q:=q||' from adminorv.proyectosongoing p ';
q:=q||' where p.sc_leader = v_usuario';
return q;
end;But I don't see why you are using dynamic SQL and a function returning a query here.
That could be done with just a simple query like this:
select p.cliente, p.partner, p.channel_mgr, p.fm_sales_rep, p.status, p.sc_leader,
p.sector, p.fecha_inicio
from adminorv.proyectosongoing p
where p.sc_leader = CASE WHEN :P101_USERNAME = 'janet' THEN 'JA'
WHEN :P101_USERNAME = 'cesar' THEN 'CC'
WHEN :P101_USERNAME = 'luisjavier' THEN 'LT'
WHEN :P101_USERNAME = 'mauricio' THEN 'MO'
WHEN :P101_USERNAME = 'enrique' THEN 'EH'
ELSE ' '
END -
This question is based on Oracle How To: http://www.oracle.com/technology/products/database/htmldb/howtos/dynamic_report-1.6.htm
I tried creating my own dynamic report as follows below, but it failed in HTMLDB with the error: [Failed to parse SQL query: ORA-00933: SQL command not properly ended]
I have examined my code quite thoroughly but still cannot understand what the problem is .. i.e. the code seems syntatically correct. Can anyone help please?
DECLARE
q VARCHAR2(4000);
BEGIN
q:=' SELECT a.customer, ';
q:=q||' a.country, ';
q:=q||' b.group_ga, ';
q:=q||' SUM(nvl(a.total_sla_pass,0))TT_SLA_Pass, ';
q:=q||' SUM(nvl(a.total_sla_fail,0)) TT_SLA_Fail,';
q:=q||' SUM(nvl(a.total_sla_unassess,0))TT_SLA_Unassessed,';
q:=q||' SUM(nvl(a.total_sla_pass,null)) TT_Total';
q:=q||' FROM ms_portal_load_mv a, ms_portal_load_mv b';
q:=q||' WHERE a.sh_fix_time >= :p400_Start_Date';
q:=q||' AND a.sh_fix_time < :p400_End_Date';
q:=q||' AND a.index_x = 3';
q:=q||' AND b.index_x = 3';
q:=q||' AND a.non_sla = 0';
q:=q||' AND a.group_assignment_id IS NULL';
q:=q||' AND a.ticket_id = b.parent_ticket_id';
IF :p400_select_customer != 'All' THEN
q:= q||'AND a.customer = :p400_select_customer';
END IF;
q:=q||' GROUP BY a.customer, a.country, b.group_ga;'
RETURN q;
END;Thanks for your replies.
I have tried all suggestions but the code still generates error in HTMLDB:
# 1 error has occurred
Query cannot be parsed within the Builder. If you believe your query is syntactically correct, check the ''generic columns'' checkbox below the region source to proceed without parsing. ORA-00933: SQL command not properly ended
Any other ideas?
Thanks in advance
Kezie -
Inventory inward pending query report problem
Dear Sir,
we are using sap b1 2005 version 7.40.253
i am opening query manager icon and choose theinventory inward pending report then click ok button the error will be display
1) [Microsoft][sql native client][sql server]conversion failed when converting the nvarchar value '31/05/2014' to data type int. 'Queries'(OUQR)
and i use the query like this:
select distinct t0.docnum as 'Inventory Transfer Number', t0.filler as 'From Warehouse', t0.u_towhcode as 'To Warehouse',T0.DocDate from owtr t0 inner join wtr1 t1 on t0.docentry = t1.docentry inner join owhs t2 on t1.whscode = t2.whscode where t2.u_whty = 'IT' and t0.docnum not in(select distinct z0.u_bd from owtr z0 inner join owhs z1 on z0.filler = z1.whscode where z1.u_whty = 'IT' and isnull(z0.u_bd,0) != 0)Thanks for ur valuble support.....
Thats query also working fine sir.....
but the user told the drawback is lot of times repeated the doc number for every item.so pls combine single document no and display total quantity need not display item description ......
i want display these colums only:
1.inventory transfer no
2.from where house
3.To where house
4.Posting date
so can you please tell another query sir ......................... -
Matrix multiple query report problem
dear members i have serious problem regarding report as i m usin oracle 10g with developer 6i release2 and i m getting following error while executing teh report out:
rep-1761: internal error <rgcaag-2> while processing group <g_item_code>
plz any one hv idea regarding this error so share with me .
thnx in advance
Edited by: user581618 on Jul 14, 2012 1:48 AMInternal errors usually indicate a bug somewhere.
What are your exact Reports version, database version and operating system? Developer 6i release2 and 10g are not the exact version numbers. -
SQL dynamic query returning (problem with list of value)
Hi, I'm having trouble with my query. I want to make where statement based on my selectlist, but the problem is that I couldnt write the correct string in my where condition.
:P61_STATUS has this following display, return value
Bewerber Bewerber
PRA_Kandidat PRA_Kandidat
abgelehnt abgelehnt
angenommen angenommen
Thema Thema
angemeldet angemeldet
abgegeben abgegeben
abgeschlossen abgeschlossen
bestätigt bestätigt
DECLARE
q varchar2(4000);
list_betreuer htmldb_application_global.vc_arr2;
list_semester htmldb_application_global.vc_arr2;
list_status htmldb_application_global.vc_arr2;
BEGIN
-- variable to store the list
list_betreuer := HTMLDB_UTIL.STRING_TO_TABLE(:P61_BETREUER);
list_semester := HTMLDB_UTIL.STRING_TO_TABLE(:P61_SEMESTER);
list_status := HTMLDB_UTIL.STRING_TO_TABLE(:P61_STATUS);
-- Query begins
q:= 'select p1.name, p1.vorname , a1.tel, a2.tel, ';
q:= q||'ab.thema, ab.status, ab.typ, s.bezeichnung, p2.name ';
q:= q||'from person p1, person p2, adresse a1, adresse a2, ';
q:= q||'zuordnungp_a zpa1,zuordnungp_a zpa2, ';
q:= q||'abschlussarbeit ab, semester s ';
q:= q||'WHERE ab.SEMESTER = s.OBJECTID (+) ';
q:= q||'AND ab.STUDENT = p1.OBJECTID (+) ';
q:= q||'AND ab.BETREUER = p2.OBJECTID (+) ';
q:= q||'and p1.objectid = zpa1.person (+) ';
q:= q||'and zpa1.adresse = a1.objectid (+) ';
q:= q||'and zpa1.art (+)= ''Privat'' ';
q:= q||'and p1.objectid = zpa2.person (+) ';
q:= q||'and zpa2.adresse = a2.objectid (+) ';
q:= q||'and zpa2.art (+)= ''Geschäft'' ';
-- Loop for betreuer list
FOR i in 1..list_betreuer.count
LOOP
IF i = 1 THEN
q:= q||'AND (ab.betreuer = '||list_betreuer(i);
ELSE
q:= q||' OR ab.betreuer = '||list_betreuer(i);
END IF;
END LOOP; if (list_betreuer.count>0)THEN q:= q||')'; END IF;
-- Loop for semester list
FOR i in 1..list_semester.count
LOOP
IF i = 1 THEN
q:= q||'AND (ab.semester = '||list_semester(i);
ELSE
q:= q||'OR ab.semester = '||list_semester(i);
END IF;
END LOOP; if (list_semester.count>0)THEN q:= q||')'; END IF;
-- Loop for status list
FOR i in 1..list_status.count
LOOP
IF i = 1 THEN
q:= q||'AND (ab.status = '||list_status(i)||'';
ELSE
q:= q||'OR ab.status = '||list_status(i)||'';
END IF;
END LOOP; if (list_status.count>0)THEN q:= q||')'; END IF;
htp.p(q);
return q;
END;result
select p1.name, p1.vorname , a1.tel, a2.tel, ab.thema, ab.status, ab.typ, s.bezeichnung, p2.name from person p1, person p2, adresse a1, adresse a2, zuordnungp_a zpa1,zuordnungp_a zpa2, abschlussarbeit ab, semester s WHERE ab.SEMESTER = s.OBJECTID (+) AND ab.STUDENT = p1.OBJECTID (+) AND ab.BETREUER = p2.OBJECTID (+) and p1.objectid = zpa1.person (+) and zpa1.adresse = a1.objectid (+) and zpa1.art (+)= 'Privat' and p1.objectid = zpa2.person (+) and zpa2.adresse = a2.objectid (+) and zpa2.art (+)= 'Geschäft' AND (ab.status = abgegeben) the problem is in this statement
q:= q||'AND (ab.status = '||list_status(i)||'';that statement produce this following statement
ab.status = abgegebenbut what I need is this statement
ab.status = 'abgegeben';how can I achieve this statement?
thank you very muchraitodn wrote:
ah ok , I was confused with this q:= q||'AND (ab.status = '''||list_status(i)||'''';I think I get it now
basically stop the string and write double quotes before the variable
'AND (ab.status = ' + ''||list_status(i)||'' + ''No, more like "wherever I want a single quote within a string, I put two single quotes instead and that tells oracle it's a quote and not the end of the string".
q:= q||'AND (ab.status = '''||list_status(i)||'''';
^ ^^^ ^^^^
| |/| ||/|
| | | || \-- single quote indicates end of string
| | | ||
| | | |\-- two quotes indicate a single quote required
| | | |
| | | \-- single quote to open a new string
| | |
| | \-- single quote indicates end of string
| |
| \-- two quotes indicate single quote required
\-- Open String -
Conditional URL ( CASE ) within a Dynamic Query
I need extra eyes or help in RE-FORMATTING the following SELECT STMT. My approach was to formulate the following query to get a functioning URL to the page that displayed the corrections made on that record (if it was corrected)...which I did. So now I'm trying to move the CASE portion into a dynamic query report. I'm having difficulties rewriting the CASE into the dynamic query due to placement of single-quotes. Is there an easy way to do this...or do I still need to find the correct placement of quotes? HELP!
select "ID",
"EMP_ID",
"ENTRY_DATE",
"JOB_TITLE",
"START_DATE",
"END_DATE",
"MODIFIED_DATE",
"lkup_1"."DESCRIPTION" as "Status",
CASE
WHEN rec_status = 'CR' -- corrected record
THEN '<a href="'
|| 'f?p=&APP_ID.:90:&SESSION.::&DEBUG.::'
|| 'P90_RID,P90_TIMESTAMP:'
|| rid ||',' || TO_CHAR(modified_date,'MM/DD/YYYY')
|| ">'
|| 'See Update(s)'
|| '</a>'
|| '</a>'
ELSE NULL
END LINK,
"lkup_2"."DESCRIPTION" as "Action",
"CATEGORY",
apex_item.checkbox(1,rid) as "Confirm"
from "JOB_SUMMARIES",
"LOOKUPS" "lkup_1",
"LOOKUPS" "lkup_2"
where "REC_STATUS" <> 'CF'
and "REC_STATUS" = "lkup_1"."CODE"
and "ACTION" = "lkup_2"."CODE"(+)
Here is what I sort of come up with, but I'm getting dizzy looking at it so many times!
' CASE '||
' WHEN rec_status = ' || '''' || '''CR''' || '''' ||
' THEN ' || '''' || '<a href="' || '''' ||
' ||' || '''' || 'f?p=&APP_ID.:90:&SESSION.::&DEBUG.::' || '''' ||
' ||' || '''' || 'P90_RID,P90_TIMESTAMP:' || '''' ||
' ||' || ' id ||' || '''' || ''',''' || '''' || '|| TO_CHAR(modified_date,' || '''' || 'MM/DD/YYYY' || '''' || ')' || '''' ||
' ||' || '''' || ">' || '''' ||
' ||' || '''' || 'See Update(s)' || '''' ||
' ||' || '''' || '</a>' || '''' ||
' ||' || '''' || '</a>' || '''' ||
' ELSE NULL '||
' END LINK, '||
I'm still getting an error which is:
1 error has occurred
* Query cannot be parsed within the Builder. If you believe your query is syntactically correct,
check the ''generic columns'' checkbox below the region source to proceed without parsing.
ORA-00905: missing keywordI still cannot get the insertion of the CASE to compile...I keep getting MISSING EXPRESSION error.
1 error has occurred
* Query cannot be parsed within the Builder. If you believe your query is syntactically correct,
check the ''generic columns'' checkbox below the region source to proceed without parsing.
ORA-00936: missing expression
Here is my dynamic query and I want to place the CASE as indicated. The numerous quotes or the Q syntax is really messing up my attempts to get this page working. I have a dynamic query because I am allowing search parameters. And I thought it would be nice to have a LINK to another page that displayed changed column values if a user CORRECTED one of their records. All changes must be verified and accepted by a REVIEWER.
declare
q varchar2(32767); -- query
w varchar2(4000) ; -- where clause
we varchar2(1) := 'N'; -- identifies if where clause exists
begin
q := 'select "ID", '||
' "EMP_ID", '||
' "ENTRY_DATE", '||
' "JOB_TITLE", '||
' "START_DATE", '||
' "END_DATE", '||
' "lkup_1"."DESCRIPTION" as "Status", '||
>WANT TO PLACE CASE RIGHT HERE
' "lk_up2"."DESCRIPTION" as "Action", '||
' "CATEGORY", '||
' apex_item.checkbox(1,rid) as "Confirm" '||
' from "#OWNER#"."JOB_SUMMARIES", '||
' "#OWNER#"."LOOKUPS" "lkup_1", '||
' "#OWNER#"."LOOKUPS" "lkup_2" '||
' where "REC_STATUS" <> ' || '''' || 'CF' || '''' ||
' and "REC_STATUS" = "lkup_1"."CODE" '||
' and "ACTION" = "lkup_2"."CODE"(+) ';
if :P16_EMP_ID != '-1'
then
w := ' AND EMP_ID = :P16_EMP_ID ';
we := 'Y';
end if;
if :P16_RECORD_STATUS != '-1'
then
w := w || ' AND REC_STATUS = :P16_RECORD_STATUS ';
we := 'Y';
end if;
if :P16_CATEGORY != '-1'
then
w := w || ' AND CATEGORY = :P16_CATEGORY ';
we := 'Y';
end if;
if we = 'Y'
then q := q || w;
end if;
return q;
end;
Edited by: JSandoval on Aug 10, 2009 3:42 PM -
Dynamic Query in Report Builder
HI
I have a doubt:
I need to receive a parameter in my report and I need this parameter in the query, that means, I need to create a dynamic query depending on the value that I receive in one of the parameters that has my report.
I tried to use the resource of Searching by Reference Cursor tool, it is a blue circle in the Data Model View of Report Builder.
When I click this tool, I have an initial code, It is:
function QR_1RefCurDS return <RefCurType> is
begin
end;
In PL/SQL I tried to create to test and to play, this code:
Note: If you want to try only to test, it is simple and works:
create or replace package TEST_REFCURTYPE as
type refcurtype is ref cursor;
function TEST_REFCURTYPE (P_DATE_TO nvarchar2) return refcurtype;
end;
create or replace package body TEST_REFCURTYPE as
function TEST_REFCURTYPE (P_DATE_TO nvarchar2)
return refcurtype is
refcur refcurtype;
mysql varchar(1000);
begin
If P_DATE_TO is not null then
mysql := 'select '''|| P_DATE_TO ||''' from dual';
else
mysql := 'select sysdate from dual';
end if;
open refcur for mysql;
return refcur;
end;
end;
The problem is to pass this example of code to the function QR_1RefCurDS, I do not have a place to make reference to the type:
type refcurtype is ref cursor;
I tested the Unit Program in the Report Builder but it did not work, because all the code I try to write and create, for example in the Event BEFORE REPORT, it opens Funcion( ) …., and I can not make reference to the type refcurtype inside a Function( ).
Would you help me please?
Or there is another way to make a dynamic query in the Report Builder?
Sorry for my English, I am a Brazilian living in Spain.Hi,
you can use lexical parameters in your queries. Instead of a ":" use in the query before the parameter a "&". Then the parameter stands for a part of the query and not for a value (Bind parameter). In the before report trigger you can set this parameters. They can contain parts of SQL like order or where. Make sure that the default value for this lexical parameters are set to get a valid query.
SELECT ENAME, &p_column as COL2 FROM EMP &p_order
and in the trigger something like
IF :p_which_column = 1 THEN
:p_column := 'SAL'
ELSE
Saludos
Rainer -
Sort problem on dynamic query !!
Hi,
I have a dynamic query written in pl/sql, when I check "Sort" for each field in Report Attribute, error message raised up as "ORA-01785: ORDER BY item must be the number of a SELECT-list expression".
If I do not check Sort, it works fine. In my apps I need all fields sorted by user, how to fix this problem?
My query as below:
declare
query varchar2(2000):='select';
s_class varchar2(1000);
cursor c1 is select * from demo_preference;
begin
for c1_val in c1 loop
if c1_val.login is not null then
query := query ||' ' || 'login' || ',';
end if;
if c1_val.id is not null then
query := query ||' ' || 'id' || ',';
end if;
end loop;
query := SUBSTR(query, 1, length(query)-1);
s_class := '(NVL(:P2_class, ''%'' || ''null%'') = ''%'' || ''null%'' OR
EXISTS (SELECT 1 FROM apex_collections WHERE collection_name = ''P2CLASSCOL'' AND c001 = class))';
query := query ||' ' || 'from ming.reg_report_view1 where'
|| ' ' || s_class;
return(query);
end;Maybe the internally mapped column used when you clicked on sort is not shown in the report. Try using aliases when you construct the query string, it could help apex internally in identifying a column even if its order changes for a different user. After all the column order in the code is dynamic and I guess even the no of columns displayed might vary both of which could make sorting on a column identified with a number, invalid.
How about displaying the report query somewhere, so that you know what is the exact query being processed, it might give you better information about the problem.
If the problem persists, then use a collection that is fetched those record using the same query string and change the report to refer the collection and then set column sorting on. This way apex would get confused on what columns are being sorted and it would just sort on a c001..c050 column as though it was a string(yes problems with number columns sorting when you do this). -
Dynamic query in updatable report
I have generated a updatable report with the folowing select:
select
"INSTALLATIEID",
"INSTALLATIEID" INSTALLATIEID_DISPLAY,
"CO_DRUK" druk,
"CO_H2O" h2o,
"CO_O2" o2,
"CO_O2_11" o2_11,
"CO_TEMP" temp
from "#OWNER#"."CORRECTIE"
The table correctie has above the 50 columns (the same columns for different components) so I want to change the query in:
select
"INSTALLATIEID",
"INSTALLATIEID" INSTALLATIEID_DISPLAY,
"&P50_COMP._DRUK" druk,
"&P50_COMP._H2O" h2o,
"&P50_COMP._O2" o2,
"&P50_COMP._O2_11" o2_11,
"&P50_COMP._TEMP" temp
from "#OWNER#"."CORRECTIE"
The item P50_COMP will be filled with a default value and is a select list with submit.
The problem is when I change the query in the above way, the query cannot be parsed and I cannot applay the changes without parsing the query.
Also not when I use Generic Column Names (parse query at runtime only)
Can somebody help me with this problem.Fred,
You should switch to a PL/SQL Function Body Returning SQL Statement (Dynamic Query) in order to achieve this. Your Function would look like this:
declare
l_sql varchar2(32767);
begin
l_sql := 'select
"INSTALLATIEID",
"INSTALLATIEID" INSTALLATIEID_DISPLAY,
"' || :P50_COMP || '._DRUK" druk,
"' || :P50_COMP || '._H2O" h2o,
"' || :P50_COMP || '._O2" o2,
"' || :P50_COMP || '._O2_11" o2_11,
"' || :P50_COMP || '._TEMP" temp
from "#OWNER#"."CORRECTIE"';
return l_sql;
end;Thanks,
- Scott - -
Problem in Data Display in Dynamic ALV Report
Hi all,
I am developing a Dynamic ALV report where I want display material batch (zjpack_base-charg) in column and Material (zjpack_base-matnr) & Qty (Zjpack_base-netwr) field row wise.My intention is to show report datewise for a material how many batch developed with there qty.I am sending you the code which i already wrote.Here column is developed batchwise but I am not able to show the qty against each batch.Please see my code and guide me how to display.
REPORT zdynamic_test .
*REPORT ztest_notepad.
*& Declarations
*Type-pools
TYPE-POOLS: slis.
*TABLES
TABLES: zjpack_base.
*Types
TYPES:
ty_fcat TYPE lvc_s_fcat,
ty_fcatalog TYPE slis_fieldcat_alv.
*Work areas
DATA:
wa_fcat TYPE ty_fcat,
wa_fcatalog TYPE ty_fcatalog.
*Internal tables
DATA:
it_fcat TYPE STANDARD TABLE OF ty_fcat,
it_fcatalog TYPE STANDARD TABLE OF ty_fcatalog.
*Type reference
DATA:
it_dyn_tab TYPE REF TO data,
wa_newline TYPE REF TO data.
*INTERNAL TABLE
DATA: BEGIN OF it_itab OCCURS 0.
INCLUDE STRUCTURE zjpack_base.
DATA: END OF it_itab.
*Filed symbols
FIELD-SYMBOLS:
<gt_table> TYPE STANDARD TABLE,
<fs_dyntable>,
<fs_fldval> TYPE ANY,
<l_field> TYPE ANY.
*Variables
DATA:
l_fieldname TYPE lvc_s_fcat-fieldname,
l_tabname TYPE lvc_s_fcat-tabname,
l_fieldtext TYPE lvc_s_fcat-seltext,
l_index TYPE char2.
"Selection-screen
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-s11 .
SELECT-OPTIONS:s_matnr FOR zjpack_base-matnr.
SELECT-OPTIONS:s_charg FOR zjpack_base-charg.
SELECT-OPTIONS:s_fdate FOR zjpack_base-fdate .
SELECTION-SCREEN END OF BLOCK b1.
PARAMETERS:
p_colms TYPE i.
*& start-of-selection.
START-OF-SELECTION.
PERFORM select_data.
PERFORM build_fieldcat.
PERFORM create_dynamic_table.
DO 20 TIMES.
DO p_colms TIMES.
l_index = sy-index.
CONCATENATE 'FIELD' l_index INTO l_fieldname.
ASSIGN COMPONENT l_fieldname OF STRUCTURE <fs_dyntable> TO <l_field>.
<l_field> = sy-index.
ENDDO.
INSERT <fs_dyntable> INTO TABLE <gt_table>.
ENDDO.
LOOP AT it_itab.
l_index = sy-tabix.
CONCATENATE 'FIELD' l_index INTO l_fieldname.
ASSIGN COMPONENT l_fieldname OF STRUCTURE <fs_dyntable> TO <l_field>.
<l_field> = it_itab-matnr.
INSERT <fs_dyntable> INTO TABLE <gt_table>.
ENDLOOP.
LOOP AT it_fcat INTO wa_fcat.
PERFORM fieldcatalog1 USING: wa_fcat-fieldname
wa_fcat-tabname
wa_fcat-seltext.
ENDLOOP.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = 'ZTEST_NOTEPAD'
it_fieldcat = it_fcatalog
TABLES
t_outtab = <gt_table>.
*& Form BUILD_FIELDCAT
FORM build_fieldcat .
CLEAR: l_fieldname,
l_tabname,
l_fieldtext,
l_index.
DO p_colms TIMES.
CLEAR l_index.
l_index = sy-index.
CONCATENATE 'FIELD' l_index INTO l_fieldname.
CONCATENATE 'Field' l_index INTO l_fieldtext.
l_tabname = '<GT_TABLE>'.
PERFORM fieldcatalog USING: l_fieldname
l_tabname
l_fieldtext.
ENDDO.
ENDFORM. " BUILD_FIELDCAT
*& Form CREATE_DYNAMIC_TABLE
FORM create_dynamic_table .
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = it_fcat
IMPORTING
ep_table = it_dyn_tab.
ASSIGN it_dyn_tab->* TO <gt_table>.
Create dynamic work area and assign to FS
CREATE DATA wa_newline LIKE LINE OF <gt_table>.
ASSIGN wa_newline->* TO <fs_dyntable>.
ENDFORM. " CREATE_DYNAMIC_TABLE
*& Form FIELDCATALOG
FORM fieldcatalog USING field table f_txt.
wa_fcat-fieldname = field.
wa_fcat-tabname = table.
wa_fcat-seltext = f_txt.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.
ENDFORM. " FIELDCATALOG
*& Form FIELDCATALOG1
FORM fieldcatalog1 USING field table f_txt.
wa_fcatalog-fieldname = field.
wa_fcatalog-tabname = table.
wa_fcatalog-seltext_m = f_txt.
APPEND wa_fcatalog TO it_fcatalog.
CLEAR wa_fcatalog.
ENDFORM. " FIELDCATALOG1
*& Form SELECT_DATA
text
--> p1 text
<-- p2 text
FORM select_data .
DATA: v_srlno TYPE i.
SELECT matnr charg blqty
INTO CORRESPONDING FIELDS OF it_itab
FROM zjpack_base
WHERE matnr IN s_matnr
AND charg IN s_charg
AND fdate IN s_fdate.
COLLECT it_itab.
ENDSELECT.
v_srlno.
LOOP AT it_itab.
v_srlno = v_srlno + 1.
ENDLOOP.
CLEAR: l_fieldname,
l_tabname,
l_fieldtext,
l_index.
1st Field
l_index = sy-tabix.
CONCATENATE 'FIELD' '1' INTO l_fieldname.
l_fieldtext = 'MATNR'.
l_tabname = '<GT_TABLE>'.
PERFORM fieldcatalog USING: l_fieldname
l_tabname
l_fieldtext.
Other fields
LOOP AT it_itab.
CLEAR l_index.
l_index = sy-tabix + 1.
CONCATENATE 'FIELD' l_index INTO l_fieldname.
CONCATENATE 'CHARG-' it_itab-charg INTO l_fieldtext.
l_tabname = '<GT_TABLE>'.
PERFORM fieldcatalog USING: l_fieldname
l_tabname
l_fieldtext.
ENDLOOP.
Please guide me how my problem will solve.
Thanks & Regards
NirmalHi all, I am developing a Dynamic ALV report where I want display material batch (zjpack_base-charg) in column and Material (zjpack_base-matnr) & Qty (Zjpack_base-netwr) field row wise.My intention is to show report datewise for a material how many batch developed with there qty.I am sending you the code which i already wrote.Here column is developed batchwise but I am not able to show the qty against each batch.Please see my code and guide me how to display.
*& Report ZDYNAMIC_TEST *
REPORT zdynamic_test .
*REPORT ztest_notepad.
*& Declarations
*Type-pools
TYPE-POOLS: slis.
*TABLES
TABLES: zjpack_base.
*Types
TYPES:
ty_fcat TYPE lvc_s_fcat,
ty_fcatalog TYPE slis_fieldcat_alv.
*Work areas
DATA:
wa_fcat TYPE ty_fcat,
wa_fcatalog TYPE ty_fcatalog.
*Internal tables
DATA:
it_fcat TYPE STANDARD TABLE OF ty_fcat,
it_fcatalog TYPE STANDARD TABLE OF ty_fcatalog.
*Type reference
DATA:
it_dyn_tab TYPE REF TO data,
wa_newline TYPE REF TO data.
*INTERNAL TABLE
DATA: BEGIN OF it_itab OCCURS 0.
INCLUDE STRUCTURE zjpack_base.
DATA: END OF it_itab.
*Filed symbols
FIELD-SYMBOLS:
<gt_table> TYPE STANDARD TABLE,
<fs_dyntable>,
<fs_fldval> TYPE ANY,
<l_field> TYPE ANY.
*Variables
DATA:
l_fieldname TYPE lvc_s_fcat-fieldname,
l_tabname TYPE lvc_s_fcat-tabname,
l_fieldtext TYPE lvc_s_fcat-seltext,
l_index TYPE char2.
"Selection-screen
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-s11 .
SELECT-OPTIONS:s_matnr FOR zjpack_base-matnr.
SELECT-OPTIONS:s_charg FOR zjpack_base-charg.
SELECT-OPTIONS:s_fdate FOR zjpack_base-fdate .
SELECTION-SCREEN END OF BLOCK b1.
PARAMETERS:
p_colms TYPE i.
*& start-of-selection.
START-OF-SELECTION.
PERFORM select_data.
PERFORM build_fieldcat.
PERFORM create_dynamic_table.
* DO 20 TIMES.
* DO p_colms TIMES.
* l_index = sy-index.
* CONCATENATE 'FIELD' l_index INTO l_fieldname.
* ASSIGN COMPONENT l_fieldname OF STRUCTURE <fs_dyntable> TO <l_field>.
* <l_field> = sy-index.
* ENDDO.
* INSERT <fs_dyntable> INTO TABLE <gt_table>.
* ENDDO.
LOOP AT it_itab.
l_index = sy-tabix.
CONCATENATE 'FIELD' l_index INTO l_fieldname.
ASSIGN COMPONENT l_fieldname OF STRUCTURE <fs_dyntable> TO <l_field>.
<l_field> = it_itab-matnr.
INSERT <fs_dyntable> INTO TABLE <gt_table>.
ENDLOOP.
LOOP AT it_fcat INTO wa_fcat.
PERFORM fieldcatalog1 USING: wa_fcat-fieldname
wa_fcat-tabname
wa_fcat-seltext.
ENDLOOP.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = 'ZTEST_NOTEPAD'
it_fieldcat = it_fcatalog
TABLES
t_outtab = <gt_table>.
*& Form BUILD_FIELDCAT
FORM build_fieldcat .
* CLEAR: l_fieldname,
* l_tabname,
* l_fieldtext,
* l_index.
* DO p_colms TIMES.
* CLEAR l_index.
* l_index = sy-index.
* CONCATENATE 'FIELD' l_index INTO l_fieldname.
* CONCATENATE 'Field' l_index INTO l_fieldtext.
* l_tabname = '<GT_TABLE>'.
* PERFORM fieldcatalog USING: l_fieldname
* l_tabname
* l_fieldtext.
* ENDDO.
ENDFORM. " BUILD_FIELDCAT
*& Form CREATE_DYNAMIC_TABLE
FORM create_dynamic_table .
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = it_fcat
IMPORTING
ep_table = it_dyn_tab.
ASSIGN it_dyn_tab->* TO <gt_table>.
* Create dynamic work area and assign to FS
CREATE DATA wa_newline LIKE LINE OF <gt_table>.
ASSIGN wa_newline->* TO <fs_dyntable>.
ENDFORM. " CREATE_DYNAMIC_TABLE
*& Form FIELDCATALOG
FORM fieldcatalog USING field table f_txt.
wa_fcat-fieldname = field.
wa_fcat-tabname = table.
wa_fcat-seltext = f_txt.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.
ENDFORM. " FIELDCATALOG
*& Form FIELDCATALOG1
FORM fieldcatalog1 USING field table f_txt.
wa_fcatalog-fieldname = field.
wa_fcatalog-tabname = table.
wa_fcatalog-seltext_m = f_txt.
APPEND wa_fcatalog TO it_fcatalog.
CLEAR wa_fcatalog.
ENDFORM. " FIELDCATALOG1
*& Form SELECT_DATA
* text
* --> p1 text
* <-- p2 text
FORM select_data .
* DATA: v_srlno TYPE i.
SELECT matnr charg blqty
INTO CORRESPONDING FIELDS OF it_itab
FROM zjpack_base
WHERE matnr IN s_matnr
AND charg IN s_charg
AND fdate IN s_fdate.
COLLECT it_itab.
ENDSELECT.
* v_srlno.
* LOOP AT it_itab.
* v_srlno = v_srlno + 1.
* ENDLOOP.
CLEAR: l_fieldname,
l_tabname,
l_fieldtext,
l_index.
* 1st Field
* l_index = sy-tabix.
CONCATENATE 'FIELD' '1' INTO l_fieldname.
l_fieldtext = 'MATNR'.
l_tabname = '<GT_TABLE>'.
PERFORM fieldcatalog USING: l_fieldname
l_tabname
l_fieldtext.
* Other fields
LOOP AT it_itab.
CLEAR l_index.
l_index = sy-tabix + 1.
CONCATENATE 'FIELD' l_index INTO l_fieldname.
CONCATENATE 'CHARG-' it_itab-charg INTO l_fieldtext.
l_tabname = '<GT_TABLE>'.
PERFORM fieldcatalog USING: l_fieldname
l_tabname
l_fieldtext.
ENDLOOP.
ENDFORM. " SELECT_DATA -
Generating Dynamic Query for Ad-Hoc Reports
Hello,
What is the best way to create a dynamic query to generate ad-hoc reports? I have a couple of ideas but not sure which would work best and be most flexible.
I would like our users to be able to check checkboxes for what data they would like returned in their report. The data would be pulled from a number of tables, 10+, depending on what pieces of data they checked.
Should I write one dynamic query, with a bunch of IF statements in it?
Should I write many individual queries and then join them together in a temp query?
Should I create a temp table on our SQL server which contains the data from all of the tables; then query that? (I am worried about data being out-of-date with this option.)
Which one of these solutions should I go with or is there a better solution that I am not considering?
Thanks for the help.
JoshDo you mean a Stored Procedure? Would the Stored Procedure then have one query on it with a bunch if IF statements? Maybe a bad example, but something like this?
Yep.
I haven't written a proc for a coupla years (I have DB people to do that for me now, bless 'em), but every DB is different, so the approach will vary depending on what DB you have. It's perhaps time to buy a book or do a google or something.
Adam
Maybe you are looking for
-
Labview 6 xmathtypes.dll missing
Hi, I am trying to run Matlab script (Matlab version I think it is the latest one) from Labview 6.1. Initially it wasn't running. Then I came across this thread http://digital.ni.com/public.nsf/websearch/CE309627064A3D5686256A9C005B0A5F?OpenDocu
-
Photoshop CC slow in performance on big files
Hello there! I've been using PS CS4 since release and upgraded to CS6 Master Collection last year. Since my OS broke down some weeks ago (RAM broke), i gave Photoshop CC a try. At the same time I moved in new rooms and couldnt get my hands on the DVD
-
AS 3.0 how to set event target?
Hi, I am trying to execute an event on a specific target and I am not successful in doing this in AS 3.0 since event.target is read only. Here is the scenario: - I have a button and the path to this button is: DataEntry0._UpdateDeleteProd1.Form10.For
-
Whose the smartest can figure this brain teaser of AS 3.0 problem?
Spent all afternoon trying to figure out the following AS 3.0 problem in Flash CS4. I can load an image using a custom class (called "BitmapExample") inside a unnamed package by placing the class name in Class field in the Properties panel inside of
-
A list of our formal training courses in Java CAPS can be found here for North America: http://www.seebeyond.com/services/course_catalog.asp here for Europe: http://www.seebeyond.com/services/course_catalog_emea.asp and here for Asia Pacific: http://