SELECT Statement question
Hi ABAP Gurus,
I have the following code.
DATA: BEGIN OF i_p0000 OCCURS 0,
pernr LIKE pa0000-pernr,
begda LIKE pa0000-begda,
endda LIKE pa0000-endda.
DATA: END OF i_p0000.
DATA: v_date_from TYPE d,
v_date_to TYPE d.
DATA: BEGIN OF PERNRZ_TAB occurs 0,
PERNR(8) TYPE N,
END OF PERNRZ_TAB.
RANGES: l_r_pernr FOR pa0000-pernr, "personnel number
SELECT PERNRZ1 FROM ZTESTHR1 INTO table PERNRZ_TAB
WHERE BEGDAZ1
BETWEEN v_date_from AND v_date_to.
OPEN CURSOR WITH HOLD s_cursor FOR
SELECT pernr
begda
endda
FROM pa0000
WHERE pernr IN l_r_pernr.
Fetch records into interface table.
FETCH NEXT CURSOR s_cursor
APPENDING CORRESPONDING FIELDS
OF TABLE i_p0000
PACKAGE SIZE s_s_if-maxsize.
IF sy-subrc <> 0.
CLOSE CURSOR s_cursor.
RAISE no_more_data.
ELSE.
SORT i_p0000 BY pernr.
I would like to retrieve records based on the values in PERNRZ_TAB. When I make the following change I am getting an error.
SELECT pernr
begda
endda
FROM pa0000
WHERE pernr IN PERNRZ_TAB.
Thanks in advance.
Regards,
bw_newbie
SELECT pernr
begda
endda
<b>into table IT_PA0000</b>
FROM pa0000
<b>for all entries in PERNRZ_TAB
WHERE pernr = PERNRZ_TAB-PERNR.</b>
if you want to retrieve records from table for all the entries in any Internal table, you should use FOR ALL ENTRIES addition of SELECT statement.
this fetch may have more than 1 record, so you should give the INTO TABLE addition also.
define IT_PA000 internal table with pernr
begda
endda fields.
Check this.
Regards
srikanth
Message was edited by: Srikanth Kidambi
Similar Messages
-
Hi quick select statement question!
Hi Everyone,
I'm new to the board and somewhat new to sql too. So I have a small problem that I hope someone can help me with.
DATA
Name: time1 time2
Jack 1 2
Jack 2 3
Jack 3 4
Jack 8 9
Jane 3 4
I'd like to get a table that combines all the continuous times for each person so that it looks like this:
Jack 1 4
Jack 8 9
Jane 3 4
I'm desperate, and I appreciate it any help! Thanks!sql>select * from t;
NAME T1 T2
Jack 1 2
Jack 2 3
Jack 3 4
Jack 8 9
Jane 8 9
sql>
select name,min(t1) t1,max(t2) t2
from(
select name,t1,t2,sum(flg) over(order by rownum) sm
from(
select name,t1,t2,
decode(lead(t1) over(partition by name order by t1),t2,0,
decode(lag(t2) over(partition by name order by t1),t1,0,1)) flg
from t))
group by name,sm;
NAME T1 T2
Jack 1 4
Jack 8 9
Jane 8 9 -
Questions on select statement in the data model
Hi,
In the select statement, the order by statement seems only to work at the lowest level of the select statement. Is this true?
What is the the purpose of the group by statement in the select statement?
As far as I understand, the grouping is catered for in the data model.....
Regards,
KinFrom the oracle report docs:
The order of column values in a default group is
determined by the ORDER BY clause of the query for
SQL queries and by the sort column for Express queries.
For column values in user-created groups, however, you
must use Break Order to specify how to order the break
column's values.So order by in your sql query is affected by groups in your data model.
The purpose of a group by statement in your select statement is to group values for aggregation purposes, like
select department_id,
min(salary),
max (salary)
from employees
group
by department_id
order
by department_id;Grouping in the data model of a report is a little different than a group by clause, but not entirely. -
Issue with Select options in select statement - ABAP Question
Hi
I am facing an issue with select options. Select statement is returning sy-subrc as 4.
I wrote the program as below:
SELECT-OPTIONS:
s_kunnr FOR bsad-kunnr,
s_lifnr FOR bsak-lifnr,
s_gjahr FOR bsad-gjahr,
s_bukrs FOR bsad-bukrs,
s_saknr FOR bsad-saknr,
s_budat FOR bsak-budat.
In start of selection I have written the select statement as
SELECT * FROM bsak INTO TABLE lt_bsak
WHERE bukrs IN s_bukrs AND lifnr = s_lifnr AND gjahr IN s_gjahr AND budat IN s_budat AND saknr IN s_saknr.
In selection screen I have not entered any values and executed the program. I am not getting any result. When I debug that, sy-subrc is 4 at above select statement. But table has records.
If am removing the "lifnr = s_lifnr " condition in select then select is returning values.
I am not getting where I made the mistake. Please suggest.
Thank you
HanuHi,
The problem here with where condition select option lifnr = s_lifnr.
Use below select query.
SELECT * FROM bsak INTO TABLE lt_bsak
WHERE bukrs IN s_bukrs
AND lifnr IN s_lifnr
AND gjahr IN s_gjahr
AND budat IN s_budat
AND saknr IN s_saknr.
s_lifnr is a select option and you are passing it as parameter lifnr = s_lifnr.
if you want to pass this s_lifnr as single vale then pass in below mentioned way.
lifnr = s_lifnr-low
BR,
Vijay -
How to find the number of fetched lines from select statement
Hi Experts,
Can you tell me how to find the number of fetched lines from select statements..
and one more thing is can you tell me how to check the written select statement or written statement is correct or not????
Thanks in advance
santoshHi,
Look for the system field SY_TABIX. That will contain the number of records which have been put into an internal table through a select statement.
For ex:
data: itab type mara occurs 0 with header line.
Select * from mara into table itab.
Write: Sy-tabix.
This will give you the number of entries that has been selected.
I am not sure what you mean by the second question. If you can let me know what you need then we might have a solution.
Hope this helps,
Sudhi
Message was edited by:
Sudhindra Chandrashekar -
Secondary Index Select Statement Problem
Hi friends.
I have a issue with a select statement using secondary index,
SELECT SINGLE * FROM VEKP WHERE VEGR4 EQ STAGE_DOCK
AND VEGR5 NE SPACE
AND WERKS EQ PLANT
%_HINTS ORACLE
'INDEX("&TABLE&" "VEKP~Z3" "VEKP^Z3" "VEKP_____Z3")'.
given above statement is taking long time for processing.
when i check for the same secondary index in vekp table i couldn't see any DB index name with vekp~z3 or vekp^z3 or vekp____z3.
And the sy-subrc value after select statement is 4. (even though values avaliable in VEKP with given where condition values)
My question is why my select statement is taking long time and sy-subrc is 4?
what happens if a secnodary index given in select statement, which is not avaliable in that DB Table?Hi,
> ONe more question: is it possible to give more than one index name in select statement.
yes you can:
read the documentation:
http://download.oracle.com/docs/cd/A97630_01/server.920/a96533/hintsref.htm#5156
index_hint:
This hint can optionally specify one or more indexes:
- If this hint specifies a single available index, then the optimizer performs
a scan on this index. The optimizer does not consider a full table scan or
a scan on another index on the table.
- If this hint specifies a list of available indexes, then the optimizer
considers the cost of a scan on each index in the list and then performs
the index scan with the lowest cost. The optimizer can also choose to
scan multiple indexes from this list and merge the results, if such an
access path has the lowest cost. The optimizer does not consider a full
table scan or a scan on an index not listed in the hint.
- If this hint specifies no indexes, then the optimizer considers the
cost of a scan on each available index on the table and then performs
the index scan with the lowest cost. The optimizer can also choose to
scan multiple indexes and merge the results, if such an access path
has the lowest cost. The optimizer does not consider a full table scan.
Kind regards,
Hermann -
Can we use is null in our select statement in ABAP program
hi,
I want to use 'is nul' or 'not null' in select statement of my ABAP program for any field. I have written below query but I am getting sy-subrc = 4 and getting no data. Can anyone resolve this.Hi,
I think you've posted your question on the wrong forum. This is the SAP Business One development forum which is not part of ERP and doesn't include any ABAP or Netweaver programming.
For a list of forums please see here:
http://forums.sdn.sap.com/index.jspa
Kind Regards,
Owen -
Using if the else logic in regards to a select statement for a report
Hi all,
I've a question regarding if then else logic in Oracle.
I'm developing a report application which contains 3 selectlists
- ProductGroup - SubGroup - Manufacturer
Each one containing several values. And are based on eachother, meaning if you select an item from the PG list, you only get the SG items regarding the PG item you've choosen before. The process logic should be as the following:
When a user selects one item from for example the PG list, the query will be:
select * from x where PG = :P_PG
and the report displays all the items in the PG category selected
The other two bindvariables would be null as the user didn't pick them
If he then proceeds and selects one item from the SG list, the query would be:
select * from x where PG = :P_PG and SG = :P_SG
and the report displays all the items in the PG and SG category selected
If he then proceeds and selects one item from the MA list, the query would be:
select * from x where PG = :P_PG and SG = :P_SG and MA =:P_MA
and the report displays all the items in the PG and SG and MA category selected
Now, I've read some documentation about the decode function, but I can't figure it out, please help.
PeterOkay, Chet, have set it up on htmldb, so you can see my problem, will go in high detail, it is not producing what I want. Example on htmldb:
DEMO/test
http://htmldb.oracle.com/pls/otn/f?p=33229:6
Defenitions:
3 LOV's, namely:
- LOVPG - select distinct productgroep, productgroep pg from plijst
- LOVSG - select distinct subgroep, subgroep sg from plijst where productgroep = :P6_LOVPG
- LOVLE- select distinct leverancier, leverancier le from plijst where productgroep = :P6_LOVPG and subgroep = :P6_LOVSG
3 Selectitems with submit, namely:
- :P6_LOVPG
- :P6_LOVSG
- :P6_LOVLE
Report region select statement:
select * from plijst where (productgroep = :P6_LOVPG or :P6_LOVPG IS NULL) and (subgroep = :P6_LOVSG or :P6_LOVSG IS NULL) and (leverancier = :P6_LOVLE or :P6_LOVLE IS NULL)
Branch to:
Branche to page on submit after processing
What it should do is:
When you select an item from the first selectlist, productgroep, the report should show all rows containing the specified productgroep.
When the user selects the next item in the subgroep selectlist, the report should show all rows containing the previously selected prodctgroup and the just selected subgroep.
When the user selects the final item , the report should show all rows based on all three selected itemvalues, productgroep, subgroep, leverancier.
The problem is that with this setup the report is only generated after the final selectlist choice of the user. But the user should see a report before that, going deeper into the structure. Hope, you see my problem?
Sincerely,
Pete -
HTML DB Select Statement in HTML HEADER
Can I put a select statement that return a value in the HTML HEADER?
If I can How? Would point the way.
Second Question
Can I call store function from HTML HEADER? Help!I have a report screen that has Delete button. Each record on the screen has a checkbox
What I would like to do is:
when the user puts a check in the checkbox and click the Delete button. a message will pop up and ask "Are you usre?" If the user click Yes then the system will check for child record. If there no No child record go head delete the record. If there is a child record then another message pop up and ask "This Schedule is currently active. Do you really want to delete this." If the user answers Yes then it will delete both parent and child records. If the user answer no then no record will be deleted.
I have been struggle with this in HTML DB for a bit, but I did not find the solution yet. Please Help!!!! -
How to get the value from a function using a select statement
I have a function(user defined not built in) that returns multiple values(like an array). My question is how do i get those values in a select statement. when i tried to retrieve it,
select pack.my_members from dual;
i am getting an error
ORA-00902: invalid datatype
I am sure this must be a syntax error with the select statement
The following is the function that give the array of data
package pack
package spec
Type my_table is table of varchar2(25);
function the_members
return pack.my_table;
pakcage body
function the_members return pack.my_table
Remarks: This function returns a table containing names of the
members
is
tm pack.my_table:= pack.my_table('first member','second member','third member','fourth member');
begin
return tm;
end the_members;Check this example on Pipelinedfunction
-
Problem with Select Statements
Hi All,
I have a performance problem for my report because of the following statements.
How can i modify the select statements for improving the performance of the report.
DATA : shkzg1h LIKE bsad-shkzg,
shkzg1s LIKE bsad-shkzg,
shkzg2h LIKE bsad-shkzg,
shkzg2s LIKE bsad-shkzg,
shkzg1hu LIKE bsad-shkzg,
shkzg1su LIKE bsad-shkzg,
shkzg2hu LIKE bsad-shkzg,
shkzg2su LIKE bsad-shkzg,
kopbal1s LIKE bsad-dmbtr,
kopbal2s LIKE bsad-dmbtr,
kopbal1h LIKE bsad-dmbtr,
kopbal2h LIKE bsad-dmbtr,
kopbal1su LIKE bsad-dmbtr,
kopbal2su LIKE bsad-dmbtr,
kopbal1hu LIKE bsad-dmbtr,
kopbal2hu LIKE bsad-dmbtr.
*These statements are in LOOP.
SELECT shkzg SUM( dmbtr )
INTO (shkzg1s , kopbal1s)
FROM bsid
WHERE bukrs = ibukrs
AND kunnr = ktab-kunnr
AND budat < idate-low
AND shkzg = 'S'
AND umskz EQ ''
GROUP BY shkzg.
ENDSELECT.
SELECT shkzg SUM( dmbtr )
INTO (shkzg1su , kopbal1su)
FROM bsid
WHERE bukrs = ibukrs
AND kunnr = ktab-kunnr
AND budat < idate-low
AND shkzg = 'S'
AND umskz IN zspgl
GROUP BY shkzg.
ENDSELECT.
SELECT shkzg SUM( dmbtr )
INTO (shkzg1h , kopbal1h)
FROM bsid
WHERE bukrs = ibukrs
AND kunnr = ktab-kunnr
AND budat < idate-low
AND shkzg = 'H'
AND umskz EQ ''
GROUP BY shkzg.
ENDSELECT.
SELECT shkzg SUM( dmbtr )
INTO (shkzg1hu , kopbal1hu)
FROM bsid
WHERE bukrs = ibukrs
AND kunnr = ktab-kunnr
AND budat < idate-low
AND shkzg = 'H'
AND umskz IN zspgl
GROUP BY shkzg.
ENDSELECT.
SELECT shkzg SUM( dmbtr )
INTO (shkzg2s , kopbal2s)
FROM bsad
WHERE bukrs = ibukrs
AND kunnr = ktab-kunnr
AND budat < idate-low
AND shkzg = 'S'
AND umskz EQ ''
GROUP BY shkzg.
ENDSELECT.
SELECT shkzg SUM( dmbtr )
INTO (shkzg2su , kopbal2su)
FROM bsad
WHERE bukrs = ibukrs
AND kunnr = ktab-kunnr
AND budat < idate-low
AND shkzg = 'S'
AND umskz IN zspgl
GROUP BY shkzg.
ENDSELECT.
SELECT shkzg SUM( dmbtr )
INTO (shkzg2h , kopbal2h)
FROM bsad
WHERE bukrs = ibukrs
AND kunnr = ktab-kunnr
AND budat < idate-low
AND shkzg = 'H'
AND umskz EQ ''
GROUP BY shkzg.
ENDSELECT.
SELECT shkzg SUM( dmbtr )
INTO (shkzg2hu , kopbal2hu)
FROM bsad
WHERE bukrs = ibukrs
AND kunnr = ktab-kunnr
AND budat < idate-low
AND shkzg = 'H'
AND umskz IN zspgl
GROUP BY shkzg.
ENDSELECT.>
Siegfried Boes wrote:
> Please stop writing answers if you understrand nothing about database SELECTS!
> All above recommendations are pure nonsense!
>
> As always with such questions, you must do an analysis before you ask! The coding itself is perfectly o.k., a SELECT with an aggregate and a GROUP BY can not be changed into a SELECT SINGLE or whatever.
>
> But your SELECTS mustr be supported by indexes!
>
> Please run SQL Trace, and tell us the results:
>
> I see 8 statements, what is the duration and the number of records coming back for each statement?
> Maybe only one statement is slow.
>
> See
> SQL trace:
> /people/siegfried.boes/blog/2007/09/05/the-sql-trace-st05-150-quick-and-easy
>
>
> Siegfried
Nice point there Siegfried. Instead of giving constructive suggestion, people here give a very bad suggestion on using SELECT SINGLE combined with SUM and GROUP BY.
I hope the person already look at your reply before he try using select single and wondering why he has error.
Anyway, the most important thing is how many loop expected for those select statements?
If you have like thousands of loop, you can expect a poor performance.
So, you should also look at how many times the select statement is called and not only performance for each select statement when you're doing SQL trace.
Regards,
Abraham -
Bind Variable in SELECT statement and get the value in PL/SQL block
Hi All,
I would like pass bind variable in SELECT statement and get the value of the column in Dynamic SQL
Please seee below
I want to get the below value
Expected result:
select distinct empno ,pr.dept from emp pr, dept ps where ps.dept like '%IT' and pr.empno =100
100, HR
select distinct ename ,pr.dept from emp pr, dept ps where ps.dept like '%IT' and pr.empno =100
TEST, HR
select distinct loc ,pr.dept from emp pr, dept ps where ps.dept like '%IT' and pr.empno =100
NYC, HR
Using the below block I am getting column names only not the value of the column. I need to pass that value(TEST,NYC..) into l_col_val variable
Please suggest
----- TABLE LIST
CREATE TABLE EMP(
EMPNO NUMBER,
ENAME VARCHAR2(255),
DEPT VARCHAR2(255),
LOC VARCHAR2(255)
INSERT INTO EMP (EMPNO,ENAME,DEPT,LOC) VALUES (100,'TEST','HR','NYC');
INSERT INTO EMP (EMPNO,ENAME,DEPT,LOC) VALUES (200,'TEST1','IT','NYC');
INSERT INTO EMP (EMPNO,ENAME,DEPT,LOC) VALUES (300,'TEST2','MR','NYC');
INSERT INTO EMP (EMPNO,ENAME,DEPT,LOC) VALUES (400,'TEST3','HR','DTR');
INSERT INTO EMP (EMPNO,ENAME,DEPT,LOC) VALUES (500,'TEST4','HR','DAL');
INSERT INTO EMP (EMPNO,ENAME,DEPT,LOC) VALUES (600,'TEST5','IT','ATL');
INSERT INTO EMP (EMPNO,ENAME,DEPT,LOC) VALUES (700,'TEST6','IT','BOS');
INSERT INTO EMP (EMPNO,ENAME,DEPT,LOC) VALUES (800,'TEST7','HR','NYC');
COMMIT;
CREATE TABLE COLUMNAMES(
COLUMNAME VARCHAR2(255)
INSERT INTO COLUMNAMES(COLUMNAME) VALUES ('EMPNO');
INSERT INTO COLUMNAMES(COLUMNAME) VALUES ('ENAME');
INSERT INTO COLUMNAMES(COLUMNAME) VALUES ('DEPT');
INSERT INTO COLUMNAMES(COLUMNAME) VALUES ('LOC');
COMMIT;
CREATE TABLE DEPT(
DEPT VARCHAR2(255),
DNAME VARCHAR2(255)
INSERT INTO DEPT(DEPT,DNAME) VALUES ('IT','INFORMATION TECH');
INSERT INTO DEPT(DEPT,DNAME) VALUES ('HR','HUMAN RESOURCE');
INSERT INTO DEPT(DEPT,DNAME) VALUES ('MR','MARKETING');
INSERT INTO DEPT(DEPT,DNAME) VALUES ('IT','INFORMATION TECH');
COMMIT;
PL/SQL BLOCK
DECLARE
TYPE EMPCurTyp IS REF CURSOR;
v_EMP_cursor EMPCurTyp;
l_col_val EMP.ENAME%type;
l_ENAME_val EMP.ENAME%type;
l_col_ddl varchar2(4000);
l_col_name varchar2(60);
l_tab_name varchar2(60);
l_empno number ;
b_l_col_name VARCHAR2(255);
b_l_empno NUMBER;
begin
for rec00 in (
select EMPNO aa from EMP
loop
l_empno := rec00.aa;
for rec in (select COLUMNAME as column_name from columnames
loop
l_col_name := rec.column_name;
begin
l_col_val :=null;
l_col_ddl := 'select distinct :b_l_col_name ,pr.dept ' ||' from emp pr, dept ps where ps.dept like ''%IT'' '||' and pr.empno =:b_l_empno';
dbms_output.put_line('DDL ...'||l_col_ddl);
OPEN v_EMP_cursor FOR l_col_ddl USING l_col_name, l_empno;
LOOP
l_col_val :=null;
FETCH v_EMP_cursor INTO l_col_val,l_ename_val;
EXIT WHEN v_EMP_cursor%NOTFOUND;
dbms_output.put_line('l_col_name='||l_col_name ||' empno ='||l_empno);
END LOOP;
CLOSE v_EMP_cursor;
END;
END LOOP;
END LOOP;
END;user1758353 wrote:
Thanks Billy, Would you be able to suggest any other faster method to load the data into table. Thanks,
As Mark responded - it all depends on the actual data to load, structure and source/origin. On my busiest database, I am loading on average 30,000 rows every second from data in external files.
However, the data structures are just that - structured. Logical.
Having a data structure with 100's of fields (columns in a SQL table), raise all kinds of questions about how sane that structure is, and what impact it will have on a physical data model implementation.
There is a gross misunderstanding by many when it comes to performance and scalability. The prime factor that determines performance is not how well you code, what tools/language you use, the h/w your c ode runs on, or anything like that. The prime factor that determines perform is the design of the data model - as it determines the complexity/ease to use the data model, and the amount of I/O (the slowest of all db operations) needed to effectively use the data model. -
How can I call a Page Process from the Select statement for Report Page
I'm able to call a javascript using the below:
img src="#IMAGE_PREFIX#add2.gif" border="0" alt="Icon 4" onClick="javascript:add_connect1('||CPORT.ID||')"
But Now,
I'd like to accomplish (2) New things:
1. instead of using,....... onClick="javascript:add_connect1,
I'd like to call a Page Process, onClick=
2. I'd like to be able to call two different processes onClick.
a. onClick="javascript:passBack('||ID||')"
b. onClick= <Please see my question #1 above>
Can someone please help me with the syntax for this,
If indeed it can even be done?
Thanks- GaryGreg.
It seems that my situation is the one you describe in you second paragraph, where you mention:
you could then add the ID column value as a parameter to the javascript functionBut,
I do not know how to reference the variable in my javascript nor how to use it in my on-demand process.
If you can hellp me past this last little bump, then I think I will be able to use these skills in Sooo many different areas of my design.
Here's what I've got so far:
A. In the select statement I identify the javascript as:
onClick="javascript:connect_port('<font color=blue>''||ID||''</font>')";
B. In my javascript I have this:
<script language="JavaScript" type="text/javascript">
function connect_port(ID)
var get = new htmldb_Get(null,$x('pFlowId').value,'APPLICATION_PROCESS=CONNECT_PORT',0);
gReturn = get.get();
get = null;
</script>
C. In my on demand function I have this:
BEGIN
INSERT INTO CCONNECTIONS_B
BLDG_ID,CLST_ID,PORT_ID,STRAND_ID
) VALUES
:P2004_BLDG_ID,:P2004_CLST_ID,:P2004_PORT_ID,:P2004_STRAND_ID1
END;
You can see that I dont know how to use the value for 'ID' in either the javascript or the On-Process function.
If you can help me out with this one, Then I can imitate it for the rest.
-Gary
Edited by: garyNboston on Apr 3, 2009 6:44 AM
Edited by: garyNboston on Apr 3, 2009 6:44 AM
Edited by: garyNboston on Apr 3, 2009 6:45 AM
Edited by: garyNboston on Apr 3, 2009 6:47 AM -
Getting error while executing this select statement
Hi All,
I am new to this community.
I am getting error whie compiling the below code. Its telling 'Text' is invalid identifier. Also i want to know how can we obtain 'parseable' version of the below query?
my basic intention is to create a trigger header through a select statement and show it the complete text as a single column..
select text from
(select 'CREATE OR REPLACE TRIGGER '||SUBSTR(column_name,2,4)||'aud
AFTER INSERT
OR UPDATE
OF '||column_name||',
OR DELETE ON '||table_name||'
FOR EACH ROW'
FROM(SELECT lower(REPLACE(column_name,'O_','')) column_name , /*changing O to O_*/
lower(replace(t.table_name,'_A_','_')) table_name,
lower(t.table_name) table_name1,
c.column_id
FROM all_tab_columns c,
(SELECT object_name table_name
FROM all_objects
WHERE object_name LIKE '%/_A/_%' ESCAPE '/') t
WHERE c.table_name(+) = t.table_name
AND SUBSTR(column_name(+),1,2) = 'O_'))thanks prathamesh. it solved the problem. i have one more question.
as of now it creates single create trigger statement for each column on a table.
example:
CREATE OR REPLACE TRIGGER ust_aud
AFTER INSERT
OR UPDATE
OF cust_id,
OR DELETE ON characteristic_t
FOR EACH ROW
however, i want to create trigger for all columns in a single statement. can you please help me how to do it?
basically want to 'CREATE TRIGGER' for all columns in a table. i am finding difficult how to change my query to suit this!!
i am pasting my original query again for your reference. pls advise...
example:
CREATE OR REPLACE TRIGGER ust_aud
AFTER INSERT
OR UPDATE
OF cust_id,
fixed_item_val,
copy_item_val,
rgn_id,
txn_id,
OR DELETE ON characteristic_t
FOR EACH ROW
ORIGINAL QUERY
select text from
(select 'CREATE OR REPLACE TRIGGER '||SUBSTR(column_name,2,4)||'aud
AFTER INSERT
OR UPDATE
OF '||column_name||',
OR DELETE ON '||table_name||'
FOR EACH ROW' text
FROM(SELECT lower(REPLACE(column_name,'O_','')) column_name , /*changing O to O_*/
lower(replace(t.table_name,'_A_','_')) table_name,
lower(t.table_name) table_name1,
c.column_id
FROM all_tab_columns c,
(SELECT object_name table_name
FROM all_objects
WHERE object_name LIKE '%/_A/_%' ESCAPE '/') t
WHERE c.table_name(+) = t.table_name
AND SUBSTR(column_name(+),1,2) = 'O_')) -
Auto retry of select statements on failure
I have a IBM Message Broker message flow that accesses the database to fetch some data. following are the steps in a message flow. (similar pattern is there in other flows as well)
1) Parse the input message
2) Invoke a ESQL compute node that accesses the database. This uses DataDirect ODBC drivers to access the database.
3) process the data
4) Invoke an external Java class that also accesses the database. This Java class uses Spring/Hibernate and uses the Oracle UCP library.
Steps 2 and 4 access an Oracle database on which failover features are NOT enabled. Following is our observation.
If the database fails when executing step 2, then the message flow pauses until a valid connection is available and then proceeds with the execution, the point to note is that the message flow does not experience a failure. It simply pauses until it gets a connection and continues once it gets a connection.
If the database fails when executing step 4, the message flow gets an error.
What we want is for step 2 and 4 to execute the same way, meaning that we want the message flows to wait until a valid connection is available and then continue without any errors.
I feel that there is some feature in DataDirect driver that cause step 2 to pause the message flow and prevent an error. We want the same behaviour in step 4 as well.
So, is there some way (via configuration or any other means) to get this behaviour using oracle UCP library.
One thing to note is that we are not in position to change the Java code since it has been developed by a third party.
To achieve this I have written a test and the following are details.
For this I have created a service with the following properties. Point to note is that we run the service on only one instance at a time, if it goes down then it is started on the second instance.
Service name: LDL_TEST02
Service is enabled
Server pool: CSAHEDA_LDL_TEST02
Cardinality: 1
Disconnect: false
Service role: PRIMARY
Management policy: AUTOMATIC
DTP transaction: false
AQ HA notifications: true
Failover type: SELECT
Failover method: NONE
TAF failover retries: 180
TAF failover delay: 5
Connection Load Balancing Goal: LONG
Runtime Load Balancing Goal: NONE
TAF policy specification: BASIC
Edition:
Preferred instances: CSAHEDA1
Available instances: CSAHEDA2
Following is in my tnsnames.ora file and I am using the oracle oci driver.
TESTA =
(DESCRIPTION =
(ENABLE = BROKEN)
(LOAD_BALANCE = off)
(FAILOVER = on)
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = vip.host1)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = vip.host2)(PORT = 1521)))
(CONNECT_DATA =
(SERVICE_NAME = LDL_TEST02)
(FAILOVER_MODE =
(BACKUP = TESTA2)
(TYPE = SELECT)
(METHOD = PRECONNECT)
(RETRIES = 120)
(DELAY = 5)
This is how I run my test.
1)I have a simple test that simply loops through a list of select statements.
2)each time it takes a connection from the connection pool, executes the statement and returns the connection to the connection pool.
3)I keep this running for around 10 minutes.
4) once the test has started I bring down the service wait for 3 minutes and the start the service on the second instance.
5) what I expect is for the test to pause for 3 minutes and then get the correct value from executing the select statement. and continue without pause.
Following is the config for the connection pool.
<bean id="dd_Datasource" class="oracle.ucp.jdbc.PoolDataSourceFactory" factory-method="getPoolDataSource">
<property name="connectionFactoryClassName" value="oracle.jdbc.xa.client.OracleXADataSource"/>
<!-- property name="connectionFactoryClassName" value="oracle.jdbc.pool.OracleDataSource"/ -->
<!-- <property name="connectionFactoryClassName" value="sun.jdbc.odbc.ee.DataSource"/-->
<!-- <property name="URL" value="jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=vip.host1)(PORT=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=vip.host2)(PORT=1521))(LOAD_BALANCE=yes)(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=LDL_TEST02)))" /> -->
<!-- <property name="URL" value="jdbc:oracle:thin:@(DESCRIPTION=(ENABLE=BROKEN)(ADDRESS=(PROTOCOL=TCP)(HOST=vip.host1)(PORT=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=vip.host2)(PORT=1521))(LOAD_BALANCE=yes)(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=LDL_TEST02)))" />-->
<!-- property name="URL" value="jdbc:oracle:thin:@(DESCRIPTION=(LOAD_BALANCE=on)(FAILOVER=on)(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=vip.host1) (PORT=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=vip.host2) (PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=LDL_TEST02)(FAILOVER_MODE = (TYPE = SELECT)(METHOD = BASIC)(RETRIES = 180)(DELAY = 5))))" /-->
<!-- <property name="URL" value="jdbc:oracle:oci:@(DESCRIPTION=(ENABLE=BROKEN)(ADDRESS_LIST=(LOAD_BALANCE=on)(FAILOVER=on)(ADDRESS=(PROTOCOL=TCP)(HOST=vip.host1) (PORT=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=vip.host2) (PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=LDL_TEST01)(FAILOVER_MODE = (TYPE = SELECT)(METHOD = BASIC)(RETRIES = 180)(DELAY = 5))))" /> -->
<property name="URL" value="jdbc:oracle:oci:/@TESTA" />
<!-- JDBC ODBC Bridge Driver -->
<!-- property name="URL" value="jdbc:odbc:LT_Test_DB"/-->
<!-- DataDirect URLs -->
<!-- property name="URL" value="datadirect:oracle://vip.host1:1521;SID=LDL_TEST01"/-->
<property name="user" value="user" />
<property name="password" value="user" />
<property name="connectionPoolName" value="dd_connectionpool" />
<property name="minPoolSize" value="2" />
<property name="maxPoolSize" value="4" />
<property name="initialPoolSize" value="2" />
<property name="connectionWaitTimeout" value="10000" />
<!-- Note:
The setSQLForValidateConnection property is not recommended when using an Oracle JDBC driver.
UCP for JDBC performs an internal ping when using an Oracle JDBC driver.
The mechanism is faster than executing an SQL statement and is overridden if this property is set.
Instead, set the setValidateConnectionOnBorrow property to true and do not
include the setSQLForValidateConnection property. -->
<property name="validateConnectionOnBorrow" value="true"/>
<!-- FCF stuff -->
<!-- property name="connectionCachingEnabled" value="true"/-->
<!-- property name="fastConnectionFailoverEnabled" value="true"/-->
<!-- <property name="ONSConfiguration" value="nodes=vip.host1:1521,vip.host2:1521"/>-->
</bean>
As you can see I have tried many combinations.
Sometimes I see the thread pause for 3 minutes without error and then continue.
Sometime I start seeing 'oracle.ucp.UniversalConnectionPoolException: Cannot get Connection from Datasource' as soon as the servic is down.
Sometime the first error above is seen after 30 seconds (always the first one).
Can you guys shed any light on this? And how can I get the desired behaviour?
Edited by: user12181209 on 30-May-2012 02:22
reworded.
Edited by: user12181209 on May 30, 2012 6:28 AM
reworded the title for clarity.
Edited by: user12181209 on Jun 1, 2012 6:01 AMHi,
Yesterday, a similar question on running slow view was post :
View is tooo slow....
You can read different questions to try to help you.
Nicolas.
Maybe you are looking for
-
I am using the remote app and I have to enter my iTunes password to purchase a movie, the problem is that some of the keys are missing on my remote app, this is on my iphone and my iPad. I am missing the Parenthasis keys. Both open and close. They ar
-
Replacing T420s HDD with a new SSD
Hello, I wonderd if It is possible to replace the HDD with a new SSD, while placing the HDD in the Ultra-Bay slot. And if so, which SSD model should I buy, and how do I transfer the Operation System and data to the SSD? Will this SSD model be compati
-
Computer Recognizes Ipod As An "Unknown Device"
How Do I Get My Computer To Recognize My Ipod As An Ipod Or Mass Strage Device?
-
Question I have Windows 7 Home Premium. When I start Firefox 4, I get a User Account Control warning, "Do you want to allow the following program to make changes to this computer"? Is there a way to stop this warning?
-
hi everyone i just purchased eureka plug in pack...went thru paypal...they took my money but no confirmation email (other than paypal) or download. Does anyone know if they are a rip-off? has anyone else had a problem with them? I'm bummed cuz it was