How to get the SQL queries based on SQL_ID.
Hi Experts,
I want to get the SQL queries based on SQL_ID.
I have tried the following query,but I am not getting full query.
[code]SET linesize 132 pagesize 999
column sql_fulltext format a60 word_wrap
break on sql_text skip 1
SELECT REPLACE (TRANSLATE (sql_text, '0123456789', '999999999'), '9', ''),sql_id
FROM dba_hist_sqltext s
WHERE s.sql_id = '7tvurftg8zryb';[/code]
One of my friend said use grid to get full query text.
Can you please help me how to use grid ,else any other method to get the full query based on SQL_ID.
Please help me.
Thanks in advance.
You have these many options to set, if sql_text is really huge. But better use a tool(TOAD) as it's really helpful and easy to use instead! (See my previous comment).
column sql_text format A10000
set echo off
set head off
set feed off
set verify off
set termout off
set lines 10000
set long 1000000
set trimspool on
set pages 0
Thanks!
Similar Messages
-
How to get the SQL Signon that Agent Jobs "Run As" or "Executed as User"
How to get the SQL Signon that Agent Jobs "Run As" or "Executed as User"?
I have an install SQL scripts that creates a Linked Server. I want to put some security on the Linked Server and only grant the Agent Job Signon (the "Run As" or "Executed as User") access to the linked server. I need to retrieve the
Agent Job Signon (something like "NT SERVICE\SQLAgent$FIDEV360BI02").
I could query certain jobs and SUBSTRING the Message column - using some form of the query below, which would return "Executed as user: NT SERVICE\SQLAgent$SSDEVBI02. The step succeeded." But that is pretty imprecise.
use msdb
SELECT [JobName] = JOB.name,
[Step] = HIST.step_id,
[StepName] = HIST.step_name,
[Message] = HIST.message,
[Status] = CASE WHEN HIST.run_status = 0 THEN 'Failed'
WHEN HIST.run_status = 1 THEN 'Succeeded'
WHEN HIST.run_status = 2 THEN 'Retry'
WHEN HIST.run_status = 3 THEN 'Canceled'
END,
[RunDate] = HIST.run_date,
[RunTime] = HIST.run_time,
[Duration] = HIST.run_duration,
[Retries] = HIST.retries_attempted
FROM sysjobs JOB
INNER JOIN sysjobhistory HIST ON HIST.job_id = JOB.job_id
-- CHANGE THIS
-- WHERE JOB.name like '%GroupMaster%' or Job.name like '%etlv%'
ORDER BY HIST.run_date, HIST.run_timeby default all sql jobs are executed as sql server agent account, unless otherwise a proxy is setup.
you can get the proxy information as Olaf mentioned, if the proxy_id is null for the step, it implies that the job step was executed as sql server service account and in such case it will be null
so, if it is null, it ran as sql server agent account.
so, one work around is get the sql server agent service account and if the proxy is null, that means it ran as sql server agent account, so, use isnull function. the disadvantage would be if the sql server agent account was switched, you might not get the
accurate information as the new account will show up though the job really ran as old account, to get this information, you need to get this from the logmessage column as you mentioned above.
try this code...
/*from sql 2008r2 sp1, you get the service accounts using tsql,otherwise you have to query the registry keys*/
declare @sqlserveragentaccount varchar(2000)
select @sqlserveragentaccount= service_account
from sys.dm_server_services
where servicename like '%sql%server%agent%'
select message,isnull(name,@sqlserveragentaccount) as AccountName
from sysjobhistory a inner join sysjobsteps b
on a.step_id=b.step_id and a.job_id=b.job_id
left outer join sysproxies c on c.proxy_id=b.proxy_id
Hope it Helps!! -
How to get the pricing hierarchy based on the delivery date for sales order
Hi,
How to get the pricing hierarchy based on the delivery date for sales order other than system date.
My requirement is to get the Pricing hierarchy based on the delivery date other than system date.
Waiting for kind response.
Best Regards,
BDPHI Sai,
please refer teh document already how to write FM based extration on generic extractors.
and here the logic to find the latest records values:-
-> get the data in an internal table
->Sort the internal table data based from date descending
-> Using READ statement , we can read the first record of the table which is nothign but your latest record.
Regards.
Sakthi -
How to get the SQL Execution Plan from complex Extractors ?
Hi
I am looking for a way to get the
SQL Execution Plan(s!)
from
Complex Extractors like 0CO_OM_CCA_9 ?
Anybody has got a suggestion ?
How to get this in SM50 ?
ThanXs
MartinIdentifying the query is the hard part. If you can identify it(based on table access or some such parameter, getting the execution plan is easy in ST04 .
-
I cannot figure how to get the text(SQL statement) from a system view(i guess it is in a system view... but witch??). 'Till now i have the sql_address and the sql_hash_value..
I know it is possible.. EM does it ... so i should be able to do the same..
ps:I use 9.2v$sql ?
-
How to get the SQL file name in SQL*plus
hi all,
I have created two sql file at C drive as "c:\Createtable.sql" and "c:\Deletetable.sql"
afterwards i open
C:\>sqlplus
SQL*Plus: Release 10.2.0.1.0 - Production on Wed Jan 30 11:37:10 2008
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Enter user-name: scott/tiger
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL> @C:\Createtable.sql'
Table created.
SQL> @'C:\Deletetable.sql'
Table dropped.
SQL>My problem is to get the name of the file as "c:\createtable.sql" and "C:\Deletetable.sql" in sql*plus enviornment.
Thanks & Regards
SinghDear Damorgan,
>>your version number to three decimal places
My Oracle DB Version i have already stated in my previous post is 10.2.0.1.0
Actually my problem is to get the sql files name we run in sqlplus enviornment with @ symbol. like
i have created one sql file in c drive as
"C:\Createtable.sql"
afterwords i have connected to sqlplus as
sql> conn scott/tiger
sql>@c:\createtable.sql
Now i want some query to get the name of the file which is run.
In actual my problem is as
i have suppose 10 or more SQL files in some folder ( sql1.sql, sql2.sql, sql3.sql ....).
i created one file to call all the 10 sql files (main.sql)
i have also one track_table which will keep track that which sql file is runned.
I want some automated script which will insert the record in that track_table....... for that i need the name of sql file which is runned.
Hope this will help you.
Thanks & Regards
Singh -
How to get the Sql inside Omni SQL portlet.
Hi,
We are trying to find a table/view which stores/holds the Sql and Pl/Sql code of Omni Pl/sql portlets.
Thanks,
Ram.by default all sql jobs are executed as sql server agent account, unless otherwise a proxy is setup.
you can get the proxy information as Olaf mentioned, if the proxy_id is null for the step, it implies that the job step was executed as sql server service account and in such case it will be null
so, if it is null, it ran as sql server agent account.
so, one work around is get the sql server agent service account and if the proxy is null, that means it ran as sql server agent account, so, use isnull function. the disadvantage would be if the sql server agent account was switched, you might not get the
accurate information as the new account will show up though the job really ran as old account, to get this information, you need to get this from the logmessage column as you mentioned above.
try this code...
/*from sql 2008r2 sp1, you get the service accounts using tsql,otherwise you have to query the registry keys*/
declare @sqlserveragentaccount varchar(2000)
select @sqlserveragentaccount= service_account
from sys.dm_server_services
where servicename like '%sql%server%agent%'
select message,isnull(name,@sqlserveragentaccount) as AccountName
from sysjobhistory a inner join sysjobsteps b
on a.step_id=b.step_id and a.job_id=b.job_id
left outer join sysproxies c on c.proxy_id=b.proxy_id
Hope it Helps!! -
How to get the sql query result?
Hi,
Currently I am using LV2012 to connect a Oracle database server. After the installations/settings for Oracle Express and Oracle ODBC driver done.
I am sucessfully to use the SQL command to query the data through my window command prompt.
Now the problem is, how I do the same task in Labview by using the database connectivity toolkits?
I have build a VI for query as attached, but i have no idea what pallete to use to get the query result.
Please help me ~~
Solved!
Go to Solution.
Attachments:
Query.vi 9 KBHere is a piece of code I use to test SQL commands, you can use the part that retrieves sql results.
It is also possible to get the column headers back, but that is for next lesson!
Attachments:
RunSQLCommand.vi 30 KB -
How to get the sql which executing?
I want to know the query sql runing in timesten? how can I get it?
For example, in oracle 9i we can use below sql to get the query sql runinig in oracle.
1.select OSUSER, PROGRAM, USERNAME, SCHEMANAME, B.Cpu_Time, STATUS, B.SQL_TEXT
2. from V$SESSION A
3. LEFT JOIN V$SQL B ON A.SQL_ADDRESS = B.ADDRESS
4. AND A.SQL_HASH_VALUE = B.HASH_VALUE
5. order by b.cpu_time desc
thanks!Sorry, there is no way to get this information in TimesTen. You can use internal tracing to see each SQL statement as it is executed but (a) the performance hit is severe and (b) there is no timing or CPU usage information available.
If you want to know how long a specific SQL statement takes to execute you need to add timing instrumentation to your application code.
Chris -
?How to get the SQL being executed
Hi, this is a 2 part question, note that I'm using 10.1.0.3:
1) When running queries against a ROLAP cube (using BI Beans or the Excel addin), how can I trace the SQL that is being executed?
2) When using a MOLAP cube, its no longer required to "enable" the cube for SQL access. However, my question is, if I want to query it using a standard SQL tool, how do I do this? It doesn't seem like there are any views, etc. that I can query against?
Thanks!
ScottHi Scott,
1) When running queries against a ROLAP cube (using BI Beans or the Excel addin), how can I trace the SQL that is being executed?
Tracing the SQL that is executed by a session is a fairly well documented process. Basically, you can either enable tracing for your own personal session, or you can enable tracing for someone else's session. See http://www.petefinnigan.com/ramblings/how_to_set_trace.htm for a pretty definitive writeup, or http://www.rittman.net/work_stuff/tracing_owb_mappings_pt1.htm for example of using trace with OWB (similar sort of concept)
2) When using a MOLAP cube, its no longer required to "enable" the cube for SQL access. However, my question is, if I want to query it using a standard SQL tool, how do I do this? It doesn't seem like there are any views, etc. that I can query against?
Best to check with Oracle, but my understanding is that 10.1.0.3A upwards enabled the cube for the OLAP API, not SQL access - the difference being that enabling for OLAP API creates the metadata that the OLAP API requires, which used to be ( < 10.1.0.3 ) stored in the OLAPSYS schema, and is now contained within objects in the AW itself. If you want to enable for SQL access, you'll have to create views using the OLAP_TABLE function as before, although I don't think you need to create the ADTs (abstract datatypes, the object definitions previously required) anymore.
HTH
Mark -
How to get the SQL Statement of a report region?
For example: The SQL of report region such as "SELECT A,B,C FROM T1 WHERE A = :P10_A".
I hope to get the converted statement (the variable has been replaced), like this:
:P10_A = 'TOM', SQL: "SELECT A,B,C FROM T1 WHERE A = 'TOM'".
THX.I agree with John with the usual caveat about using bind variables.
In other words, you should use
SELECT A,B,C FROM T1 WHERE A = :P10_Ainstead of SELECT A,B,C FROM T1 WHERE A = 'foo'so that the shared pool doesn't get clutterred with copies of the same (sharable) SQL.
Even if you use the "PL/SQL function returning a SQL query", be sure to use bind variables in your SQL and not "glue in" session state by concatenating it into the query.
Thanks. -
How to get the sql id and sql text for the pid which is completed.
Hi All,
I like to know how the get the details of sql_id and sql_text using the proecess which is completed already (ie., no more showing in the top command).
But I have the details of the process id.
Database name: 11g
os: sun os
thanks
Edited by: user9354175 on Nov 8, 2010 10:42 AMIf the session is still connected you might try this:
- query v$process where spid = os-process-number
- then join v$process to v$session using ADDR (in process) to PADDR (in session)
- then look at PREV_SQL_ID in v$session.
- use that to get the SQL_TEXT in for instance V$SQLAREA.
Could work, if all info is still in the SGA... -
How to view the sql queries generated by EJB (CMP)
Hello,
I'm using Oracle9iAS (9.0.2.1.0) Containers for J2EE (build 020827.1652) & Oracle 8.1.7 database.
I have a CMP that has about 400 fields and the corrsoponding table has about 800 fields. I'm able to call create and add a row in database.
Now when I call update method to set the remaining fields of this row (I get the proper instance by calling findByPrimaryKey()) I'm getting an exception ORA-00957 duplicate column name.
I'm using reflection to set all the fields by passing my update method a HashMap and setting those fields that this HashMap contains. And as HashMap cannot contain duplicate keys the possiblility of having duplicates is eliminated.
But why am I getting ORA-00957 duplicate column name.
Is there a way I can configure somehow to view what sql query is being generated by the OC4j container when its firing this query to update the database table.
Any help will be greatly appriciated.
Vipin.Install IronTrack SQL as described in the following link
http://www.irongrid.com/documentation/irontracksql/install.html#install_oracle9iAS -
How to get the SQL Query statement of a Search Form ?
Hi all,
We have a requirement to send the query result of an ADF Search Form into report application (Crystal rpt).
Crystal can accept data source as query statement. SO I think of getting the exact query statement "generated" by the ADF Search form and send it to crystal.
Is this possible ?
Thank you very much,
xtantoTry the various get methods of the viewObject such as getQuery:
http://www.oracle.com/webapps/online-help/jdeveloper/10.1.2/state/content/navId.4/navSetId._/vtAnchor.getQuery%28%29/vtTopicFile.bc4jjavadoc%7Crt%7Coracle%7Cjbo%7CViewObject%7Ehtml/ -
How to get the Equity Share (%) based on a BSEG record
Dear JVA experts,
I have to model a relation with BSEG and JVA tables to get the Equity Share from T8JQ.
it has been proposed to me to build a relation as follows:
BSEG-BELNR - BKPF-BELNR
BKPF-AWKEY -> JVSO1-REFDOCNR
BKPF-GJAHR -> JVSO1-REFYEAR
BKPF-BUKRS -> JVSO1-RBUKRS
get JVSO1-VNAME
finally get T8JQ-VNAME and get T8JQ-EQSHARE.
My question to you.
I have found that in BSEG there are some JVA fields. Would it be possible to model another relation in order to get the Equity Share from T8JQ from a BSEG record, avoiding the reading of JVSO1 ?
thanks in advance for your help ?
best regards,
LoryHi Lory,
You can refer BSEG table to mapp with T8JQ to retrieve Equity share. You have not mentioned what are the line item you would consider to retrieve Equity share details. If you are not considering clearing documents which normally refer the line item which has to be cleared for JV details, will have not JV information to get corresponding Equity share details from T8JQ
Example:
I have two line items
Doc No
1 . DR 400 JV1
2 Doc No. CR 400 -- Clearing document
Maybe you are looking for
-
How do I create / print a unique form ID?
I have created a simple work order. I have the need of assigning the work order an ID of some kind. I'm not really concerned about the ID topology. The ID should not be incremented for page copies. So let's say I had a hypothetical ID of 9000 and I p
-
How to do Regression Testing in XI
Hello: We are doing some patch upgrade for XI from SP13 to SP16 and we are planning to do some regression testing in Dev, then in QA and then in Prod. Are there any steps to take or is there any blog or PDF, links on how to do such regression testing
-
When uploading videos to iWeb, the video screen gets cut off at the top. It only happens in Firefox, but not in Safari. Has anybody else had this problem?
-
How to dubug the IDoc-- I got the 51 error meesage.
How to dubug the IDoc-- I got the 51 error meesage. I got 51 errormessage: No batchinput data for screen. Please let where i can debug this.
-
Hi all, We would like to authenticate users L3 adjacent to the NAC appliance server. The NAC is setup as OOB virtual gateway. Is that possible, what should be the configuration ?