SQL Dev Child Reports - Dynamic From Clause Possible?
Hi All,
Trying to figure out this problem:
Master Report SQL:
select TABLE_NAME from USER_TAB_COLS where COLUMN_NAME = 'CREATION_DATE'
Results with some table names. Now I want to use the table name to formulate my child query
Child SQL:
select * from :TABLE_NAME where CREATION_DATE >= SYSDATE-7
or whatever.....but I want to somehow use the table_name dynamically.
Thanks!
-Brent
I doubt that you can get dynamic from clause for Child Report if its style is table.
But you can get dynamic one in child with style script:
Say you have :
Master report for list tables which select owner and table name by some condition (I omit this):
SQL : select owner, table_name from all_tables ..So Child Report
SQL is follow:
COLUMN TN NEW_VALUE TNAME ;
select :OWNER||'.'||:TABLE_NAME as TN from dual;
select '&&TNAME' as tab_NAME, count(1) from &&TNAME;Hope it help.
Edited by: K_Serge on Jan 5, 2013 5:10 AM
Edited by: K_Serge on Jan 5, 2013 5:20 AM
Similar Messages
-
Creating Crystal Reports Dynamically from an incoming SQL query
Hi,
I have a requirement where a sql query will be entered by the user in a text box and in the back end java code, i have to create a crystal report dynamically based on that sql query and show it in the crystalviewer object.
For example if the user writes "select x,y from xtable ", i should be able to create a report with 2 fields, and if the user says "select x,y,z from xtable" then i should be able create and show a report with 3 fileds...thsi report creation should be done in the click event.
Is this possible in java? I have found something similar in .NET... pls have a look at this
http://vb.net-informations.com/crystal-report/dynamic_crystal_report_from_sql_query_string.htm
Thanks,
PreethiHi Preethi,
Can you please share the steps with me? I am also looking for dynamic SQL being applied to the crystal report.
Thank you so much for your help in advance.
Regards,
Janakiram D. -
Need help with writing a query with dynamic FROM clause
Hi Folks,
I need help with an query that should generate the "FROM" clause dynamically.
My main query is as follows
select DT_SKEY, count(*)
from *???*
where DT_SKEY between 20110601 and 20110719
group by DT_SKEY
having count(*) = 0
order by 1; The "from" clause of the above query should be generated as below
select 'Schema_Name'||'.'||TABLE_NAME
from dba_tables
where OWNER = 'Schema_Name'Simply sticking the later query in the first query does not work.
Any pointers will be appreciated.
Thanks
rogers42Hi,
rogers42 wrote:
Hi Folks,
I need help with an query that should generate the "FROM" clause dynamically.
My main query is as follows
select DT_SKEY, count(*)
from *???*
where DT_SKEY between 20110601 and 20110719
group by DT_SKEY
having count(*) = 0
order by 1; The "from" clause of the above query should be generated as below
select 'Schema_Name'||'.'||TABLE_NAME
from dba_tables
where OWNER = 'Schema_Name'
Remember that anything inside quotes is case-sensitive. Is the owner really "Schema_Name" with a capital S and a capital N, and 8 lower-case letters?
Simply sticking the later query in the first query does not work.Right; the table name must be given when you compile the query. It's not an expression that you can generate in the query itself.
Any pointers will be appreciated.In SQL*Plus, you can do something like the query bleow.
Say you want to count the rows in scott.emp, but you're not certain that the name is emp; it could be emp_2011 or emp_august, or anything else that starts with e. (And the name could change every day, so you can't just look it up now and hard-code it in a query that you want to run in the future.)
Typically, how dynamic SQL works is that some code (such as a preliminary query) gets some of the information you need to write the query first, and you use that information in a SQL statement that is compiled and run after that. For example:
-- Preliminary Query:
COLUMN my_table_name_col NEW_VALUE my_table_name
SELECT table_name AS my_table_name_col
FROM all_tables
WHERE owner = 'SCOTT'
AND table_name LIKE 'E%';
-- Main Query:
SELECT COUNT (*) AS cnt
FROM scott.&my_table_name
;This assumes that the preliminary query will find exactly one row; that is, it assumes that SCOTT has exactly one table whose name starts with E. Could you have 0 tables in the schema, or more than 1? If so, what results would you want? Give a concrete example, preferably suing commonly available tables (like those in the SCOTT schema) so that the poepl who want to help you can re-create the problem and test their ideas.
Edited by: Frank Kulash on Aug 11, 2011 2:30 PM -
How to programmatically count from a dynamic from clause ?
Hi all,
My report contains a user-parameter , say :from_clause, which will receive the from clause of a query from a forms application. We can have for example :from_clause = "from t_table where column_1 = value_1 order by column_2". The "from" keeword is included in the parameter value. In the before report trigger I want to make a count based on that from clause. How to achieve this goal ?
Thank you very much indeed.Hi,
It won't work. You need a control flow case, unless you want to use a hack (internal API) with OutcomeUtils.getActivityRequestOutcome(activityId).
FacesContext context = FacesContext.getCurrentInstance();
NavigationHandler handler = context.getApplication().getNavigationHandler();
handler.handleNavigation(context, null, OutcomeUtils.getActivityRequestOutcome("YourViewId"));
context.renderResponse();Regards,
~ Simon -
Dynamic 'from' Clause in Native SQL
Hi All,
While running a select query in ORACLE, we can put the table name in '<i>from</i>' clause at the runtime-Seletion Screen Parameter .
But I am not able to do so in SAP using Native Sql. Does SAP has any restrictions regarding this?
It might be possible that ,by using Embedded SQL (C/C++ precompiler ),we may be able to achive this.
Can any body please throw light on this.
Its Urgent.
Thanks in Advance.
Regards,
GauravHi
<u>Assuming you can also use Open SQL.</u>
Macroman's suggestion is OK. in Open SQL (this is SQL of ABAP platform) but a query statement can be constituted using some dynamic clauses. Although macro coding has some restrictions it will be less time consuming using it than a dynamic query.
<u>An example SELECT statement with dynamic clauses:</u>
SELECT (fields) FROM (table_name_variable)
INTO <target_fields>
WHERE (conditions_tab) .
For more information:
<a href="http://help.sap.com/saphelp_47x200/helpdata/en/fc/eb3983358411d1829f0000e829fbfe/frameset.htm">Open SQL -Reading Data</a>
*--Serdar -
Hi, I am needing to use a dynamic "<font color="blue">FROM (insert table name here)</font>" as well. From reading several posts, it seems like I need to do this using dynamic SQL. I can pass the name of the table into the stored procedure, but I am getting confused as to how to turn the SELECT statement part of this function into dynamic SQL since the SELECT statement is already inside a cursor itself. Thank you -
<br><br><b>FUNCTION getDni4wImmStartInterface(p_board_group_id NUMBER) RETURN interface_cnt_tbl PIPELINED
IS
--fill the cursor with available interfaces for the board_group_id passed in
CURSOR gc_intf IS
SELECT interface
FROM TABLE(ipfinterfaces.getinterfaceslist(p_board_group_id))
WHERE interface NOT IN (SELECT interface FROM physical_interface WHERE board_group_id = p_board_group_id);
l_count NUMBER(10);
l_max NUMBER(10);
BEGIN
--fetch the max # of interfaces allowed for the board group type
--passed in
SELECT bgt.max_interfaces
INTO l_max
FROM board_group_type bgt, board_groups bg
WHERE bg.board_group_id = p_board_group_id
AND bg.board_group_type_id = bgt.board_group_type_id;
--for interface in the cursor, check to see if there is an interface
--with the same C-S-G in the database that is 1 greater than the one in the cursor
FOR gc_rec IN gc_intf LOOP
SELECT count(*)
INTO l_count
"<font color="blue">FROM INT_DNI_4W_IMM c</font>
, VIRTUAL_INTERFACE vi
, BOARD_GROUPS bg
, PHYSICAL_INTERFACE pi
, BOARD b
WHERE b.BOARD_ID = bg.BOARD_ID
AND b.SYSTEM_ID = vi.SYSTEM_ID
AND vi.PHYSICAL_INTERFACE_ID = pi.PHYSICAL_INTERFACE_ID
AND pi.SYSTEM_ID = vi. SYSTEM_ID
AND pi.BOARD_GROUP_ID = bg.BOARD_GROUP_ID
AND vi.SYSTEM_ID = bg.SYSTEM_ID
AND c.VIRTUAL_INTERFACE_ID = vi.VIRTUAL_INTERFACE_ID
AND bg.BOARD_GROUP_ID = p_board_group_id
AND pi.Interface = TO_NUMBER(gc_rec.Interface) + 1;
--if there is not interface 1 greater than the one passed in, and if
--the interface passed in is not the max interface, pipe the row back.
IF l_count = 0 AND (TO_NUMBER(gc_rec.interface) != l_max)
THEN PIPE ROW (interface_cnt_obj (TO_NUMBER(gc_rec.interface), TO_NUMBER(l_count)));
END IF;
END LOOP;
RETURN;
END getDni4wImmStartInterface;
</b>Hi Vikas,
Sorry, I didn't think I could assign p_table_name to l_table_name like that. When I try to implement your suggestion, I get these errors (Is my DECLARE out of place?):<br><br>
Line # = 469 Column # = 1 Error Text = PLS-00103: Encountered the symbol "DECLARE" when expecting one of the following: begin function package pragma procedure subtype type use <an identifier> <a double-quoted delimited-identifier> form current cursor The symbol "begin" was substituted for "DECLARE" to continue. <br><br>
Line # = 474 Column # = 14 Error Text = PLS-00103: Encountered the symbol "=" when expecting one of the following: constant exception <an identifier> <a double-quoted delimited-identifier> table LONG_ double ref char time timestamp interval date binary national character nchar The symbol "<an identifier>" was substituted for "=" to continue.
<br><br>
Line # = 491 Column # = 51 Error Text = PLS-00103: Encountered the symbol "C" when expecting one of the following: * & = - + ; < / > at in is mod remainder not rem <an exponent (**)> <> or != or ~= >= <= <> and or like LIKE2_ LIKE4_ LIKEC_ between || multiset member SUBMULTISET_
<br><br>
Line # = 496 Column # = 3 Error Text = PLS-00103: Encountered the symbol "WHERE" when expecting one of the following: , from into bulk
<br><br>
Line # = 503 Column # = 27 Error Text = PLS-00049: bad bind variable 'B1'
<br><br>
Line # = 506 Column # = 3 Error Text = PLS-00103: Encountered the symbol "EXECUTE"
<br><br>
Here's my current code:<br><br><b>FUNCTION getDni4wImmStartInterface(p_board_group_id NUMBER, p_table_name VARCHAR2) RETURN interface_cnt_tbl PIPELINED
IS
--fill the cursor with available interfaces for the board_group_id passed in
CURSOR gc_intf IS
SELECT interface
FROM TABLE(ipfinterfaces.getinterfaceslist(p_board_group_id))
WHERE interface NOT IN (SELECT interface FROM physical_interface WHERE board_group_id = p_board_group_id);
DECLARE
l_count NUMBER(10);
l_max NUMBER(10);
l_sql LONG;
l_count NUMBER;
l_table_name := p_table_name;
BEGIN
--fetch the max # of interfaces allowed for the board group type
--passed in
SELECT bgt.max_interfaces
INTO l_max
FROM board_group_type bgt, board_groups bg
WHERE bg.board_group_id = p_board_group_id
AND bg.board_group_type_id = bgt.board_group_type_id;
--for interface in the cursor, check to see if there is an interface
--with the same C-S-G in the database that is 1 greater than the one in the cursor
FOR gc_rec IN gc_intf LOOP
l_sql := 'SELECT count(*) FROM ||l_table_name||' c
, VIRTUAL_INTERFACE vi
, BOARD_GROUPS bg
, PHYSICAL_INTERFACE pi
, BOARD b
WHERE b.BOARD_ID = bg.BOARD_ID
AND b.SYSTEM_ID = vi.SYSTEM_ID
AND vi.PHYSICAL_INTERFACE_ID = pi.PHYSICAL_INTERFACE_ID
AND pi.SYSTEM_ID = vi. SYSTEM_ID
AND pi.BOARD_GROUP_ID = bg.BOARD_GROUP_ID
AND vi.SYSTEM_ID = bg.SYSTEM_ID
AND c.VIRTUAL_INTERFACE_ID = vi.VIRTUAL_INTERFACE_ID
AND bg.BOARD_GROUP_ID = :b1
AND pi.Interface = TO_NUMBER(gc_rec.Interface) + 1;
EXECUTE IMMEDIATE l_sql INTO l_count USING p_board_group_id;
<br><br></b>Message was edited by:
The Fabulous LB -
Create view with dynamic from-clause
Dear all,
you might have some ideas to help me out of my issue that i just "created myself" ;-)
i have a unknown and non-constant amount of tables using the the same table-structure and i do have a master table
that contains all names of these kind of tables. I now want to create a single view that contains all columns of each table
and an additional column name containing the name of the corresponding table.
I found a solution for this but only if I knew all table names while creating my view.
Here's what I currently have:
master_table:
ID TABLENAME
1 table_01
2 table_02
table_01:
ID NAME
1 eins
2 zwei
3 drei
table_02:
ID NAME
1 one
2 two
3 three
my view "tab1tab2" on these 2 table looks like this:
ID NAME TABLENAME
1 eins table_01
2 zwei table_01
3 drei table_01
1 one table_02
2 two table_02
3 three table_02
i achieved this view by using:
CREATE OR REPLACE VIEW TAB1TAB2 ("ID", "NAME", "TABLENAME")
AS
SELECT id,name, 'table_01' AS tablename FROM table_01
UNION
SELECT id,name, 'table_02' AS tablename FROM table_02;
Is there a way to create as many select and union statements as i do have entries (tablenames) in my master_table to achive the same results as my hardcoded view ?
Many thanks in advance for your help
Best regards
majoIs there a way to create as many select and union statements as i do have entries (tablenames) in my master_table to achive the same results as my hardcoded view ?You can achieve this also with some xml facilities as e.g. in
SQL> create table t1 as select empno, ename from emp where rownum <= 3
Table created.
SQL> create table t2 as select deptno empno, dname ename from dept
Table created.
SQL> create table master as (select 1 id, 't1' table_name from dual union all
select 2 id, 't2' table_name from dual)
Table created.
SQL> create or replace view v_t
as
select table_name, x.*
from (select table_name, 'ora:view("' || table_name || '")' tabs from master),
xmltable (tabs columns id int path 'EMPNO', ename varchar2(20) path 'ENAME') x
View created.
SQL> select * from v_t
TABLE_NAME ID ENAME
t1 7369 SMITH
t1 7499 ALLEN
t1 7521 WARD
t2 10 ACCOUNTING
t2 20 RESEARCH
t2 30 SALES
t2 40 OPERATIONS
t2 50 SALES
8 rows selected.
SQL> create table t3 as select object_id empno, object_name ename from user_objects where rownum <= 3
Table created.
SQL> insert into master values (3, 't3')
1 row created.
SQL> select * from v_t
TABLE_NAME ID ENAME
t1 7369 SMITH
t1 7499 ALLEN
t1 7521 WARD
t2 10 ACCOUNTING
t2 20 RESEARCH
t2 30 SALES
t2 40 OPERATIONS
t2 50 SALES
t3 187449 ABC
t3 187448 ADDRESSES_EXT_TAB
t3 187446 ADDRESSES_EXT_TYP
11 rows selected.Note: above will work only in 11g. -
From Clause query with form variables
forms 9.0.4 rdbms 9.2
Is it possible to create a From Clause query with form variables generated from another block (but in the same form)? I am not having any success.
I searched Metalink. It appears that according to DOC ID # 69884.1, in Forms 6i, this is not possible. Metalink suggest in DOC ID 104771.1 implementating a dynamic From Clause, but when I duplicate the example on my system, I receive an Oracle error. Further investigation from the web form (DISPLAY ERROR) indicates that the system does not see the dynamic value.
Has anyone else run into this error? Has this been fixed in forms 9.0.4 and I am just missing something? Does a dynamic from clause query work? Can anyone point me to an example or post an example or offer any advise.
thanks in advanceAs far as I know it is not possible to use block items in a from clause query in forms 9.0.4. Here is my solution for a From-Clause-Query via the 'Query-Data-Source-Name-Property':
To use the values of the block items in my from clause query I implemented a database package with getter and setter routines for the block item values I needed for the query.
In the Key-Exeqry-Trigger of the From-Clause-Query-Block I set the global package variables with values of the block-items I am interested in. In the From-Clause-Query I used the values in the where-clause via package functions which return the global package variables.
Hope my solution will work for your problem. -
Is it possible to pass a variable in FROM clause in SQL?
Hi Experts,
<i><b>loop at it_db_table.
select field1 from it_db_table-table_name into my_it.
endloop.</b></i>
I mean, Is it pass a variable value to FROM clause in SQL?
I got the info from SAP as,
<i><b>Works like variants 1-3, provided the source_text varialb contains the table name or a join expression as ABAP source text.
Examples
Output of a list of all customers:
DATA tabname(10).
DATA: BEGIN OF wa,
id TYPE scustom-id,
name TYPE scustom-name,
END OF wa.
tabname = 'SCUSTOM'.
SELECT id name INTO CORRESPONDING FIELDS OF wa FROM (tabname).
WRITE: / wa-id, wa-name.
ENDSELECT.</b></i>
thanq.Here is a short sample of a dynamic select statement.
Enter your table name in the parameter on selection screen. Enter you where clause in the select-option on selection screen.
I used.....
MARA
MTART = 'HALB'
report zrich_0004 .
data: xwhere(30) type c.
data: iwhere(30) type c occurs 0.
data:itab(1000) type c occurs 0 with header line.
parameters: p_table(30) type c.
select-options: s_where for xwhere.
loop at s_where.
clear iwhere.
xwhere = s_where-low.
append xwhere to iwhere.
endloop.
select * up to 100 rows into table itab
from (p_table)
where (iwhere).
loop at itab.
write:/ itab.
endloop.
Regards
vasu -
Possible APEX BUG - Export to CSV from SQL Query (updateable report)
I'm getting a the following sql error - just by enabling the Export to a CSV file from a SQL Query (updateable report) and selecting the export link - anyone have an idea what I could as a workaround?
ORA-06550: line 1, column 45: PLS-00103: Encountered the symbol "1" when expecting one of the following: begin case declare exit for goto if loop mod null pragma raise return select update while with <an identifier> <a double-quoted delimited-identifier> <a bind variable> << close current delete fetch lock insert open rollback savepoint set sql execute commit forall merge pipe
Error ERR-1000 Unable to determine LOV from "declare function x return varchar2 is begin 1 Not Checked;1 Not Checked,2 Review Passed;2 Review Passed,3 Reviewed w/ Issues;3 Reviewed w/ Issues,4 Not Applicable;4 Not Applicable return null; end; begin wwv_flow_utilities.g_query := x; end;".
OK
report error:
ORA-20001: Error fetching column value: ORA-20001: Query must begin with SELECT or WITHFrank,
I received your email with this same question so I'll just respond here. Our internet-facing hosted site apex.oracle.com allows you to request a workspace and, after the request is approved and the workspace provisioned, to develop applications there. If you already have an application that you need some help with, you can import/install it into your workspace on apex.oracle.com. This makes it easy to demonstrate problems to others who might be able to help.
Sometimes it will be necessary for you to create developer accounts in your workspace in order for others to use your Application Builder. You can post usernames/passwords here or you can convey those privately to those offering their services. In either case, you'd want to remove or disable those accounts as soon as the problem is resolved. For problems that I ask to see demonstrated on apex.oracle.com, it is not necessary for you to create an account for me. I can do that as our group runs the site. I just need to know your workspace name and application ID.
Scott -
Following an article by Sue Harper originally published in the May/June 2007 Oracle magazine, I have finally been able to construct a hierarchy of Drill-Down reports. My original attempts to create such reports failed, because in my version of SQL Dev 1.5.4 I could not see how to specify a "Report ID" as Sue had documented. Following instructions on other posts I have found, including a bind variable in the drill-down query appears to resolve this problem.
I can also use the "Add Child" button on a parent report definition to add reports which also use bind variables, and which then appear as clickable tabs below the parent report. When defining such a child report, I can choose a type of "Detail" or "Child".
My questions are these:
1. What is the difference between a drill-down report as described by Sue, and a Child report defined when the "Add Child" button is clicked, other than where the report appears on the Oracle SQL Dev window?
2. When defining a Child report after clicking "Add Child", what is the difference between a type of "Detail" and "Child"?
Sorry if this has already been clearly explained elsewhere. Links to relevant doco will be much appreciated!
TIA,
JonHello,
Is it possible to have a "chart" report that expands to multiple child "chart" reports with the bind variable from the 1st child report passed to the 2nd child report?
The bind variable from the 1st child report is not being passed to the 2nd child report.
In the sample below, I would like to display a count of objects created by day. When clicking on the object_type/count/day, it displays a child chart with the object_type by hour. What's not working is, when I select the object_type, the 2nd child chart is not displaying the object_type created for that hour (:TIME2) because it is not being recognized/passed to the chart.
Below is the sql and sqldeveloper report options I'm using. Thanks in advance for your help.
-- Master - bar_vert_stack chart of objects created by day:
select
to_char(trunc(created,'dd'),'mmddyyyy') TIME1,
object_type OBJECT_TYPE1,
count(*)
from all_objects
group by
to_char(trunc(created,'dd'),'mmddyyyy'),
object_type
order by
to_char(trunc(created,'dd'),'mmddyyyy') desc
-- Child1 - bar_vert_stack chart of objects created by hour that appears when selecting the day above:
select
to_char(trunc(created,'hh24'),'mmddyyyy hh24:mi:ss') TIME2,
object_type OBJECT_TYPE2,
count(*)
from all_objects
where
object_type=:OBJECT_TYPE1
and created between to_date(:TIME1,'mmddyyyy hh24:mi:ss') and (to_date(:TIME1,'mmddyyyy hh24:mi:ss')+1)
group by
to_char(trunc(created,'hh24'),'mmddyyyy hh24:mi:ss'),
object_type
order by
TIME2 desc
-- Child2 - table of objects created in the hour that appears when selecting the day above (note that :TIME2 is not being passed so all
--recs for that day are displayed)
select
:TIME1,:OBJECT_TYPE1,:TIME2,:OBJECT_TYPE2,all_objects.*
from all_objects
where
object_type=:OBJECT_TYPE1
and created
between to_date(:TIME1,'mmddyyyy hh24:mi:ss')
and (to_date (:TIME1,'mmddyyyy hh24:mi:ss')+1)
order by created desc -
How to change tables in from clause dynamically
Hi,
I have to add some join conditions in where clause and tables in from clause based on some input parameters and data in other tables.
How can i achieve this ? I must use procedure/function or dynamic query preparation or any more alternatives?
Regards,
KrishnaYes, you can use dynamic sql for that.
But be aware that you'll be needing to concatenate the table names in your FROM-clause, you cannot bind them...
So you'll be trashing the shared pool.
Maybe alternative approaches are possible, but you provide too little input for my crystal ball here... -
REPORT with dynamic WHERE CLAUSE (run RDF or REP) ?
Hi:
When running a REPORT (myreport.rep) with dynamic where clause using a lexical parameter, I got this error:
REP-1439: Cannot compile .REP or .PLX file as it does not have source
If i run the report specifiying RDF extension (myreport.rdf) the report run successfully! Is this normal ?
If I specify RDF extension will Report Server COMPILE the report everytime I execute it ?
When using dynamic WHERE CLAUSE I will have to run RDF files instead of REP ?
I'm running Reports 9i under Linux, with IDS under Windows.
Waiting Help
Joao OliveiraIt sounds like you are building the .rep files on one platform (windows) and running them on another (linux). The reason that the .rdf file continues to work is that Reports recompiles the PL/SQL within the report when you move from one platform to another or change schemas. .rep files can't be re-compiled in this way so you need to ensure they are compiled successfully when converting them.
You need to convert from .rdf to .rep on the platform that you are intending to run on. Try running rwconverter on the linux platform with "compile_all=yes" to produce the .rep file and running that .rep file. -
Is there a way to use dynamic built string in the "from" clause
Hi all, im having one problem and now, im not sure how to solve it easily at all... :) Is there someone that would be so kind and put a eye on it? ..thx
I have plsql proc, in which i have a list of table_names. For each of that table i need to run a query that will retrieve me a list of values and for each of that value i need to do something.
If i can be more specific about the problem -> each of that table is built as key_column, value_columns, day,starttime. For a key per table there are 4 records per hour - every quarter. Im truncating those quarters to full-quarter (minutes => 0->14 = 0min; 15->29 = 15min, 30->44 = 30, 45->59=45)
example
i get for one key and specific hour four records at 15:01;15:16;15:31;15:46 => i truncate em to 15:00;15:15;15:30;15:45..Sometimes there is a problem with the tool that is generating those data for me, and one quarter could be moved a little - so i get data like 15:01;15:16;15:29;15:46 => after i truncate the times i get duplicates in second quarter. It also can happen like this : 23:00; 23:14; 23:29; 23:44; 23:59 => totaly bad => cos the last one supposed to be as 0:00 next day, ..and 23:14 as 23:15...So...that was a problem - and solution -> i wanted to create plsql that will find those hours in each table i ve defined, and for each problem hour i make some fixes - update the bad time ...
..and i have problem - can i put an dynamic built table_name in the "from" clause?
example how i wanted to do that:
declare
type t_objectName is table of varchar2(030) index by pls_integer;
l_tableName t_objectName;
begin
l_tableName(1) := 'tmphlrgl';
l_tableName(2) := 'tmprcfgl';
l_tableName(3) := 'tmprcfbs';
l_tableName(4) := 'tmpvlrgl';
for i in (select evtime from (select day,trunc_quarter(evtime) evtime,m_id from l_tableName(i) group by day,trunc_quarter(evtime),m_id having count(*)>1) order by evtime) loop
--some other conditions and the update...
end loop;
end;
/I cannot use the l_tableName(i) for FROM ...get an error...I was thinking to build it as dynamic sql and execute immediate into some kind of object that can store mutliple lines, from which i would in the FOR cycle get the data...But im not sure if this could be done in plsql...
thanks for your time and help..
d.declare
c sys_refcursor;
begin
for i in 1..4 loop
open c for 'day,trunc_quarter(evtime) evtime,m_id
from ' || l_tableName(i) ||
'group by day,trunc_quarter(evtime),m_id having
count(*)>1) order by evtime';Just to high light SELECT is missing that all
OPEN c FOR ' SELECT day,trunc_quarter(evtime) evtime,m_id
FROM' || l_tableName(i) ||
'GROUP BY day,trunc_quarter(evtime),m_id HAVING count(*)>1) ORDER BY evtime'; -
Can we use Dynamic SQL in Oracle Reports ?
Hi ,
Can we use Dynamic SQL in Oracle Reports ?
If yes please give some examples .
Thanx
sriniI believe the built-in package SRW.Do_Sql is what you are looking for
Example from the document:
/* Suppose you want to create a "table of contents" by getting the
** first character of a columns value, and page number on which its
** field fires to print. Assume that you want to put the "table of
contents"
** into a table named SHIP. You could write the following construct:
DECLARE
PAGE_NO NUMBER;
PAGE_FOR INDEX NUMBER;
SORT_CHAR CHAR(1);
CMD_LINE CHAR(200);
BEGIN
SORT_CHAR := :SORT_NAME ;
IF :CALLED = Y THEN
SRW.GET_PAGE_NUM(PAGE_FOR_INDEX);
SRW.USER_EXIT(RWECOP PAGE_FOR_INDEX
P_START_PAGENO);
SRW.MESSAGE(2,TO_CHAR(:P_START_PAGENO));
END IF;
SRW.GET_PAGE_NUM(PAGE_NO);
CMD_LINE := INSERT INTO SHIP VALUES
(||SORT_CHAR||,||TO_CHAR(PAGE_NO)||);
SRW.MESSAGE(2,CMD_LINE);
SRW.DO_SQL(CMD_LINE);
COMMIT;
EXCEPTION
WHEN DUP_VAL_ON_INDEX THEN
NULL;
WHEN SRW.DO_SQL_FAILURE THEN
SRW.MESSAGE(1,FAILED TO INSERT ROW INTO SHIP TABLE);
WHEN OTHERS THEN
COMMIT;
END;
Maybe you are looking for
-
Shared services vs essbase security
we upgraded from v7 to sys 9 recently.. when we used V7 essbase security was maintained by maxl scritps..? creation of filters granting access and everything was using maxl.. How can i do the same now? I think I cannot grant access to the cube or a f
-
Image Shifted (Link attached)
I posted this message two days ago and I also read the article about the layers. The background with the buttons was created in photoshop then I put it in the middle of the page. Then, I draw a layer to hold the swf file. When I view it in the IE, th
-
Hi, is there any way of assigning a keyboard shortcut to copy and paste atributes? I´m currently using drag and drop from the appearence panel but this takes much more time. In FreeHand I use ctrl+shift+C to copy the attributes of a shape and ctrl+sh
-
Endless trouble after downloading IOS7 ON BOTH IPHONE AND MINI IPAD. It takes almost 4 minutes to write and send SMS where it used to take 90 seconds on IOS6. My ipad wanted a passcode after installing IOS7 and I never knew what the passcode was and
-
Ever since the newest update (3.6.6) every time I restart Firefox it reverts back to as if it was first installed. It deletes my bookmarks, settings and history. I have deleted profiles and created new ones which didn't help. I have uninstalled and r