Put SQL query in a function/ call function from region
How can I write a SQL query (like SELECT EMPNO, ENAME, JOB FROM EMP) as PL/SQL function, and then call this function from the PL/SQL Function Returning SQL Statement region?
Thanks, Tom
thanks jverd for your quick reply.
I know passing in a reference to an object will do the job if I want to change the value several parameters in one function call.
But I want to ask, is there any other ways?
the following code works.....
public class TestParameter {
public static void main(String[] args) {
Test2 t2 = new Test2();
invokeChange(t2);
System.out.println("x = " + t2.x + "\t y = " + t2.y);
static void invokeChange(Test2 t2) {
t2.x = 10;
t2.y = 15;
class Test2 {
int x;
int y;
}
Similar Messages
-
SQL query statement for stored procedure / function listing ...
Hi everyone,
Is there a SQL query to list all the stored procedures and functions of an user in an Oracle 8 database?
I have this idea:
select * from USER_SOURCE where TYPE = 'PROCEDURE' or TYPE = 'FUNCTION'
but I am not too sure whether this is correct.
Thanks in advance,
EricYeah
I agree with you Garcia , my above posting was a correction to the query mentioned in the question only.
you are correct
If you only want the name of the object,
SELECT Object_Name from User_Objects where object_type in ( 'PROCEDURE' ,'FUNCTION');
is much faster than Selecting (distinct) from User_Source. -
How to use this function call function 'REUSE_ALV_COMMENTARY_WRITE' in alv
hi all
thanks in advance
how to use this function in alv programming
call function 'REUSE_ALV_COMMENTARY_WRITE'
why use and what purpose use this function plz tell me details
plz guide me
thanksHi
see this exmaple code where i had inserted a LOGO by useing this FM
*& Report ZTEST_ALV_LOGO
REPORT ztest_alv_logo.
TYPE-POOLS : slis.
*ALV Formatting tables /structures
DATA: gt_fieldcat TYPE slis_t_fieldcat_alv.
DATA: gt_events TYPE slis_t_event.
DATA: gs_layout TYPE slis_layout_alv.
DATA: gt_page TYPE slis_t_listheader.
DATA: gs_page TYPE slis_listheader.
DATA: v_repid LIKE sy-repid.
*ALV Formatting work area
DATA: w_fieldcat TYPE slis_fieldcat_alv.
DATA: w_events TYPE slis_alv_event.
DATA: gt_bsid TYPE TABLE OF bsid WITH HEADER LINE.
INITIALIZATION.
PERFORM build_events.
PERFORM build_page_header.
START-OF-SELECTION.
*perform build_comment. "top_of_page - in initialization at present
SELECT * FROM bsid INTO TABLE gt_bsid UP TO 10 ROWS.
*perform populate_for_fm using '1' '3' 'BUKRS' '8' 'GT_BSID' 'Whee'.
*USING = Row, Column, Field name, display length, table name, heading
*OR
PERFORM build_fieldcat.
gs_layout-zebra = 'X'.
*top of page event does not work without I_callback_program
v_repid = sy-repid.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = v_repid
i_structure_name = 'BSID'
i_background_id = 'ALV_BACKGROUND'
i_grid_title = 'This is the grid title'
I_GRID_SETTINGS =
is_layout = gs_layout
it_fieldcat = gt_fieldcat[]
it_events = gt_events[]
TABLES
t_outtab = gt_bsid.
Form..............: populate_for_fm
Description.......: Populates fields for function module used in ALV
FORM populate_for_fm USING p_row
p_col
p_fieldname
p_len
p_table
p_desc.
w_fieldcat-row_pos = p_row. "Row Position
w_fieldcat-col_pos = p_col. "Column Position
w_fieldcat-fieldname = p_fieldname. "Field name
w_fieldcat-outputlen = p_len. "Column Lenth
w_fieldcat-tabname = p_table. "Table name
w_fieldcat-reptext_ddic = p_desc. "Field Description
w_fieldcat-input = '1'.
APPEND w_fieldcat TO gt_fieldcat.
CLEAR w_fieldcat.
ENDFORM. " populate_for_fm
*& Form build_events
FORM build_events.
DATA: ls_event TYPE slis_alv_event.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
i_list_type = 0
IMPORTING
et_events = gt_events.
READ TABLE gt_events
WITH KEY name = slis_ev_user_command
INTO ls_event.
IF sy-subrc = 0.
MOVE slis_ev_user_command TO ls_event-form.
APPEND ls_event TO gt_events.
ENDIF.
READ TABLE gt_events
WITH KEY name = slis_ev_top_of_page
INTO ls_event.
IF sy-subrc = 0.
MOVE slis_ev_top_of_page TO ls_event-form.
APPEND ls_event TO gt_events.
ENDIF.
ENDFORM. " build_events
*& Form USER_COMMAND
When user command is called it uses 2 parameters. The itab
passed to the ALV is in whatever order it currently is on screen.
Therefore, you can read table itab index rs_selfield-tabindex to get
all data from the table. You can also check r_ucomm and code
accordingly.
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
READ TABLE gt_bsid INDEX rs_selfield-tabindex.
error checking etc.
SET PARAMETER ID 'KUN' FIELD gt_bsid-kunnr.
CALL TRANSACTION 'XD03' AND SKIP FIRST SCREEN.
ENDFORM. "user_command
*& Form top_of_page
Your own company logo can go here if it has been saved (OAOR)
If the logo is larger than the size of the headings in gt_page,
the window will not show full logo and will have a scroll bar. Thus,
it is a good idea to have a standard ALV header if you are going to
use logos in your top of page.
FORM top_of_page.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = gt_page
i_logo = 'ENJOYSAP_LOGO'.
ENDFORM. "top_of_page
*& Form build_fieldcat
*Many and varied fields are available here. Have a look at documentation
*for FM REUSE_ALV_LIST_DISPLAY and REUSE_ALV_FIELDCATALOG_MERGE
FORM build_fieldcat.
w_fieldcat-fieldname = 'BUDAT'.
w_fieldcat-seltext_m = 'Dte pst'.
w_fieldcat-ddictxt(1) = 'M'.
w_fieldcat-edit = 'x'.
Can change the position of fields if you do not want them in order
of the DDIC or itab
w_fieldcat-row_pos = '1'.
w_fieldcat-col_pos = '10'.
APPEND w_fieldcat TO gt_fieldcat.
CLEAR w_fieldcat.
ENDFORM. " build_fieldcat
*& Form build_page_header
gt_page is used in top of page (ALV subroutine - NOT event)
*H = Header, S = Selection, A = Action
FORM build_page_header.
For Headers, Key is not printed and is irrelevant. Will not cause
a syntax error, but is not used.
gs_page-typ = 'H'.
gs_page-info = 'Header 1'.
APPEND gs_page TO gt_page.
gs_page-typ = 'H'.
gs_page-info = 'Header 2'.
APPEND gs_page TO gt_page.
For Selections, the Key is printed (bold). It can be anything up to 20
bytes. It gets printed in order of code here, not by key value.
gs_page-typ = 'S'.
gs_page-key = 'And the winner is:'.
gs_page-info = 'Selection 1'.
APPEND gs_page TO gt_page.
gs_page-typ = 'S'.
gs_page-key = 'Runner up:'.
gs_page-info = 'Selection 2'.
APPEND gs_page TO gt_page.
For Action, Key is also irrelevant.
gs_page-typ = 'A'.
gs_page-info = 'Action goes here'.
APPEND gs_page TO gt_page.
ENDFORM. " build_page_header -
Error while executing SQL query -' Must Specify Table to select from'
Hi all,
While executing query using query generator
it shows error message
[Microsoft][SQL Native Client][SQL Server]Must specify table to select from.
2). [Microsoft][SQL Nativ
SELECT T1.ItemCode, T1.Dscription AS 'Item Description', T1.Quantity, T1.Price, T1.LineTotal,
(Select SUM(T2.TaxSum) From PCH4 T2 Where T0.DocEntry=T2.DocEntry AND T2.staType=-90 AND T1.LineNum=T2.LineNum) as 'BEDAmt',
(Select SUM(T2.TaxSum) From PCH4 T2 Where T0.DocEntry=T2.DocEntry AND T2.staType=-60 AND T1.LineNum=T2.LineNum) as 'ECSAmt',
(Select SUM(T2.TaxSum) From PCH4 T2 Where T0.DocEntry=T2.DocEntry AND T2.staType=7 AND T1.LineNum=T2.LineNum) as 'HECSAmt',
(Select SUM(T2.TaxSum) From PCH4 T2 Where T0.DocEntry=T2.DocEntry AND T2.staType=1 AND T1.LineNum=T2.LineNum) as 'VATAmt',
(Select SUM(T2.TaxSum) From PCH4 T2 Where T0.DocEntry=T2.DocEntry AND T2.staType=4 AND T1.LineNum=T2.LineNum) as 'CSTAmt'
FROM dbo.[OPCH] T0 INNER JOIN PCH1 T1 ON T0.DocEntry = T1.DocEntry INNER JOIN PCH4 T2 ON T2.DocEntry=T0.DocEntry
WHERE T0.DocDate >='[%0]' AND T0.DocDate <='[%1]' AND T0.DocType = 'I'
GROUP BY T1.ItemCode,T1.Dscription,T1.Quantity, T1.Price, T1.LineTotal,T0.DocEntry,T1.DocEntry,T1.LineNum,T2.LineNum
It's executing fine in MS SQL Server Studio Management.
Please give y'r ideas to solve the problem.
Jeyakanthantry this, it works fine in my B1:
SELECT T1.ItemCode, T1.Dscription AS 'Item Description', T1.Quantity, T1.Price, T1.LineTotal,
(Select SUM(T2.TaxSum) From PCH4 T2 Where T0.DocEntry=T2.DocEntry AND T2.staType=-90 AND T1.LineNum=T2.LineNum) as 'BEDAmt',
(Select SUM(T2.TaxSum) From PCH4 T2 Where T0.DocEntry=T2.DocEntry AND T2.staType=-60 AND T1.LineNum=T2.LineNum) as 'ECSAmt',
(Select SUM(T2.TaxSum) From PCH4 T2 Where T0.DocEntry=T2.DocEntry AND T2.staType=7 AND T1.LineNum=T2.LineNum) as 'HECSAmt',
(Select SUM(T2.TaxSum) From PCH4 T2 Where T0.DocEntry=T2.DocEntry AND T2.staType=1 AND T1.LineNum=T2.LineNum) as 'VATAmt',
(Select SUM(T2.TaxSum) From PCH4 T2 Where T0.DocEntry=T2.DocEntry AND T2.staType=4 AND T1.LineNum=T2.LineNum) as 'CSTAmt'
FROM dbo.OPCH T0 INNER JOIN PCH1 T1 ON T0.DocEntry = T1.DocEntry INNER JOIN PCH4 T2 ON T2.DocEntry=T0.DocEntry
WHERE T0.DocDate >='[%0]' AND T0.DocDate <='[%1]' AND T0.DocType = 'I'
GROUP BY T1.ItemCode,T1.Dscription,T1.Quantity, T1.Price, T1.LineTotal,T0.DocEntry,T1.DocEntry,T1.LineNum,T2.LineNum
B1 don't like brackets!
Regards -
Oracle SQL query for getting specific special characters from a table
Hi all,
This is my table
Table Name- Table1
S.no Name
1 aaaaaaaa
2 a1234sgjghb
3 a@3$%jkhkjn
4 abcd-dfghjik
5 bbvxzckvbzxcv&^%#
6 ashgweqfg/gfjwgefj////
7 sdsaf$([]:'
8 <-fdsjgbdfsg
9 dfgfdgfd"uodf
10 aaaa bbbbz#$
11 cccc dddd-/mnm
The output has to be
S.no Name
3 a@3$%jkhkjn
5 bbvxzckvbzxcv&^%#
7 sdsaf$([]:'
8 <-fdsjgbdfsg
10 aaaa bbbbz#$
It has to return "Name" column which is having special characters,whereas some special chars like -, / ," and space are acceptable.
The Oracle query has to print columns having special characters excluding -,/," and space
Can anyone help me to get a SQL query for the above.
Thanks in advance.You can achieve it in multiple ways. Here are few.
SQL> with t
2 as
3 (
4 select 1 id, 'aaaaaaaa' name from dual union all
5 select 2 id, 'a1234sgjghb' name from dual union all
6 select 3 id, 'a@3$%jkhkjn' name from dual union all
7 select 4 id, 'abcd-dfghjik' name from dual union all
8 select 5 id, 'bbvxzckvbzxcv&^%#' name from dual union all
9 select 6 id, 'ashgweqfg/gfjwgefj////' name from dual union all
10 select 7 id, 'sdsaf$([]:''' name from dual union all
11 select 8 id, '<-fdsjgbdfsg' name from dual union all
12 select 9 id, 'dfgfdgfd"uodf' name from dual union all
13 select 10 id, 'aaaa bbbbz#$' name from dual union all
14 select 11 id, 'cccc dddd-/mnm' name from dual
15 )
16 select *
17 from t
18 where regexp_like(translate(name,'a-/" ','a'), '[^[:alnum:]]');
ID NAME
3 a@3$%jkhkjn
5 bbvxzckvbzxcv&^%#
7 sdsaf$([]:'
8 <-fdsjgbdfsg
10 aaaa bbbbz#$
SQL> with t
2 as
3 (
4 select 1 id, 'aaaaaaaa' name from dual union all
5 select 2 id, 'a1234sgjghb' name from dual union all
6 select 3 id, 'a@3$%jkhkjn' name from dual union all
7 select 4 id, 'abcd-dfghjik' name from dual union all
8 select 5 id, 'bbvxzckvbzxcv&^%#' name from dual union all
9 select 6 id, 'ashgweqfg/gfjwgefj////' name from dual union all
10 select 7 id, 'sdsaf$([]:''' name from dual union all
11 select 8 id, '<-fdsjgbdfsg' name from dual union all
12 select 9 id, 'dfgfdgfd"uodf' name from dual union all
13 select 10 id, 'aaaa bbbbz#$' name from dual union all
14 select 11 id, 'cccc dddd-/mnm' name from dual
15 )
16 select *
17 from t
18 where translate
19 (
20 lower(translate(name,'a-/" ','a'))
21 , '.0123456789abcdefghijklmnopqrstuvwxyz'
22 , '.'
23 ) is not null;
ID NAME
3 a@3$%jkhkjn
5 bbvxzckvbzxcv&^%#
7 sdsaf$([]:'
8 <-fdsjgbdfsg
10 aaaa bbbbz#$
SQL> -
Handling sql query in jsp while extracing records from 3 tables
hi to one and all,
i want to implement the sql query given below in jsp in execute query statement . the query is working in sql but not when implemented using jsp. please help me in resolving this.
Query
SELECT e.Department , e.ETitle , s.basic , s.da, c.address1 , c.address2 from Employee e , Salary s , Contactdetails1 c where e.id = s.id and e.id =c.idIt would help if you gave us a little more info to go on like;
a) post your code
b) post the error message the compiler is giving you -
PL/SQL Anonymous Block - Trying to Call Function within Cursor
Hello -
I need to create an anonymous block that contains a cursor and a function. I want to call the function from within the cursor, and the function will basically take an ID as its IN parameter, and will return a comma separated list of values.
However, when I try to do this I get the error " function 'GET_PAYMENT_DATES' may not be used in SQL".
Does anyone know of a workaround? I'm trying to avoid having to store this function.
Thanks,
ChristineExploring Keith's suggestion of using the function code inline in your SQL:
test@ORA10G>
test@ORA10G> --
test@ORA10G> drop table t;
Table dropped.
test@ORA10G> drop table monetary_trans;
Table dropped.
test@ORA10G>
test@ORA10G> create table monetary_trans as
2 select 1 household_id, trunc(sysdate)-10 received_date from dual union all
3 select 1, trunc(sysdate)-9 from dual union all
4 select 1, trunc(sysdate)-8 from dual union all
5 select 2, trunc(sysdate)-7 from dual union all
6 select 2, trunc(sysdate)-6 from dual;
Table created.
test@ORA10G>
test@ORA10G> create table t as
2 select rownum x, rownum*10 y from dual connect by level <= 4;
Table created.
test@ORA10G>
test@ORA10G> --
test@ORA10G> select * from monetary_trans;
HOUSEHOLD_ID RECEIVED_
1 28-DEC-08
1 29-DEC-08
1 30-DEC-08
2 31-DEC-08
2 01-JAN-09
test@ORA10G> select * from t;
X Y
1 10
2 20
3 30
4 40
test@ORA10G>
test@ORA10G> --
test@ORA10G> -- the function code could be rewritten as follows
test@ORA10G> --
test@ORA10G> select household_id,
2 ltrim(sys_connect_by_path(rd,','),',') payment_dates
3 from
4 (
5 select household_id,
6 to_char(received_date,'mm/dd/yy') as rd,
7 row_number() over (partition by household_id order by 1) rn,
8 count(*) over (partition by household_id) cnt
9 from monetary_trans
10 -- and the constraints here in the where clause
11 )
12 where level = cnt
13 start with rn = 1
14 connect by prior household_id = household_id
15 and prior rn = rn - 1
16 and household_id = 1 -- <== this is the input parameter value
17 ;
HOUSEHOLD_ID PAYMENT_DATES
1 12/28/08,12/29/08,12/30/08
test@ORA10G>
test@ORA10G> --
test@ORA10G> -- and can be used as an inline view when joined with other tables
test@ORA10G> --
test@ORA10G> select t.y,
2 fn.payment_dates
3 from t,
4 (select household_id,
5 ltrim(sys_connect_by_path(rd,','),',') payment_dates
6 from (select household_id,
7 to_char(received_date,'mm/dd/yy') as rd,
8 row_number() over (partition by household_id order by 1) rn,
9 count(*) over (partition by household_id) cnt
10 from monetary_trans)
11 where level = cnt
12 start with rn = 1
13 connect by prior household_id = household_id
14 and prior rn = rn - 1
15 ) fn
16 where t.x = fn.household_id
17 ;
Y PAYMENT_DATES
10 12/28/08,12/29/08,12/30/08
20 12/31/08,01/01/09
test@ORA10G>
test@ORA10G>HTH
isotope -
Re:SQL query with the usage of functions
Hi
on using "select deptno,ename from emp where deptno = 10" we get all the rows one after the other with employees working in dept no 10 as follows
DEPTNO ENAME
10 CLARK
10 KING
10 MILLER
3 rows selected
But how to display the result in the following order :
DEPTNO ENAME
10 clark king miller
Regards,
Satyam Reddy> But how to display the result in the following order
Why? Is this a rendering issue? Then deal with it in the client. Remember that a SQL string can only be 4000 bytes in size. That is it. Any string aggregation function used will break this limit when dealing with many rows.. so why consider a method that WILL fail when there are too many rows?
If this is not a rendering issue, but some weird esoteric issue, then the correct way to do this is using a collection - as a collection does not suffer from a 4000 byte limit.
SQL> create or replace type TStrings as table of varchar2(4000);
2 /
Type created.
SQL> select
2 10 as DEPTNO,
3 cast(
4 multiset( select ename from emp where deptno = 10 )
5 as TSTrings
6 ) as ENAME_LIST
7* from dual;
DEPTNO ENAME_LIST
10 TSTRINGS('CLARK', 'KING', 'MILLER')
SQL> -
SQL query problem using analytical/report function
Hello there,
I am having some problem writing my query. I have this table below:
create table t (priority number,
plannedamount number,
availablepieces number,
material_id varchar2(20))
insert into t values (1, 15, 30, 'A');
insert into t values (2, 20, 30, 'A');
insert into t values (3, 5, 30, 'A');
insert into t values (4, 8, 30, 'A');
insert into t values (5, 4, 30, 'A');
insert into t values (1, 2, 10, 'B'); PRIORITY| PLANNED AMOUNT|AVAILABLE PIECES | MATERIAL_ID
1 15 30 A
2 20 30 A
3 5 30 A
4 8 30 A
5 4 30 A
1 2 30 B .
Each line is a customer order ordering a material. I am grouping by material and ordering it by priority. I want to display a new column called pieces not reserved yet. This column will show that if the order can be fully reserved for that current order ordering by priority.
If the row can be reserved it will substract and bring it to the next row. If it cannot the pieces not reserved will remain the same.
I've tried using sum(), lead(), first(), lag(), etc but I still cannot get the correct result.
PRIORITY| PLANNED AMOUNT|PIECES NOT RESERVED YET | MATERIAL_ID
1 15 30 A
2 20 15 A
3 5 15 A
4 8 10 A
5 4 2 A
1 2 30 B
Can anyone elaborate or have any hints on what method to use to create this column?
Thanks. .
Edited by: 998373 on Apr 5, 2013 11:42 AM
Edited by: 998373 on Apr 5, 2013 11:43 AMFrom 10.x on
with t(PRIORITY, PLANNED_AMOUNT,AVAILABLE_PIECES , MATERIAL_ID) as
select 1, 15, 30, 'A' from dual union all
select 2, 20, 30, 'A' from dual union all
select 3, 5, 30, 'A' from dual union all
select 4, 8, 30, 'A' from dual union all
select 5, 4, 30, 'A' from dual union all
select 1, 2, 30, 'B' from dual
select
MATERIAL_ID
, PRIORITY
, PLANNED_AMOUNT
, AVAILABLE_PIECES PIECES_NOT_RESERVED_YET
from t
model
partition by (material_id)
dimension by (PRIORITY)
measures (
PLANNED_AMOUNT
, AVAILABLE_PIECES
rules (
AVAILABLE_PIECES[priority>1] order by priority=
case when PLANNED_AMOUNT[cv()-1] <= AVAILABLE_PIECES[cv()-1]
then AVAILABLE_PIECES[cv()-1] - PLANNED_AMOUNT[cv()-1]
else AVAILABLE_PIECES[cv()-1]
end
MATERIAL_ID PRIORITY PLANNED_AMOUNT PIECES_NOT_RESERVED_YET
A 1 15 30
A 2 20 15
A 3 5 15
A 4 8 10
A 5 4 2
B 1 2 30 -
Function calling function passing data
We have developed an MQSERIES utility that is a function that calls many related functions and its purpose is to perform a variety of MQSeries functions with minimal interaction required by the user. The user provides the message, an activity code (pd for puts, gd for gets, pr for putting requests for replies, etc.) and a couple other parameters. The user gets back the message, a return flag (good, bad, truncated, etc). . Our MQSERIES function is a function of the calling module. Our function has it's series of includes with classes, functions, etc. The calling program needs a couple includes (to define the passed data areas) and a function prototype of our function (void mqcmd090(typefilefdi &, typefilemsg &, typefilemdi &);) and after the user does string copies and so forth into the passed data areas they currently call the function (mqcmd090(currpassarea, currmessage, currquetable);) After our function is called these passed data areas are manipulated by the user's module. They inquire into the return code, they may do activity (with message ids, etc), they manipulate the message and may send it back (replies, etc). Our dilemma is this. The users want our module to be stand-alone. It should be compiled and linked by itself. Their module should be compiled and linked by itself. They don't mind having a couple includes for the common passed structures but our modules should not be a function in theirs.
How can I compile our function (and how can they call it) so that we can keep the communications going both ways between modules? A system call can't do it because they can send us information but they can't receive information back. If our module needs an upgrade we should just be able to change and recompile ours and their next execution should get the changes.
I am at a loss and would greatly appreciate any assistance on this matter.
Thanks,
Dennis BartizalWe have developed an MQSERIES utility that is a function that calls many related functions and its purpose is to perform a variety of MQSeries functions with minimal interaction required by the user. The user provides the message, an activity code (pd for puts, gd for gets, pr for putting requests for replies, etc.) and a couple other parameters. The user gets back the message, a return flag (good, bad, truncated, etc). . Our MQSERIES function is a function of the calling module. Our function has it's series of includes with classes, functions, etc. The calling program needs a couple includes (to define the passed data areas) and a function prototype of our function (void mqcmd090(typefilefdi &, typefilemsg &, typefilemdi &);) and after the user does string copies and so forth into the passed data areas they currently call the function (mqcmd090(currpassarea, currmessage, currquetable);) After our function is called these passed data areas are manipulated by the user's module. They inquire into the return code, they may do activity (with message ids, etc), they manipulate the message and may send it back (replies, etc). Our dilemma is this. The users want our module to be stand-alone. It should be compiled and linked by itself. Their module should be compiled and linked by itself. They don't mind having a couple includes for the common passed structures but our modules should not be a function in theirs.
How can I compile our function (and how can they call it) so that we can keep the communications going both ways between modules? A system call can't do it because they can send us information but they can't receive information back. If our module needs an upgrade we should just be able to change and recompile ours and their next execution should get the changes.
I am at a loss and would greatly appreciate any assistance on this matter.
Thanks,
Dennis Bartizal -
SQL Query taking longer time as seen from Trace file
Below Query Execution timings:
Any help will be benefitial as its affecting business needs.
SELECT MATERIAL_DETAIL_ID
FROM
GME_MATERIAL_DETAILS WHERE BATCH_ID = :B1 FOR UPDATE OF ACTUAL_QTY NOWAIT
call count cpu elapsed disk query current rows
Parse 1 0.00 0.70 0 0 0 0
Execute 2256 8100.00 24033.51 627 12298 31739 0
Fetch 2256 900.00 949.82 0 12187 0 30547
total 4513 9000.00 24984.03 627 24485 31739 30547
Thanks and RegardsThanks Buddy.
Data Collected from Trace file:
SELECT STEP_CLOSE_DATE
FROM
GME_BATCH_STEPS WHERE BATCH_ID
IN (SELECT
DISTINCT BATCH_ID FROM
GME_MATERIAL_DETAILS START WITH BATCH_ID = :B2 CONNECT BY PRIOR PHANTOM_ID=BATCH_ID)
AND NVL(STEP_CLOSE_DATE, :B1) > :B1
call count cpu elapsed disk query current rows
Parse 1 0.00 0.54 0 0 0 0
Execute 2256 800.00 1120.32 0 0 0 0
Fetch 2256 9100.00 13551.45 396 77718 0 0
total 4513 9900.00 14672.31 396 77718 0 0
Misses in library cache during parse: 0
Optimizer goal: CHOOSE
Parsing user id: 66 (recursive depth: 1)
Rows Row Source Operation
0 TABLE ACCESS BY INDEX ROWID GME_BATCH_STEPS
13160 NESTED LOOPS
6518 VIEW
6518 SORT UNIQUE
53736 CONNECT BY WITH FILTERING
30547 NESTED LOOPS
30547 INDEX RANGE SCAN GME_MATERIAL_DETAILS_U1 (object id 146151)
30547 TABLE ACCESS BY USER ROWID GME_MATERIAL_DETAILS
23189 NESTED LOOPS
53736 BUFFER SORT
53736 CONNECT BY PUMP
23189 TABLE ACCESS BY INDEX ROWID GME_MATERIAL_DETAILS
23189 INDEX RANGE SCAN GME_MATERIAL_DETAILS_U1 (object id 146151)
4386 INDEX RANGE SCAN GME_BATCH_STEPS_U1 (object id 146144)
In the Package there are lots of SQL Statements using CONNECT BY CLAUSE.
Does the use of CONNECT BY Clause degrades performance?
As you can see the Rows Section is 0 but the Query and elapsed time is taking longer
Regards -
SQL Query to Roll up amounts starting from a lower to higher level
with data as (select 'C' Child, 'P' as parent, 11 amount from dual
union all select 'C1', 'C', -2 from dual
union all select 'C2', 'C', 3 from dual
union all select 'C3', 'C', -8 from dual
union all select 'C4', 'C', 10 from dual
union all select 'C11', 'C1', 7 from dual
union all select 'C12', 'C1', 12 from dual
union all select 'C21', 'C2', 5 from dual
union all select 'C22', 'C2', 9 from dual
union all select 'C31', 'C3', 6 from dual
union all select 'C32', 'C3', -4 from dual
union all select 'C41', 'C4', -3 from dual
union all select 'C42', 'C4', 13 from dual
union all select 'C111', 'C11', 16 from dual
union all select 'C121', 'C12', 8 from dual
) Select * from data order by 2
Hi Experts,
I have the following table with parent child relationship which I would like to roll up starting from a lower to a higher level. The catch here is as I move up the level i should replace the amount for a parent with the aggregate value of its children and grand total aggregated amount should be in C
For example; In the given sample data c111 rolls up to c11 as 16 (please note: the amount for c11 is 7 should not be added to 16 rather replaced by 16) which should further roll up to c1.
This means c1 = c11c12; c11 = c111 = 16 so, c1= 1612 instread of 16712.
Since this is a interim table, i do not have any control on how many levels it might contain.
So dynamically, i need a query which would rollup and aggregate the amount from a lower to a higher level moving up from the bottom.
Is this possible? I look forward to all the help. Thanks in advance.SQL> with data as
2 (
3 select 'C' Child, 'P' as parent, 11 amount from dual
4 union all select 'C1', 'C', -2 from dual
5 union all select 'C2', 'C', 3 from dual
6 union all select 'C3', 'C', -8 from dual
7 union all select 'C4', 'C', 10 from dual
8 union all select 'C11', 'C1', 7 from dual
9 union all select 'C12', 'C1', 12 from dual
10 union all select 'C21', 'C2', 5 from dual
11 union all select 'C22', 'C2', 9 from dual
12 union all select 'C31', 'C3', 6 from dual
13 union all select 'C32', 'C3', -4 from dual
14 union all select 'C41', 'C4', -3 from dual
15 union all select 'C42', 'C4', 13 from dual
16 union all select 'C111', 'C11', 16 from dual
17 union all select 'C121', 'C12', 8 from dual
18 )
19 , data1
20 as
21 (
22 select parent
23 , child
24 , lpad('-', (level-1)*3, '-') || parent tree_structure
25 , amount
26 , case when connect_by_isleaf = 1 then amount else 0 end amount_leaf
27 from data
28 start with parent = 'P'
29 connect
30 by parent = prior child
31 )
32 select parent as node
33 , tree_structure
34 , amount_sum
35 from data1
36 model
37 dimension by
38 (
39 child
40 , parent
41 )
42 measures
43 (
44 amount_leaf as amount
45 , tree_structure
46 , 0 amount_sum
47 )
48 rules automatic order
49 (
50 amount_sum[any,any]= amount[cv(),cv()] + nvl(sum(amount_sum)[any, cv(child)],0)
51 );
NOD TREE_STRUCTURE AMOUNT_SUM
P P 50
C ---C 24
C1 ------C1 16
C11 ---------C11 16
C1 ------C1 8
C12 ---------C12 8
C ---C 14
C2 ------C2 5
C2 ------C2 9
C ---C 2
C3 ------C3 6
C3 ------C3 -4
C ---C 10
C4 ------C4 -3
C4 ------C4 13
15 rows selected. -
SQl Query to Calculate No of Days from LastDate and PreviousDate
Hi All,
Below is a sample table which holds the rent updates done for properties at any point of time.
I like the query to show the out put as
Prop_Code, PreviousRent, PreviousRentUpdateDate, LastRent, LastRentUpdateDate NoofDays
1008 206.38 2014-06-16
209.04 2014-12-22 189
DECLARE @table TABLE
( Prop_Code INT
,Current_Rent INT
,Revised_Rent INT
,Rent_Review_Date varchar(10)
,Rent_Review_Time DATEtime)
INSERT INTO @table (PROP_CODE,Current_Rent,Revised_Rent,Rent_Review_Date,Rent_Review_Time) VALUES
(2977,372,339.15,'2013-07-08','7:44')
,(2977,372,339.15,'2013-07-03','11:01')
,(2977,372,372,'2014-06-30','9:07')
,(2977,372,372,'2014-07-07','11:06')
,(2981,372,372,'2014-07-07','11:06')
,(2981,372,340.15,'2013-07-08','7:23')
,(2981,372,314.15,'2013-07-08','7:44')
,(2981,372,340.15,'2013-07-29','7:16')
,(3089,205.63,400,'2014-10-27','8:38')
,(3089,205.63,205.63,'2014-02-03','8:29')
,(3089,205.63,127.64,'2014-01-20','0:52')
,(3089,205.63,123.02,'2013-08-12','8:28')
,(3089,205.63,205.63,'2014-12-15','8:46')
,(3109,252.62,198,'2014-01-20','0:52')
,(3109,252.62,252.62,'2014-04-07','8:30')
,(3109,252.62,198,'2013-08-12','8:28')
,(3117,284.96,336,'2014-04-21','1:03')
,(3125,267.53,267.53,'2014-02-03','8:29')
,1008, 181.32, '2013-03-19, '04:41')
,(1008 , 186.15, '2013-03-19, '04:41')
,(1008 , 187.62, '2013-03-19, '04:41')
,(1008, 191.07, '2013-03-19, '04:41')
,(1008, 202.33, '2013-08-12', '08:28')
,(1008, 202.53, '2013-11-25', '08:33')
,(1008, 206.38, '2014-06-16', '09:38')
,(1008, 209.04, '2014-12-22', '07:55')
Select * from @table
Regards,
JagINSERT statement had error and incorrect data. I changed it
Rent column had INT data type and I changed it to Money.
DECLARE @table TABLE
( Prop_Code INT
,Current_Rent Money
,Revised_Rent Money
,Rent_Review_Date varchar(10)
,Rent_Review_Time DATEtime)
INSERT INTO @table (PROP_CODE,Current_Rent,Revised_Rent,Rent_Review_Date,Rent_Review_Time) VALUES
(2977,372,339.15,'2013-07-08','7:44')
,(2977,372,339.15,'2013-07-03','11:01')
,(2977,372,372,'2014-06-30','9:07')
,(2977,372,372,'2014-07-07','11:06')
,(2981,372,372,'2014-07-07','11:06')
,(2981,372,340.15,'2013-07-08','7:23')
,(2981,372,314.15,'2013-07-08','7:44')
,(2981,372,340.15,'2013-07-29','7:16')
,(3089,205.63,400,'2014-10-27','8:38')
,(3089,205.63,205.63,'2014-02-03','8:29')
,(3089,205.63,127.64,'2014-01-20','0:52')
,(3089,205.63,123.02,'2013-08-12','8:28')
,(3089,205.63,205.63,'2014-12-15','8:46')
,(3109,252.62,198,'2014-01-20','0:52')
,(3109,252.62,252.62,'2014-04-07','8:30')
,(3109,252.62,198,'2013-08-12','8:28')
,(3117,284.96,336,'2014-04-21','1:03')
,(3125,267.53,267.53,'2014-02-03','8:29')
,(1008, NULL ,181.32, '2013-03-19', '04:41')
,(1008 , NULL , 186.15, '2013-03-19', '04:41')
,(1008 ,NULL , 187.62, '2013-03-19', '04:41')
,(1008, NULL , 191.07, '2013-03-19', '04:41')
,(1008, NULL , 202.33, '2013-08-12', '08:28')
,(1008, NULL , 202.53, '2013-11-25', '08:33')
,(1008, NULL , 206.38, '2014-06-16', '09:38')
,(1008, NULL , 209.04, '2014-12-22', '07:55')
WITH TempCTE
AS (
SELECT *
,ROW_NUMBER() OVER (
PARTITION BY Prop_Code ORDER BY Rent_Review_Date DESC
) RowNum
FROM @table
SELECT a.Prop_Code
,a.Revised_Rent
,a.Rent_Review_Date
,b.Revised_Rent
,b.Rent_Review_Date
,DATEDIFF(Day, a.Rent_Review_Date, b.Rent_Review_Date)
FROM TempCTE a
INNER JOIN TempCTE b ON a.Prop_Code = b.Prop_Code
AND a.RowNum = b.RowNum + 1
WHERE b.RowNum = 1
-Vaibhav Chaudhari -
My sql query is taking hours to run from toad
SELECT * from (select hr.NAME org_name, ractla.org_id, acct_site.attribute_category,
acct_site.attribute10 general_agent, arc.reversal_category,arr.reversal_gl_date,ard.reversed_source_id,
DECODE (acct_site.attribute_category,
'COMM', acct_site.attribute9,
'IPLAN', acct_site.attribute11,
NULL
) broker_number, -- changed by Michelle
SUBSTR (hca.account_number, 1, 12) customer_number,
ractla.attribute3 plan_type,
SUBSTR (hp.party_name, 1, 15) customer_name,
DECODE (ractla.attribute_category,
'Commercial Receivables', ractla.attribute1,
'Subscriber Receivables', ractla.attribute1,
NULL
) product, --x Product
rax.trx_number trx_number, rax.trx_date transaction_date,
DECODE
(SIGN (INSTR (rax.attribute4, '/')),
1, TO_DATE
( '01'
|| TO_CHAR
(DECODE (SIGN (INSTR (rax.attribute4, '/')),
1, TO_DATE
(SUBSTR (rax.attribute4,
1,
10
'rrrr/mm/dd'
NULL
'MON-RRRR'
'DD-MON-RRRR'
NULL
) coverage_month,
DECODE (SIGN (INSTR (rax.attribute4, '/')),
1, TO_DATE (SUBSTR (rax.attribute4, 1, 10), 'rrrr/mm/dd'),
NULL
) due_date,
DECODE (acct_site.attribute_category,
'COMM', SUBSTR (hca.account_number, 1, 6),
acct_site.attribute10
) employer_group,
DECODE (arc.reversal_category,
'NSF', TRUNC (arr.creation_date),
'REV', TRUNC (arr.creation_date),
DECODE (arr.reversal_gl_date,
NULL, TRUNC (arr.apply_date),
DECODE (ard.reversed_source_id,
NULL, TRUNC (arr.apply_date),
TRUNC (arr.creation_date)
) as application_date,
arr.apply_date,
arr.creation_date, --9/8/03
arc.receipt_number receipt_number, arc.receipt_date receipt_date,
arr.amount_applied applied_amount, rax.attribute1 company,
rax.attribute2 division, ractla.attribute2 coverage_plan, -- (Plan Code)
DECODE (acct_site.attribute_category,
'IPLAN', acct_site.attribute13,
'SH', acct_site.attribute8,
NULL
) coverage_type,
ps.amount_due_original trans_amount,
NVL (ps.amount_due_remaining, 0) trans_amount_remaining,
SUBSTR (hre.first_name || ' ' || hre.middle_name || ' '
|| hre.last_name,
1,
25
) salesrep_name,
SUBSTR (acct_site.attribute5, 1, 5) salesrep_extension,
hca.attribute4 SOURCE
FROM apps.ra_customer_trx_all rax, -- invoice info
apps.ar_payment_schedules_all ps,
apps.ra_cust_trx_types_all rat,
apps.hz_cust_accounts_all hca,
apps.hz_parties hp,
apps.ar_receivable_applications_all arr,
apps.ar_cash_receipts_all arc, --- receipt info
apps.hr_operating_units hr,
apps.hr_employees hre,
apps.hz_cust_acct_sites_all acct_site,
apps.hz_cust_site_uses_all acct_site_use, --added by tapas on 7/16
apps.ra_customer_trx_lines_all ractla,
apps.ar_distributions_all ard
WHERE
hca.cust_account_id = rax.bill_to_customer_id
AND ps.customer_trx_id = rax.customer_trx_id
AND rat.cust_trx_type_id = rax.cust_trx_type_id
AND rat.org_id = rax.org_id
AND arr.applied_customer_trx_id = rax.customer_trx_id
AND arr.status = 'APP'
AND arr.cash_receipt_id = arc.cash_receipt_id
AND hr.organization_id = rax.org_id
AND rax.customer_trx_id = ractla.customer_trx_id
AND ractla.line_number = 1
AND rax.bill_to_site_use_id = acct_site_use.site_use_id
AND hca.cust_account_id = acct_site.cust_account_id
AND acct_site.cust_acct_site_id = acct_site_use.cust_acct_site_id
AND hca.party_id = hp.party_id
AND acct_site.attribute4 = hre.employee_id(+)
AND hr.NAME = 'Commercial Group'
AND ard.source_table = 'RA'
AND ard.source_id = arr.receivable_application_id) app
where app.application_date between :start_date and :end_Date
and app.application_date <> app.apply_date
and app.applied_amount>0;
This is my query..due to some requirement i have written an inline view. The query is getting executed without inline view and even after including inline view but when i included the condition "app.applied_amount>0" its taking hours and i dont see it complete. Please advise. Urgently needed as a discoverer report needs to be built based on this.
Thanks.
Edited by: 958913 on Oct 8, 2012 3:52 PM
Edited by: 958913 on Oct 8, 2012 4:19 PM
Edited by: 958913 on Oct 8, 2012 4:33 PMHi,
the next action plan i have taken is as i need to write a condition that is based on application date(which is not a database column and is getting by a decode statement in the select) i have removed that decode statement from select and written in inline view and there by adding in where condition. Here is the query and still its taking time to run.
/* Formatted on 2012/10/09 13:51 (Formatter Plus v4.8.8) */
SELECT hr.NAME org_name, ractla.org_id, acct_site.attribute_category,
acct_site.attribute10 general_agent, arc.reversal_category,
arr.reversal_gl_date, ard.reversed_source_id,
DECODE (acct_site.attribute_category,
'COMM', acct_site.attribute9,
'IPLAN', acct_site.attribute11,
NULL
) broker_number, -- changed by Michelle
SUBSTR (hca.account_number, 1, 12) customer_number,
ractla.attribute3 plan_type,
SUBSTR (hp.party_name, 1, 15) customer_name,
DECODE (ractla.attribute_category,
'Commercial Receivables', ractla.attribute1,
'Subscriber Receivables', ractla.attribute1,
NULL
) product, --x Product
rax.trx_number trx_number, rax.trx_date transaction_date,
DECODE
(SIGN (INSTR (rax.attribute4, '/')),
1, TO_DATE ( '01'
|| TO_CHAR (DECODE (SIGN (INSTR (rax.attribute4, '/')),
1, TO_DATE
(SUBSTR (rax.attribute4,
1,
10
'rrrr/mm/dd'
NULL
'MON-RRRR'
'DD-MON-RRRR'
NULL
) coverage_month,
DECODE (SIGN (INSTR (rax.attribute4, '/')),
1, TO_DATE (SUBSTR (rax.attribute4, 1, 10), 'rrrr/mm/dd'),
NULL
) due_date,
DECODE (acct_site.attribute_category,
'COMM', SUBSTR (hca.account_number, 1, 6),
acct_site.attribute10
) employer_group,
app.application_date,
arr.apply_date, arr.creation_date, --9/8/03
arc.receipt_number receipt_number,
arc.receipt_date receipt_date, arr.amount_applied applied_amount,
rax.attribute1 company, rax.attribute2 division,
ractla.attribute2 coverage_plan, -- (Plan Code)
DECODE (acct_site.attribute_category,
'IPLAN', acct_site.attribute13,
'SH', acct_site.attribute8,
NULL
) coverage_type,
ps.amount_due_original trans_amount,
NVL (ps.amount_due_remaining, 0) trans_amount_remaining,
SUBSTR (hre.first_name || ' ' || hre.middle_name || ' '
|| hre.last_name,
1,
25
) salesrep_name,
SUBSTR (acct_site.attribute5, 1, 5) salesrep_extension,
hca.attribute4 SOURCE
FROM apps.ra_customer_trx_all rax, -- invoice info
apps.ar_payment_schedules_all ps,
apps.ra_cust_trx_types_all rat,
apps.hz_cust_accounts_all hca,
apps.hz_parties hp,
apps.ar_receivable_applications_all arr,
apps.ar_cash_receipts_all arc, --- receipt info
apps.hr_operating_units hr,
apps.hr_employees hre,
apps.hz_cust_acct_sites_all acct_site,
apps.hz_cust_site_uses_all acct_site_use, --added by tapas on 7/16
apps.ra_customer_trx_lines_all ractla,
apps.ar_distributions_all ard,
(select rax1.customer_trx_id,DECODE (arc1.reversal_category,
'NSF', TRUNC (arr1.creation_date),
'REV', TRUNC (arr1.creation_date),
DECODE (arr1.reversal_gl_date,
NULL, TRUNC (arr1.apply_date),
DECODE (ard1.reversed_source_id,
NULL, TRUNC (arr1.apply_date),
TRUNC (arr1.creation_date)
) as application_date
from apps.ar_receivable_applications_all arr1,
apps.ar_cash_receipts_all arc1,
apps.ra_customer_trx_all rax1,
apps.ar_distributions_all ard1
where arr1.applied_customer_trx_id = rax1.customer_trx_id
AND arr1.status = 'APP'
AND arr1.cash_receipt_id = arc1.cash_receipt_id
AND ard1.source_table = 'RA'
AND ard1.source_id = arr1.receivable_application_id
) app
WHERE hca.cust_account_id = rax.bill_to_customer_id
AND app.customer_trx_id = rax.customer_trx_id
AND arr.apply_date <> app.application_date
and app.application_date between :start_date and :end_date
--AND rax.trx_number IN ('52715888', '52689753')
AND ps.customer_trx_id = rax.customer_trx_id
AND rat.cust_trx_type_id = rax.cust_trx_type_id
AND rat.org_id = rax.org_id
AND arr.applied_customer_trx_id = rax.customer_trx_id
AND arr.status = 'APP'
AND arr.cash_receipt_id = arc.cash_receipt_id
AND hr.organization_id = rax.org_id
AND rax.customer_trx_id = ractla.customer_trx_id
AND ractla.line_number = 1
AND rax.bill_to_site_use_id = acct_site_use.site_use_id
AND hca.cust_account_id = acct_site.cust_account_id
AND acct_site.cust_acct_site_id = acct_site_use.cust_acct_site_id
AND hca.party_id = hp.party_id
AND acct_site.attribute4 = hre.employee_id(+)
AND hr.NAME = 'Commercial Group'
AND ard.source_table = 'RA'
AND ard.source_id = arr.receivable_application_id -
Using the Query Partitioning Technique for calling reports from forms.
Hello everyone,
I am having problems using the Query partitioning technique which does not work (??) on the web environment. It seems like you are currently using it. However, I'm not sure whether you have tried this on the web environment. Anyway, see if you can help me please.
I am populating a record group using data from a form and then pass it as a data parameter to report.
I use the following codes:
Add_Parameter(list_id,'Q_1',DATA_PARAMETER,rg_name); /* rg_name is my record group */
repid := find_report_object('myrep');
v_rep := RUN_REPORT_OBJECT(repid, list_id); /* list_id is my parameter list */
In client-server mode, I set the report destination type to preview and it works fine. Data from the record group are displayed in the report.
To run it on the web environment, I use the following properties:
Report destination type: cache
Report server: repserver
I get no output and the Reports Queue Manager shows the following:
Description:
Name: /test/pfs/kn/rep/kn211rp0.rdf
Owner: dev6
Destination: Cache Only
Destination Name:
Status:
Current status: [Repserver] Terminated with Error
REP-0076: Internal failure in product integration.
Thank you again for a reply
Kind Regards
Yogeeraj Degambur
PS. I am working on the HP-UX environment. Versions: Dev6i patch 5a, Oracle 8.0.5hello,
check the whitepaper "Oracle9iAS Forms Services 6i and Reports Integration" which can be found on otn.oracle.com/products/forms
regards,
the oracle reports team
Maybe you are looking for
-
Atualização do LG Fireweb?...
Olá caros usuários do LG Fireweb, Recentemente venho notado a preocupação de muitos perante a atualização do aparelho LG D300. Eu também estou preocupado, pois já tem um ano que estou com o mesmo aparelho e a mesma versão. Pesquisei em vários sites c
-
Hi, true experts... Just got my BB Curve 8330 last week, and I'm having fun. But after having explored BB App World from my Curve one time, I can't get into it again. I keep getting this error message: "Error starting net_rim_bb_appworld; Symbol
-
Exception Condition "Fatal_Error" Raised in SMQ2
Hi, I am doing File to Proxy(ECC) Asynchronous scenario. in this getting the error in Target side(ECC) in SMQ2 message is showing error , when I double click on this error getting the error message like Exception Condition "Fatal_Error" Raised. Beca
-
Issue with PO output types.
Hi All, Please note that for the STOs with document type NB the same PO output has been processed twice with out any manual intervention (with some time gap). The first output idoc has been processed successfully and the second one went into error. P
-
Oracle OpenWorld and Ops Center 12c
When I was at Oracle OpenWorld two weeks ago, I could have sworn the Ops Center booth was running an unreleased version of Ops Center (to be 12c). If that is the case, what is the estimated release date of this product? And will it be like Oracle Ent