Get the last query from the current user
Is there a way to get the last query of the current user, so every query could be log with a database trigger?
Let's just say I execute:
DELETE xxxx;
I tried :
SELECT T.SQL_TEXT FROM V$SQLAREA T where ADDRESS=(SELECT prev_sql_addr FROM v$session where audsid=userenv('sessionid'));
But the result of this query is :
'SELECT T.SQL_TEXT FROM V$SQLAREA T where ADDRESS=(SELECT prev_sql_addr FROM v$session where audsid=userenv('sessionid'))'
Is there a way to execute a query that would return :
'DELETE xxxx'
Thanks
You could join SQL_ADDR in v$session with ADDRESS in v$sqlarea to determine the SID that executed that SQL statement last. Note that PREV_SQL_ADDR in v$session will indicate the previous SQL he executed. Though you would have to look at these tables very often to get all SQL statements issued. One note here, I think if a different user ran the SAME SQL with just bind var differences the SQL_AREA will only show the last userâs information that executed it.
BTW - it will show deletes also...
Similar Messages
-
To Find the SAP Query from the tranaction code or the program name
Hi,
I have a situation wherein I have to modify the sap query associated with an transaction code.But the problem is that I am unable to find the SAP Query.
<b>Please let me know how to find the SAP query from the transaction code or the program name.</b>
Thanks and Regards,
RupeshHi Rupesh,
1 use FM
RSAQ_DECODE_REPORT_NAME
2. This is one of the best and easiest way.
3. It will provide u the following info.
WORKSPACE
USERGROUP
QUERY
CLIENT
4. Thru TCode U must know the program name first.
This can be discovered using SE93.
Hope it helps.
Regards,
Amit M. -
Problem of running the jump query from the result line
Dear expert,
I have a problem when running a jump query from the result line. Apparently, the values of the caracteristics haven't been sent to the jump target. However, the configuration in RSBBS seems to be good as the jump works well from the other lines.
Does anyone have some ideas on that?
Thanks in advance!Hi,
If you are supposed to bring across characteristic values to your target, then you will not be able to jump from the result line. The configuration expects that the values of the characteristic marked as being used in the jump are filled with unique values. When you use the result line as a source for your jump, the values in the result line will most likely be based on the sum of multiple characteristic values.
Hth,
-Jacob -
Unpivot taking the last letter from the column name
Hi guys, having
DATE Period1 Period2 Period3 Period4
01/01/2014 1.02 1.06 1.02 1.03
02/01/2014 1.06 1.05 1.04 1.06
I would like an unptivot as
01/01/2014 1 1.02
01/01/2014 2 1.06
01/01/2014 3 1.02
01/01/2014 4 1.03
02/01/2014 1 1.06
02/01/2014 2 1.05
02/01/2014 3 1.04
02/01/2014 4 1.06
But I'm wondering how can I take the last letter of the column. Maybe I should use a select case...
Any advices? Thank youDECLARE @Table TABLE
dt DATE,
P1 INT NULL,
P2 INT NULL,
P3 INT NULL,
P4 INt NULL
INSERT INTO @Table(dt, P1, P2, P3, P4)
VALUES('20140101',10,null,20,3);
INSERT INTO @Table(dt, P1, P2, P3, P4)
VALUES('20140102',50,25,15,5);
SELECT dt, row_number() over (partition by dt order by dt) rn,per AS DayMax FROM @Table
UNPIVOT (per FOR DayNumber IN (P1, P2, P3, P4)) AS c
Best Regards,Uri Dimant SQL Server MVP,
http://sqlblog.com/blogs/uri_dimant/
MS SQL optimization: MS SQL Development and Optimization
MS SQL Consulting:
Large scale of database and data cleansing
Remote DBA Services:
Improves MS SQL Database Performance
SQL Server Integration Services:
Business Intelligence -
How to get the last record from the database
I am using MS Access database and Swings as GUI. I want to get the last record of a particular column from the table and store it as a varaible.
Hi
To get Last record of resultset, you have pass some parameter in constructor of CreateStatement.In such case Resultset should be scrollable and Readonly
Example
objStatement=objCon.createStatement ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
mwwResultSet=cwwStatement.executeQuery(mwwSqlQuery);
while(mwwResultSet.next())
if(mwwResultSet.isLast())
//Fetch the required column record.
String abc=mwwResultSet.getString(1);
I think this will work. Try it.
bye -
Getting the last record from the internal table
When we use a READ statement it always picks up the first record which fulfill its condition but in my case I want to pick up the last record that fulfills it condition
I have a internal table like
id type
N1 A
N1 T
N1 A
N1 6 ----> LAST RECORD
my code is
read table itab wIth key id = netobjid.
for eg if netobjid = N1 , then I want to read the last record that corresponds to N1 ie ID N1 TYPE - 6...
How to do that?HI
actually i have done same requirement like this ...
Take one count variable into your internal table ..you pass the number of records into cont variable for every time u enter the loop .
Sort the internal table with count variable descending . ( AS we cant sort the internal table with sy-tabix)
Then use read statement with sy-index = 1 .
USe below logic ,............
data : count type i value '0'.
LOOP at int .
count = count + 1 .
endloop.
sort int count descending .
read int with index = 1 . -
Selecting the last record from a database table
In my ABAP Program, I have to use a select statement to retrieve the last record from the database table with the same key. In other words, the Program will get more than one hit on the database table for the selected keys and I need to retrieve values from only the last record and not the first. I know I can use an internal table to sort the records first and then retrieve the right value. But to make things easier, is there a SELECT statement keyword than I can use to do this in one single step? Thanks!
hi,
tables:mara.
data: begin of it_mara occurs 0,
matnr like mara-matnr,
meins like mara-meins,
mtart like mara-mtart,
end of it_mara.
select-options:s_matnr for mara-matnr.
select matnr
meins
mtart
from mara
into table it_mara
where matnr in s_matnr.
if not it_mara[] is initial.
sort it_mara by matnr descending.
read table it_mara index 1.
endif.
then you get the last record of the select statement.
reward points if useful,
venkat. -
Why does safari 5.1 open with the last page from previous session?
I don't want Safari 5.1 to open with the last page from the previous session. How do I stop it?
I too would like to manually or automatically open the windows and tabs I had open from the previous session, but I want to configure this per application. In a browser for instance, I can have many windows and tabs open and it can take a lot of time to refresh them all. I would like to manually pick the windows/tabs I want to reopen. Before Lion I could restore the last session manually and I liked that ability. Firefox has a plugin for this And what if I reboot with no internet access, they all time out. With a word processor, spreadsheet, or xcode on the other hand, I like to start where I left off. Everything comes from local disk so the restart is fast. I want to control this by app, not globally. Sometime Apple can really be blind to the real needs of users, and that is to configure their envoronment the way the user needs, not the way Apple envisions the need of users.
So Apple, please give ME the opportunity to choose the apps that auto reload the last sesion and give me a manual way to reload the last session on all apps that qualify.
-KR -
It is required to get the result set from the last query.
I need this SP to return the result set from the last query.
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
alter proc spQ_GetASCBillingRateIDs2
@ScheduleID CHAR(15),
@startdate smalldatetime,
@enddate smalldatetime
as
set nocount on
truncate table tbltmpgroup
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[tbltmptbltest]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[tbltmptbltest]
exec sp_CreateTblTmpGroup
insert into tbltmpgroup
SELECT DISTINCT
case when pd.billparent = 'N' then org.eligibleorgid
else isnull(af.parentid, org.eligibleorgid) end as billorgid,
pd.individualbill , pd.cobrabill, pd.billparent,
org.eligibleorgid, org.polid, org.orgpolicyid,
pp.planid, pp.rateid,
ps.ascinvoicedate,
case when ps.ascclaimfromdate > @startdate then ps.ascclaimfromdate
else @startdate end as premiumrundayFrom,
case when ps.ascclaimtodate < @enddate then ps.ascclaimtodate
else @enddate end as premiumrundayTo,
fts.effdate, fts.termdate,
case when fts.effdate > @startdate then fts.EffDate
else @startdate end as ascStartDate,
case when fts.termdate < @enddate then fts.termdate
else @enddate end as ascEndDate
FROM premiumschedule ps (nolock)
inner join orgpolicy org (nolock)
on org.ascinvoicerungroup between ps.premiumrundayfrom and ps.premiumrundayto
inner join FundingTypeStatus fts
on fts.orgpolicyid = org.orgpolicyid
and fts.fundtype = 'ASC'
and ((fts.effdate between @startdate and @enddate)
or (fts.termdate between @startdate and @enddate)
or (fts.effdate < @startdate and fts.termdate > @enddate))
inner join eligibilityorg o (nolock)
on org.eligibleorgid = o.eligibleorgid
inner join policydef pd (nolock)
on pd.polid = org.polid
inner join policyplans pp (nolock)
on pp.polid = org.polid
inner join program p (nolock)
on pd.programid = p.programid
left join orgaffiliation af with (nolock)
on org.eligibleorgid = af.childid
WHERE ps.premiumscheduleid = @ScheduleID
AND org.orgpolicyid <> ''
go
SELECT DISTINCT z.rateid, e.enrollid, z.ascstartdate, z.ascenddate
into tbltmptbltest FROM enrollment E (nolock)
inner join tbltmpgroup z
on e.rateid = z.rateid
go
CREATE UNIQUE CLUSTERED INDEX IDXTempTable ON tbltmptbltest(enrollid)
create index IDXTemptableDates on tbltmptbltest(ascstartdate,ascenddate)
go
select distinct t.*
from tbltmpgroup t
where rateid in (
select distinct t.rateid from VW_ASC_Billing)
order by billorgid
set nocount off
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GOPlease post DDL, so that people do not have to guess what the keys, constraints, Declarative Referential Integrity, data types, etc. in your schema are. Learn how to follow ISO-11179 data element naming conventions and formatting rules (you have no idea).
Temporal data should use ISO-8601 formats. Code should be in Standard SQL as much as possible and not local dialect.
What you did post is bad SQL.
The prefix “tbl-” is a design flaw called tibbling and we do not do it. We seldom use temp tables in RDBMS; it is how magnetic tape file programmers fake scratch tapes.
If the schema is correct, then SELECT DISTINCT is almost never used.
Your “bill_parent” looks like a assembly language bit flag; we never use those flags in SQL.
“Funding_Type_Status” is an absurd name for a table. A status is a state of being, not an entity. A type is an attribute property. So this table ought to be column that is either a “funding_type” or “funding_status” (with the time period for the state of being
shown in other columns). But this hybrid is not possible in a valid data model.
Want to try again, with DDL and some specs?
--CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
in Sets / Trees and Hierarchies in SQL -
On doing a full Restore on my iMac from A time capsule, I am getting a permanent white apple screen with permanent loading wheel. This is my second attempt to restore with the same outcome. Seems like the last stage of the restore is getting stuck. Any tips on how to sort this out please.
iMac, Mac OS X (10.7.3)It just means some spammer is using your email address as the sender address for their spam. This is very easy to do - anyone can do it simply by changing the From email address in their email program. It does not mean your account was hacked or you have a virus (there are no current Mac viruses on the loose anyway, nor has there been for years).
There's nothing you can do about it. It can happen to anyone and the spammers will move on to using someone else's email address before long. -
How to get the last day of the current open fiscal period?
hi folks,
I have to display the last date of the current open fiscal period in the selection screen. Its just a display only.
if there is any function module vailable for getting that period, kindly suggest me?
thanks in advance,
cheers,
Adi.hi,
CALL FUNCTION '/BEV3/CHPERIOD_DETERMINE'
EXPORTING
date = sy-datum
version = c_version
IMPORTING
period = l_period
year = l_fiscal_year
EXCEPTIONS
period_in_not_valid = 1
period_not_assigned = 2
version_undefined = 3
OTHERS = 4.
If not use GM_GET_FISCAL_YEAR
CALL FUNCTION 'GET_CURRENT_YEAR'
EXPORTING
BUKRS = '1000' " Company Code
DATE = SY-DATUM " Date to find fiscal year for
IMPORTING
CURRM = w_currm " Current Fiscal Month
CURRY = w_curry " Current Fiscal Year
PREVM = w_prevm " Previous Fiscal Month
PREVY = w_prevy. " Previous Fiscal Year
Rgds
Anver -
Get SQL Query from the Region Source
Hi,
The below query gives me the region source code,
SELECT region_source into p_sql_stmt
FROM apex_application_page_regions
WHERE region_id = 01129836282 AND
page_id = 54 AND
application_id = 215;
Initially I use to have only the SQL region source code as mentioned below , So using the above query i use to pass the sql code to p_sql_stmt
SELECT PROJECT_ID,EMPLOYEE_ID,EFFECTIVE_DATE FROM AR_V_ADDRESS_HISTORY WHERE PROJECT_ID = :P51_PROJECT_ID
Now the changes what i did in the page region source is i am using a PLSQL return query which is mentioned below
declare
qry varchar2(32000);
begin
qry := ' SELECT PROJECT_ID,EMPLOYEE_ID,EFFECTIVE_DATE';
for c1 in ( SELECT * FROM AR_ADDRESS_TYPE)
loop
qry := qry ||
' , GET_ADDRESS_LINE_1(PROJECT_ID,EMPLOYEE_ID,' || c1.address_type_id || ' ,TO_DATE(EFFECTIVE_DATE)) "' || c1.name ||'_ADDRESS_TYPE_1"';
qry := qry ||
' , GET_ADDRESS_LINE_1(PROJECT_ID,EMPLOYEE_ID,' || c1.address_type_id || ' ,TO_DATE(EFFECTIVE_DATE)) "' || c1.name ||'_ADDRESS_TYPE_2"';
end loop;
qry := qry || ' FROM AR_V_ADDRESS_HISTORY
WHERE
PROJECT_ID = :P51_PROJECT_ID ';
return(qry);
end;
If i execute the above code in the with dbms_output.put_line in the SQL developer or TOAD it prints the sql query which i wanted, Since i am using this in a apex page i need to get the SQL code from the apex page.
Can any one please suggest me how to get this sql code using the above plsql code.
Please suggest me in this issue
Thanks
SudhirOne way to get the sql statement is
Create a global variable in the package spec where your function returns sql statement and assign the final sql statement to the package spec variable before the return.
Write a wrapper function to return the stored sql statement value.
Example code below:
create or replace package xx_test_pkg as
g_sql_stmt CLOB;
function get_sql() return clob;
function get_stored_val() return clob;
end;
create or replace body package xx_test_pkg as
function get_sql return clob ..
v_sqlstmt clob;
begin
v_sqlstmt := 'select * from emp';
-- assign to global variable before returning the value
g_sql_stmt := v_sqlstmt;
return v_sqlstmt;
end;
function get_stored_val() ....
begin
return g_sql_stmnt;
end;
end; -
Will the iPod nano 7 get a new update from the current 1.0.3?
Hey Guys I was wondering will the iPod nano 7 get a new update from the current 1.0.3?
If anyone knows or has and info or rumors pleas tell me.
Thanks
email *****
<edited by host>Apple might release small updates for 4th generation iPods touch if they find serious issues like the FaceTime problem that made Apple release iOS 6.1.5 for the 4th generation iPod touch. However, this device won't receive any major iOS update.
The 4th generation iPod touch has got 256 MB of memory, and iOS 7 devices have got 512 MB or more of memory -
Read to get the last line from a File
Hi
I am sending in a clarification , hoping that I get an efficient solution from the group, should somebody have come across this scenario and implemented.
How to read or get the last line from a text file , which usually have a no of records, without actually reading or looping through all the lines
I know there is some solution with the RandomAccessFile, but given there can be some encoding issues or so.
Please let me know if somebody have implemented the same.
Thanks n advanceThe character encoding could, indeed, be an issue especially with UTF-8. I think what I'd do is to create a byte array with the encoded, expected end of line sequence in it and work on the file in bytes. For example, seek to the last 100 bytes of the file, read those bytes and look for an EOL sequence backwards. If not found read the previous 100, 200, 400 bytes etc. until you do find an end of line. Then seek to after the EOL and read normally. Remember an EOL sequence might cross a boundary.
UTF-8 would be a problem, especially with a unix format file because you might mistake part of a multi-byte sequence for '\n'. To be reliable on UTF-8 you'd need to go back three characters looking for sequence start markers (has the previous character got the top bit set, or the one before that the first two bits set, or the one before that the top three bits). Or you could just react to an encoding exception and try another position. -
How to call a query from the backing bean ?
Hi all,
Another question for you guys :
I made a jspx page with an input form and a submit button.
When I click the submit button, the action my_action in my backing bean is executed.
This is the code :
public BindingContainer getBindings() {
return BindingContext.getCurrent().getCurrentBindingsEntry();
public String my_action() {
BindingContainer bindings = getBindings();
OperationBinding operationBinding = bindings.getOperationBinding("EmployeesView");
Object result = operationBinding.execute();
if (!operationBinding.getErrors().isEmpty()) {
return null;
I hoped that the query 'EmployeesView' was executed in this way, but I get the following exception :
java.lang.ClassCastException: oracle.adfinternal.view.faces.model.binding.FacesCtrlHierBinding cannot be cast to oracle.binding.OperationBinding
So how should I execute the query EmployeesView ?
Second part of the question : What if I typed the name an employee in my form, and I want to
execute a query that selects all the Employees with that name ?
How do I make a query with a variable as input in the WHERE clause ?
Thanks in advance.
Edited by: Facehugger on 7-apr-2010 11:15I'm still trying all the stuff you guys says, but still no result.
This is my backing bean :
+// the button action+
+public String my_action() {+
+// get the selected rows from the multiselect table and store the objectid's in an String array+
RowKeySet rks = graph_table.getSelectedRowKeys();
Iterator itr = rks.iterator();
Object key;
int nbr_objects = 0 , i = 0;
if (rks.size()>0) nbr_objects = rks.size();
+String[] objectid = new String[nbr_objects];+
while(itr.hasNext())
+{+
key = itr.next();
graph_table.setRowKey(key);
Object o = graph_table.getRowData();
JUCtrlHierNodeBinding rowData = (JUCtrlHierNodeBinding) o;
Row row = rowData.getRow();
+objectid[i] = row.getAttribute("Objectid").toString();+
i+;+
+}+
+// now get all the x and y values for these objectid's from the database out of the table history.+
BindingContainer bc = BindingContext.getCurrent().getCurrentBindingsEntry();
for (int j=0 ; j<nbr_objects; j+){+
+// get X and Y values for object number j+
DataPoints history = new DataPoints();
OperationBinding operationBinding = bc.getOperationBinding("retrieveHistory"); ===> operationBinding stays NULL ???+
+operationBinding.getParamsMap().put("OBJECTID", objectid[j]);+
Object retVal = operationBinding.execute();
+// ==> retVal should contain a List of all X and Y values for the provided objectid.+
+// while (retVal has values)+
+// {+
+// List_of_x_values.add(retVal.valueX);+
+// List_of_y_values.add(retVal.valueY);+
+// }+
history.add(List_of_x_values);
history.add(List_of_y_values):
+// call the soap method to do some calculations+
methodname.forecast(history);
+}+
+}+
In my application module :
public void retrieveHistory(String objectid) {
getHistory().setWhereClause("OBJECTID = '" + objectid + "'");
System.out.println("current query : "+getHistory().getQuery());
getHistory().executeQuery();
public ViewObjectImpl getHistory() {+
return (ViewObjectImpl)findViewObject("History");+
The query for the VO History : SELECT * FROM HISTORY
Please anyone ?
Edited by: Facehugger on 9-apr-2010 14:19
Maybe you are looking for
-
Can items from a list be copied and pasted into a new Pages Table?
In iWork Pages, I have a list of 50's & 60's recording artists and their songs, (which is about 40 pages long) from my '45 rpm record collection for my Jukebox. Is there any way to copy and paste the artists' names, and their songs into a Pages Table
-
IBooks in OS X Mavericks - Doesn't open after adding PDF
HELP! I broke my iBooks app on Mavericks and need a fix to make it work again! I dragged and droped a PDF into iBooks on my MacBook Air (hoping that the PDF would then end up on my iPhone iBooks App too) but then iBooks on the MacBook crashed with an
-
How do I save title settings in FCPX?
Hi, I'm trying to find out how I can save title settings so that I don't have to redo everything each time I create a video. Specifially, I go into the Titles Browser and select "Gradient - Edge" which I then drag onto the timeline for my video. I th
-
How to watch my Mac iPhoto Library on my iPhone?
Hi, is there a way to watch my Mac iPhoto Library on my iOS devices using Home WiFi? I am regurarly sharing my music, clips, films etc, but cannot find a way to share my Photos, although photo sharing is activated on my iPhoto mac... I can see it fro
-
"No data available" in BEx Query
There seems to be some serious issue. I created a Query but when i execute it, It returns me with an error like "no applicable data found" or 'no data available" or sometimes it is returning some weird data. The issue here is that i don't have the a