SQL statement/ DB Object beling call in last 1 Hour
Hi,
Can anyone help me i.e. How to find specific sql statement or database objects being used in last one hr or 24 hrs in Oracle 10.2.0.4?
Thanks
Hello,
To find out specific SQL statement you can used following query and to find information about object you need to enable object level auditing like select,update,insert and delete.
SELECT e.SID,
SUBSTR(osuser,0,7) osuser,
SUBSTR(username,0,8) username,
substr(status,1,1) status,
SUBSTR(machine,0,11) machine,
TO_CHAR(ROUND(value/1024),9999) || ' KB' memory,
TO_CHAR((sysdate-logon_time)*24*60,999999.99) minutes,
q.sql_text
FROM
v$session e,
v$sesstat s,
v$statname n,
v$sql q
WHERE s.statistic# = n.statistic#
AND n.name = 'session uga memory max'
AND e.sid = s.sid
AND q.hash_value(+) = e.sql_hash_value
order by
machine,minutes;
Hope this help.
Similar Messages
-
How to store pl/sql statement in varchar and call EXEC on it?
So this statement works:
SELECT column_name BULK COLLECT INTO table_column_list FROM all_tab_columns WHERE table_name = conv_tablename AND OWNER IN (SELECT USER FROM DUAL);
However I want to add conditions like " AND column_name <> 'abc' " at the end. So i tried to store this in a varchar and call EXEC on it:
select_column_value_sql_stmt := 'SELECT column_name BULK COLLECT INTO table_column_list FROM user_tab_columns WHERE table_name = '''|| conv_tablename || '''' || inexclude_column;
EXECUTE IMMEDIATE select_column_value_sql_stmt;
No matter how I concatenate the conv_tablename part, i get an error. either invalid identifier or unimplemented feature.
so is there a way to do this at all?
Thanks in advance.Welcome to the forum!
Wheneve you post provide your 4 digit Oracle version (result of SELECT * FROM V$VERSION).
>
So this statement works:
SELECT column_name BULK COLLECT INTO table_column_list FROM all_tab_columns WHERE table_name = conv_tablename AND OWNER IN (SELECT USER FROM DUAL);
However I want to add conditions like " AND column_name 'abc' " at the end. So i tried to store this in a varchar and call EXEC on it:
select_column_value_sql_stmt := 'SELECT column_name BULK COLLECT INTO table_column_list FROM user_tab_columns WHERE table_name = '''|| conv_tablename || '''' || inexclude_column;
EXECUTE IMMEDIATE select_column_value_sql_stmt;
No matter how I concatenate the conv_tablename part, i get an error. either invalid identifier or unimplemented feature.
so is there a way to do this at all?
>
Yes - you can do it but the syntax is different for BULK COLLECT when using EXECUTE IMMEDIATE; the INTO goes AFTER the query, not within it.
See the example code at this link
http://unix-oracle-11g.blogspot.com/2011/03/dynamic-sql-execute-immediate-bulk.html
-- example of dynamic sql with bull collect
v_sql_stmt := 'SELECT sal FROM emp_t';
EXECUTE IMMEDIATE v_sql_stmt BULK COLLECT INTO vc_sal;So you won't be able to use a common set of queries for normal vs execute immediate. -
Odd results from SQL statement in JSP
Hi.
Getting very strange results from my SQL statement housed in my JSP.
the last part of it is like so:
"SELECT DISTINCT AID, ACTIVE, REQUESTOR_NAME, ..." +
"REQUESTOR_EMAIL" +
" FROM CHANGE_CONTROL_ADMIN a INNER JOIN CHANGE_CONTROL_USER b " +
"ON a.CHANGE_CTRL_ID = b.CHANGE_CTRL_ID " +
" WHERE UPPER(REQUESTOR_NAME) LIKE ? "; I've set the following variables and statements:
String reqName = request.getParameter("requestor_name");
PreparedStatement prepstmt = connection.prepareStatement(preparedQuery);
prepstmt.setString(1, "%" + reqName.trim().toUpperCase() + "%");
ResultSet rslts = prepstmt.executeQuery();
rslts.next();
int aidn = rslts.getInt(1);
int actbox = rslts.getInt(2); String reqname = rslts.getString(3).toUpperCase();
String reqemails = rslts.getString(4);
String bizct = rslts.getString(5);
String dept = rslts.getString(6);
String loc = rslts.getString(7);
Date datereq = rslts.getDate(8);
String busvp = rslts.getString(9);
AND SO ONSo then I loop it, or try to with the following:
<%
try {
while ((rslts).next()) { %>
<tr class="style17">
<td><%=reqname%></td><td><%=reqemails %></td><td><%=bizct %></td>td><%=dept %></td>
<td><%=aidn %></td>
</tr>
<%
rslts.close();
selstmt.close();
catch(Exception ex){
ex.printStackTrace();
log("Exception", ex);
%>AND so on, setting 13 getXXX methods of the 16 cols in the SQL statement.
Trouble is I'm getting wildly inconsistent results.
For example, typing 'H' (w/o quotes) will spit out 20 duplicate records of a guy named Herman, with the rest of his corresponding info correct, just repeated for some reason.
Typing in 'He' will bring back the record twice (2 rows of the complete result set being queried).
However, typing in 'Her' returns nothing. I could type in 'ell' (last 3 letters of his name, Winchell) and it will again return two duplicate records, but typing in 'hell' would return nothing.
Am I omitting something crucial from the while statement that's needed to accurately print out the results set without duplicating it and that will ensure returning it?
There's also records in the DB that I know are there but aren't being returned. Different names (i.e. Jennifer, Jesse, Jeremy) won't be returned by typing in partial name strings like Je.
Any insight would be largely appreciated.
One sidenote: I can go to SQL Plus and accurately return a results set through the above query. Having said that, is it possible the JDBC driver has some kind of issue?
Message was edited by:
bpropes20
Message was edited by:
bpropes20Am I omitting something crucial from the while
statement that's needed to accurately print out the
results set without duplicating it and that will
ensure returning it?Yes.
In this code, nothing ever changes the value of reqname or any of the other variables.
while ((rslts).next()) { %>
<tr class="style17">
<td><%=reqname%></td><td><%=reqemails %></td><td><%=bizct %></td>td><%=dept %></td>
<td><%=aidn %></td>
</tr>
<%
} You code needs to be like this:while (rslts.next()) {
reqname = rslts.getString(3).toUpperCase();
reqemails = rslts.getString(4);
bizct = rslts.getString(5);
dept = rslts.getString(6);
loc = rslts.getString(7);
datereq = rslts.getDate(8);
busvp = rslts.getString(9);
%>
<tr class="style17">
<td><%=reqname%></td><td><%=reqemails %></td><td><%=bizct %></td>td><%=dept %></td>
<td><%=aidn %></td>
</tr>
<%
There's also records in the DB that I know are there
but aren't being returned. Different names (i.e.
Jennifer, Jesse, Jeremy) won't be returned by typing
in partial name strings like Je.Well, you're half-right, your loop won't display all the rows in the result set, because you call rslts.next(); once immediately after executing the query. That advance the result set to the first row; when the loop is entered, it starts displaying at the 2nd row (or later if there are more next() calls in the code you omitted). -
How do I use a variable within a sql statement
I am trying to use a local variable within an open SQL step but I keep getting an error.
My sql command looks like this "SELECT BoardDetailID FROM BoardDetails WHERE SerialNumber = " + locals.CurrentSerialNo
If I replace the locals.CurrentSerialNo with an actual value such as below the statement works fine.
"SELECT BoardDetailID FROM BoardDetails WHERE SerialNumber = " + " 'ABC001' "
Can someone tell me how to correctly format the statement to use a variable?Hi,
Thanks for the reply. I have changed the required variable to a string, but with no success. I have reattached my updated sequence file and an image of the error.
When looking at the Data operation step I see that the sql statement is missing everything after the last quotation mark.
Thanks again,
Stuart
Attachments:
Database Test Sequence.seq 10 KB
TestStand error.JPG 37 KB -
Need SQL statement for this logic....
Hi,
I want a SQL statement for updating the following changed last number .
Cuurently its:
SELECT * FROM TEST;
LAST NUMBER CHANGED LAST NUMBER
123518
12355265
123674659
9087648970
After updating with the required SQL statement table should look like
LAST NUMBER CHANGED LAST NUMBER
123518 0000123518
12355265 0012355265
123674659 0123674659
9087648970 9087648970
the last number should be appended with ZEROs and the length of changed last number should be 10 always. Hope its clear.
Appreciate your help.
Thanks in advance
Devenderselect last_number, lpad(to_char(last_number), 10 , '0') FROM test
-
High Database server load from expensive SQL statements
Dear all,
I am facing problem in the production sever there is high Database server load from expensive SQL statements as per EVA report
Buffer Load [%] Disk Load [%] CPU Load [%]
55 69 0
Analysis of DB SQL CACHE
EXPENSIVE SQL STATEMENTS OVERVIEW
Object Name CPU Load [%] I/O Load [%] Elapsed Time [%] Executions Records Processed
BSIS 1 9 0 22 90462
CDEF$ 6 6 0 2131113 2575694
BSAD 1 3 0 21 408576
MKPF 1 32 0 180 3899
ICOL$ 9 1 0 2575694 8703798
OBJ$ 6 1 0 3405254 3400023
COL$ 12 0 0 2138793 22919657
MKPF 1 13 0 75 396
MCHB 7 0 0 366543 41708
Please suggest the step by step to reduce the expensive SQL from these table.
RegardsHi,
In tx code ST05 i have find the following deatails.
Duration |Obj. name |Op. |Recs.|RC |Statement
4 TSP03A REOPEN 0 SELECT WHERE "NAME" = 'LOCL' AND "P" = 'S_CLIENTS' 344 TSP03A FETCH 1 0 42 ZRIN DECLARE 0 SELECT WHERE "MANDT" = :A0 AND "BCQ" = :A1 442 ZRIN PREPARE 0 SELECT WHERE "MANDT" = :A0 AND "BCQ" = :A1 3 ZRIN OPEN 0 SELECT WHERE "MANDT" = '600' AND "BCQ" = 'BCQ'
2,181,565 ZRIN FETCH 4 1403
706,267 DBA_SEGME FETCH 99 0 8,248 DBA_SEGME FETCH 99 0 44,994 DBA_SEGME FETCH 99 0 67,713 DBA_SEGME FETCH 99 0
1,367,923 DBA_SEGME FETCH 99 0
16,735|TADIR |FETCH | 1| 1403| |
5
TADIR
REOPEN
0
SELECT WHERE "PGMID" = 'R3TR' AND "OBJECT" = 'TABL' AND "OBJ_NAME" = 'CME__TEXT'
22,415
TADIR
FETCH
1
1403
4
TADIR
REOPEN
0
SELECT WHERE "PGMID" = 'R3TR' AND "OBJECT" = 'TABL' AND "OBJ_NAME" = 'CME_PATTERN_SIGN'
232
TADIR
FETCH
1
1403
4
TADIR
REOPEN
0
SELECT WHERE "PGMID" = 'R3TR' AND "OBJECT" = 'TABL' AND "OBJ_NAME" = 'CML_ARC_DEADLINE'
19,189
TADIR
FETCH
1
1403
4
TADIR
REOPEN
706,267
DBA_SEGME
FETCH
99
0
|
44,994
DBA_SEGME
FETCH
99
0
67,713
DBA_SEGME
FETCH
99
0
Please suggest how to reduce it.
Regards, -
Using Date objects in SQL statements
Hi, I am wondering if it is possible to use Date objects while trying to retrieve entries from an access database with fields set as "Date/Time" fields, as opposed to "Text"? If so, do I need to reformat it before inserting it into the SQL statement, or can I just leave it as a Date object, and call up the variable name?
For example - "SELECT * FROM database WHERE startDate = ' " + dateObject + ' ". And do i need quotes round this value?
Thanks in advance.I had some problems by just fetching a date and pushing it back to a MS SQL Database.
I used the following reformating step to fix it:
if (o instanceof Timestamp)
String time = o.toString().substring(8,10)+"."+o.toString().substring(5,7)+"."+o.toString().substring(0,4)+" "+o.toString().substring(11,19);
ht.put(columnName, time);
o is the object i receve from the select statement and ht is a Hashtable where i put my data.
To write the data back i now can use:
UPDATE table SET columnname = 'valueOfColumn'
This means i use the value i created above in Quotes to write it back.
Format of Timestamp.toString() is something like yyyy-mm-dd hh:mm:ss.xx
Format used by MS SQL (and i think by Access to) 'dd.mm.yyyy hh:mm:ss' -
SQLEXEC not able to filter extract on sql statement or function call.
hi all,
i'm trying to do some basic extract filtering using a stored function and am not having much success.
i started off using a procedure call but have been unsuccessful getting that working, i've simplified
it to use a sql statement calling a function for a value to filter on, but cannot even get that to work.
i've read through the documentation and i cannot figure out what is going wrong.
any help would be much appreciated.
thx,
daniel
function code is very simple, just trying to get something working.
FUNCTION f_lookup_offer_id(v_offer_id IN offer.offer_id%TYPE)
RETURN company.name%TYPE IS
lv_company_name company.name%TYPE;
BEGIN
SELECT c.name
INTO lv_company_name
FROM orders a, offer b, company c
WHERE a.offer_id = b.offer_id
AND b.company_id = c.company_id
AND a.order_id = v_order_id;
RETURN lv_company_name;
END f_lookup_offer_id ;
Oracle GoldenGate Command Interpreter for Oracle
Version 11.1.1.0.0 Build 078
Solaris, sparc, 64bit (optimized), Oracle 10 on Jul 28 2010 13:26:39
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
EXTRACT EATUOP1
INCLUDE ./dirprm/GGS_LOGIN.inc
EXTTRAIL ./dirdat/up
DISCARDFILE ./dirout/eatuop1.dsc, append , MEGABYTES 50
DISCARDROLLOVER ON SUNDAY AT 06:00
-- Database and DDL Options
-- Added to avoid errors when setting unused columns
DBOPTIONS ALLOWUNUSEDCOLUMN
-- Get full row for deletes
NOCOMPRESSDELETES
-- Get updates before
GETUPDATEBEFORES
-- If commit SCN that is not greater than the highest SCN already processed error
THREADOPTIONS MAXCOMMITPROPAGATIONDELAY 15000 IOLATENCY 6000
-- Retains original timestamp. Currently using GMT
NOTCPSOURCETIMER
--TABLE DEFS
TABLE master.OFFER,
SQLEXEC ( ID ck_offer,
QUERY " select master.f_lookup_offer_id(:off_id) is_company from dual ",
PARAMS (off_id = offer_id),
BEFOREFILTER),
FILTER (@GETVAL (ck_offer.is_company = "Google, Inc."));
does not give any errors, but also does not capture any data, it's filtering everything out and trail files are empty, minus a header.
thoughts or help?
2012-04-04 22:17:36 INFO OGG-00993 Oracle GoldenGate Capture for Oracle, eatuop1.prm: EXTRACT EATUOP1 started.
2012-04-04 22:17:36 INFO OGG-01055 Oracle GoldenGate Capture for Oracle, eatuop1.prm: Recovery initialization completed for target file ./dirdat/up000022, at RBA 978.
2012-04-04 22:17:36 INFO OGG-01478 Oracle GoldenGate Capture for Oracle, eatuop1.prm: Output file ./dirdat/up is using format RELEASE 10.4/11.1.
2012-04-04 22:17:36 INFO OGG-01026 Oracle GoldenGate Capture for Oracle, eatuop1.prm: Rolling over remote file ./dirdat/up000022.
2012-04-04 22:17:36 INFO OGG-01053 Oracle GoldenGate Capture for Oracle, eatuop1.prm: Recovery completed for target file ./dirdat/up000023, at RBA 978.
2012-04-04 22:17:36 INFO OGG-01057 Oracle GoldenGate Capture for Oracle, eatuop1.prm: Recovery completed for all targets.
2012-04-04 22:17:36 INFO OGG-01517 Oracle GoldenGate Capture for Oracle, eatuop1.prm: Position of first record processed Sequence 13469, RBA 21894160, SCN 1789.722275534, Apr 4, 2012 10:12:40 PM.
-rw-rw-rw- 1 svc_ggs 502 978 Apr 4 22:17 up000023got it working, this seems to be about as simple as i could formulate it. thanks for pointing me in the right direction.
TABLE GGS_TEST_EXT, &
SQLEXEC ( ID co_count, &
QUERY " select f_lookup_company_name(:P1) x from dual ", &
PARAMS ( P1 = company_id), BEFOREFILTER), &
FILTER ( @GETVAL (co_count.x = 0) );
then i have a function that returns 1 or 0, depending on the company id passed in.
thx,
daniel -
Calling a PL/SQL function in the SQL statement
I have a PL/SQL function which i should call in a SQL statement.
Let's say the function is func1(parameter1,parameter2),
it should be called like this :- SELECT func1() FROM mytable ;
Can any one help me out on this ?
---Thanx in advanceyou can call pl/sql functions from pl/sql using
select fn1('param1','param2') from table;
if you dont want to pass paramters, you have to specify default
value while creating function like below
create function fn1(p1 number default null,p2 varchar2 default
null) return...
now you can call using
select fn1 from table; -
Problem in Calling a function in sql statement.
hi,
I am having a function ops_safex_utl.EDIT_ASSC_CNTR_LOG(id number);
when i am trying to use this inside a sql statement as shown below, it is giving error (exception part inside the function).
SQL> select ops_safex_utl.EDIT_ASSC_CNTR_LOG(688) from dual;
OPS_SAFEX_UTL.EDIT_ASSC_CNTR_LOG(688)
-1 (-- exception )
when i am trying to call this function using a PL/SQL Block then it is woking fine as shown below.
SQL> DECLARE
2
3 x NUMBER(2);
4
5 BEGIN
6
7 x := ops_safex_utl.EDIT_ASSC_CNTR_LOG(688);
8
9 dbms_output.put_line('x '||' '||x);
10
11 END;
12 /
hi
insert into ops_assc_cntr_log
insert into ops_ac_ex_gratia_log
insert into ops_ac_sls_dlvry_slab_dtls_log
insert into ops_ac_sls_dlvry_slab_dtls_log
insert into ops_ac_sls_dlvry_slab_dtls_log
insert into ops_ac_sls_dlvry_slab_dtls_log
insert into ops_ac_sls_dlvry_slab_dtls_log
insert into ops_ac_spl_acct_dtls_log
insert into ops_ac_spl_acct_slab_dtls_log
insert into ops_ac_spl_acct_slab_dtls_log
insert into ops_ac_spl_acct_slab_dtls_log
insert into ops_ac_spl_acct_dtls_log
insert into ops_ac_spl_acct_slab_dtls_log
insert into ops_ac_spl_acct_slab_dtls_log
insert into ops_ac_spl_acct_slab_dtls_log
update ops_assc_cntr
success
x 0
PL/SQL procedure successfully completed.
when i am trying to run the SQL statement it is returning a exception from the function.
SELECT ops_safex_utl.EDIT_ASSC_CNTR_LOG(688) from dual --it is returning -1 (i.e exception).
My sql client version is 9.2.0.1.0. and my data base version is 10.2.0.2.0.
Please advice.Could you post the exception handler within the function.
It sounds like you return -1 if you experience an error - it would be easier to determine the cause of the problem if you return the Oracle error details, E.g:
EXCEPTION
WHEN OTHERS THEN
RETURN dbms_utility.format_error_backtrace;This will then return a meaningful error, identifying exactly what is causing the error to be generated. -
CALL PROCEDURE IN SQL STATEMENT
Why we cant call a procedure inside SQL statement?
Hitesh Nirkhey wrote:
Hi Karthick_Arp
as you said
The procedure that is used inside a function cannot contain DDL or DML statements or COMMIT/ROLLBACK.
Said that it does not make much sence to use a procedure within a function.IT make sense if we DECLARE FUNCTION AS PRAGMA AUTONOMUS_TRANSACTION
then we can execute DDL or DML statements or COMMIT/ROLLBACK in that function.
Regards
HiteshBut why would you do that? -
Call C function in SQL statement
dear all
I want to know how i can call C function in SQL statement where clausehttp://asktom.oracle.com/pls/ask/f?p=4950:8:80100593788949622::NO::F4950_P8_DISPLAYID,F4950_P8_CRITERIA:934029542973
-
Create a link in a table calls sql statement
Hello,
I'm very new to htmldb but need to complete a project within a tight timeline. I created a sql report in a region. On each row, I have an on/off link, which used to trigger a sql statement. It turns a flag on and off in a table. Key needs to be passed with the link to be used in sql. How do I passed the key in the link and how can I call the sql statement? Where can I put the sql statement? Can someone give me some tips?
Your help is greatly appreciated!
Junif you take a look at the "Understanding URL Syntax" section in chapter 6 of our User Guide, you'll see that you can set item values in html db via the URL by passing name/value pairs through the url. to see it in action, use our "Report with links to form on a table (2 Pages)" wizard to generate a form and a report on some table of yours. when you run that report page and click an edit link on it, you'll see how it passes its values to the form page using our URL syntax. in your case you'd want to create an item like MY_PROD_KEY_ITEM and set its value via your link. you'd then run your pl/sql block referring to the value of that item. when doing so, you'd probably want to use the bind variable syntax that's also explained in chapter 6, "Referencing Session State".
--raj -
How to call a FoxPro .prg file through SQL statement
I created a program exclusive.prg which basically consisted of the statement USE my table exclusive. How can i call this function through a SQL statement using java
Hi,
Thank you for he reply.
Runtime.getRuntime().exec(..)works fine with .exe files.
but, when a foxpro program file(.prg) is compiled, a (.fxp) file is produced and not a .exe file
when i write some thing like
statement.execute("exclusive.fxp")i'm getting an error. here is the stack trace
java.sql.SQLException: [Microsoft][ODBC Visual FoxPro Driver]Syntax error or access violation
at sun.jdbc.odbc.JdbcOdbc.createSQLException(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.standardError(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.SQLExecDirect(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcStatement.execute(Unknown Source)
at excel.TestMom.main(TestMom.java:28)i also tried using
statement.execute("do exclusive.fxp") and
statement.execute("do exclusive.prg")I got the same error.
Dont know what else to do.Can you please suggest some way to work around. -
How to call SQL statements in InDesign CS6?
Hi,
My plug-in needs to interact with the database, and update the database content, how should I do, can I call SQL statements in InDesign CS6?
Thanku very much.The same way you'd call them from any C++ program. You don't mention which platform, and that probably makes a difference.
I'm accessing an SQL database in InDesign CS6 on Windows. I'm using the ODBC interface to SQL database that Windows provides, via the nanodbc wrapper. So I'm linking to odbc32.lib and odbccp32.lib, and including the nanodbc.cpp and nanodbc.h files. (See http://lexicalunit.github.io/nanodbc/ )
Paul.
Maybe you are looking for
-
I am using elements 11, windows live mail 2012 on a windows 8.1 PC. When trying to attach an elements 11 image to an email via the sharing option in Organizer, I get a message that the email message cannot be completed, and to try Adobe mail. I hav
-
Kernel Panic on Mac Pro - Lion
Anybody have an idea about this kernel panic log? Thanks! Mon Mar 11 13:43:04 2013 Machine-check capabilities (cpu 15) 0x0000000000001c09: family: 6 model: 26 stepping: 5 microcode: 17 Intel(R) Xeon(R) CPU E5520 @ 2.27GHz 9 error-reporting
-
.....NOW THAT I HAVE ALL OF YOUR ATTENTION.... I have never seen so many children in my life. I'm going to assume that all of you are over the age of 18 who ordered their wonderful iPhone, but quite honestly, most of you are all acting like a bunch
-
Data transfer from iPhone 3GS to iPhone 4S
I've just switched from an iPhone3GS to an iPhone4S, how do I transfer videos I took with the 3GS camera to the 4S....? The synching for these elements does not seem to work. Also my iTunes store says the Viber app needs to be "authorized" through th
-
Firefox will NOT Open...Crash report appears...WHY?
AdapterDeviceID: 68a1 AdapterVendorID: 1002 Add-ons: [email protected]:0.79,{dc572301-7619-498c-a57d-39143191b318}:0.3.8.5,{BBDA0591-3099-440a-AA10-41764D9DB4DB}:2.0,{B7082FAA-CB62-4872-9106-E42DD88EDE45}:3.3.1,{972ce4c6-7e08-4474-a285-3208198ce6fd}: