How to rewrite sql statement?
Hello my query goes like this:
select a, b, c
from (select 5 a , null b, null c from dual
union all
select null, 4, null from dual
union all
select 10, 3, null from dual) test_tab;
and i wanna get result
5 null null
null 4 null
10 null null
null 3 null
How can i rewrite query without changing the structure of a table?
Regards,
Igor
Your data ->
select 10, 3, null from dualAnd, your expected output ->
10 null null
null 3 nullWhat is the logic behind this split?
Please explain.
Regards.
Satyaki De.
Similar Messages
-
How to find sql statement with Unix process pid
Hi
how to find sql statement with Unix process pid
is there any view to find that.
please if so let me know
Thanks in advancethis is how I am doing this:
oracle 7352340 7459066 0 07:47:10 - 0:00 oracleJDERED (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))
oracle 7459066 5386396 2 07:47:10 pts/1 0:01 sqlplus
select sid,serial# from v$session where process='7459066';
SID SERIAL#
2178 6067
select sql_text
from
v$sqlarea a,
v$session b
where a.hash_value = b.sql_hash_value
and b.sid = 2178
; -
we have 1 server oracle and many clients.
when client sends sql statement to server.How to Capture sql statement to analysis berfore it sent to server and execution.
Edited by: 955185 on Aug 27, 2012 4:22 AM955185 wrote:
yes. how to do this?Check these link all of them talking about Already executed sql in database by Users , but i don't know if what you ask is possible since they already connect to database
If you attending to analysis sql read the below links and start your analysis,
Last executed sql
http://www.databasejournal.com/features/oracle/article.php/3373701/Watching-SQL-Execute-on-Oracle---Part-I.htm
http://stackoverflow.com/questions/55899/how-to-see-the-actual-oracle-sql-statement-that-is-being-executed -
How to find SQL Statement fired using SYS.AUD$ - Database Auditing
Dear Friends
I am having Oracle 9i Database and have configured it with database auditing option by setting the following parameter in init.ora file
AUDIT_TRAIL = "DB"
I want to audit SELECT, INSERT , UPDATE and DELETE operations on PRACTICE.EMP table for which I did :
1) Logged in as SYS
2) SQL> AUDIT SELECT, INSERT, UPDATE, DELETE
ON PRACTICE.EMP
BY ACCESS
WHENEVER SUCCESSFUL;
Audit Succedded
Now how should I find out the SQL statement that does the insert, update or delete operation on the EMP table using SYS.AUD$ table
ThanksHi,
It's contents can be viewed directly or via the following views:
* DBA_AUDIT_EXISTS
* DBA_AUDIT_OBJECT
* DBA_AUDIT_SESSION
* DBA_AUDIT_STATEMENT
* DBA_AUDIT_TRAIL
* DBA_OBJ_AUDIT_OPTS
* DBA_PRIV_AUDIT_OPTS
* DBA_STMT_AUDIT_OPTS
The audit trail contains a lot of data, but the following are most likely to be of interest:
* Username : Oracle Username.
* Terminal : Machine that the user performed the action from.
* Timestamp : When the action occured.
* Object Owner : The owner of the object that was interacted with.
* Object Name : The name of the object that was interacted with.
* Action Name : The action that occured against the object. (INSERT, UPDATE, DELETE, SELECT, EXECUTE)
So, take a look at action_name column from DBA_AUDIT_TRAIL view.
Cheers
Legatti -
How to find SQL statement = Database Auditing
Dear All
I have configured Database Auditing on Oracle 9i Enterprise Edition Server
parameter init.ora file:
AUDIT_TRAIL = "DB"
I want to audit INSERT,UPDATE, DELETE STATEMENT on PRACTICE.EMP table
for which i did :
1) Logged in as SYS
SQL> AUDIT INSERT,UPDATE,DELETE
ON PRACTICE.EMP
BY ACCESS
WHENEVER SUCCESSFUL
Audit Succedded
2) Now I have to check the SQL statement that did insert update or delete operation using SYS.AUD$
3) There is SQLTEXT field , datatype is CLOB.
How should I check the SQL Statements that were fired on PRACTICE.EMP table
Kindly helpSQL> show user
USER is "SYS"
SQL> alter system set audit_trail = db,extended scope=spfile;
alter system set audit_trail = db,extended scope=spfile
ERROR at line 1:
ORA-32001: write to SPFILE requested but no SPFILE specified at startup
I have init.ora but no spifle so should I create SPFILE based on INIT.ORA and then give the command ?
As of now I am using V$SQL view to find all the commands executed on my database.
I found one good book "Oracle Security" OREILY PUBLICATION in which Auditing Database is discussed in good details.
Thank you so much for all your efforts -
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. -
How to retrieve SQL statement in the CR 2008
I'm using Crystal Reports 2008 in MS Visual Studio 2008, how can i retrieve SQL statement from *.rpt file, i have tried this code, but it doesn't work:
ReportDocument rdReport = new ReportDocument();
rdReport.Load("Reports/EmployeeTest.rpt", OpenReportMethod.OpenReportByTempCopy);
CrystalDecisions.ReportAppServer.Controllers.RowsetController rsController;
CrystalDecisions.ReportAppServer.ClientDoc.ISCDReportClientDocument rdClient = rdReport.ReportClientDocument; // on this line it throws an exception "The ReportClientDocument property can only be accessed when the report is opened using a Report Application Server."
CrystalDecisions.ReportAppServer.DataDefModel.ISCRGroupPath rdGroupPath = new CrystalDecisions.ReportAppServer.DataDefModel.GroupPath();
string temp;
string sql;
rsController = rdClient.RowsetController;
sql = rsController.GetSQLStatement(rdGroupPath, out temp);
maybe i'm doing something wrong ?
thanksHello Ludek,
when I try to get the report from the session I got an error like this (I am using State Server Session mode i.e out proc in my application)
ReportClientDocument 'reportDocument.ReportClientDocument' threw an exception of type 'System.InvalidOperationException' CrystalDecisions.ReportAppServer.ClientDoc.ISCDReportClientDocument {System.InvalidOperationException}
+base {"The ReportClientDocument property can only be accessed when the report is opened using a Report Application Server."} System.SystemException {System.InvalidOperationException}
StackTrace " at CrystalDecisions.CrystalReports.Engine.ReportDocument.get_ReportClientDocument()" string
so is it the problem of not opened with RAS. Does installation of RAS solves the problem, If so Is it a free-ware or needs to be purchased.
Ashok -
How to monitor SQL statements issued by SIEBEL ?
Hi,
We have developed BI Siebel 10.1.3.3. application.
One of the requirement is to persist/store in the database real SQL statement issued by BI Dashboards/Answers.
The best solution would be having acces on-line to cursor cache.
Could someone please tell me how to achive this ?
Regards,
CezarySounds like you're looking for Usage Tracking.
OBIEE Server Administration Guide – Pages: 220
OBIEE Installation and Configuration Guide – Pages: 229
And this post here;
http://oraclebizint.wordpress.com/2007/08/14/usage-tracking-in-obi-ee/
A. -
How to execute SQL statement with oracle jdev
Please I'm a beginner in oracle jdeveloper. I want to know how to use and execute sql statememt within oracle Jdeveloper 10 g release 3 to manipulate objects in oracle database. I want for e.g. to Enable/disable trigger using sql statement "ALTER TRIGGER trigername DISABLE" explicitly. Please tell me how to proceed.
i am sure you can help me
Sincerly yours.Hi,
Using following tutorial http://www.oracle.com/technology/obe/ADF_tutorial_1013/10131/index.htm
you will found how to connect from Jdev to a database (chapter 1 or 2 ?). Then you just have to go under Tool>SQL*Plus or Tools>SQL Worksheet depending on what you need.
Luck,
Tif -
How to execute sql statement under bat file?
I want to execute following statement
C:\>sqlplus /nolog
SQL> conn scott/tiger
SQL> select * from tab;
I know I can realize it as following test.bat and testdb.sql file
test.bat is follows:
sqlplus /nolog @testdb.sql
testdb.sql is follows:
conn scott/tiger
select * from tab;
Now I don't want to use sql file,I only want to use bat file,like follows:
test.bat is follows:
sqlplus /nolog
conn scott/tiger
select * from tab;
when I run test.bat,I find only sqlplus /nolog statement execute,the other statements don't execute.
1)I want to know whether there is a method to execute sql statement only by bat file without a sql file? How to realize it?
2)If I call sql file,how to hide passord of user? Because I don't want to other persons know scott password,if I use conn scott/tiger in testdb.sql,other person can see testdb.sql and know the password. Is there a good method to avoid?
Thanks!I'm running *NIX, but works the same on Windows
bcm@bcm-laptop:~$ cat here.sh
sqlplus dbadmin/admindb << EOF
select count(*) from user_objects;
exit
EOF
bcm@bcm-laptop:~$ sh here.sh
SQL*Plus: Release 11.2.0.1.0 Production on Mon May 17 18:14:09 2010
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL>
COUNT(*)
9
SQL> Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
bcm@bcm-laptop:~$ Edited by: sb92075 on May 17, 2010 6:15 PM -
How to process sql statements stored in a table
I have a rule table that contain rule_type, rule_status and rule_condition. The rule condition is a sql statement. In a report I need to be able to expand this condtion based on the status selected. E.g When rule status is terminated the rule_condition is as below. When a user pick terminated status, I need to be able to go to the table and expand the sql statement. Another example is active status.
RULE_STATUS TERMINATED
SELECT leaseid
FROM leatatt
WHERE txtattid = 'LEAS END'
and value = 'TERMINATED'
RULE_STATUS ACTIVE
SELECT leaseid
FROM lease
WHERE redoc_class = 'MASTER'
AND TRUNC(SYSDATE) <=
NVL(TRUNC(enddate),TRUNC(SYSDATE)+1)
AND functional_status IN ('ACTIVE','OVERHOLD')
Any suggestion will be appreciated.Please refer to
http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:246014735810
I am sure you would be twist this to bring it in to your use.
<PRE>
the proper way to do this is to NOT use a PLSQL table type but to use a SQL Object Type
instead. It would look like this:
[email protected]> create or replace type myScalarType as object
2 ( x int,
3 y date,
4 z varchar2(25)
5 )
6 /
Type created.
[email protected]> create or replace type myTableType as table of myScalarType;
2 /
Type created.
[email protected]> create or replace
2 function demo_proc( p_start_row in number,
3 p_end_row in number )
4 return myTableType
5 as
6 l_data myTableType := myTableType();
7 l_cnt number default 0;
8 begin
9 for x in ( select * from emp order by sal desc )
10 loop
11 l_cnt := l_cnt + 1;
12 if ( l_cnt >= p_start_row )
13 then
14 l_data.extend;
15 l_data(l_data.count) :=
16 myScalarType( x.empno,
17 x.hiredate,
18 x.ename );
19 end if;
20 exit when l_cnt = p_end_row;
21 end loop;
22
23 return l_data;
24 end;
25 /
Function created.
[email protected]> select *
2 from the ( select cast( demo_proc(2,6) as mytableType )
3 from dual ) a
4 /
X Y Z
7788 09-DEC-82 SCOTT
7902 03-DEC-81 FORD
7566 02-APR-81 JONES
7698 01-MAY-81 BLAKE
7782 09-JUN-81 CLARK
[email protected]>
</PRE> -
How to find SQL Statements for BW queries ?
Experts,
Is there a way, we can see what SQL statement BW queries creates ?
please Help.Hi,
use sql trace: transaction ST05.
ask your database admin. He can control the database session.
=> for oracle: you can see the session also in the sap gui.
Sven -
How to write Sql statement for M:M relationship set?
If theres two Entity sets "Department" and "Employee".....
Department Entity contains this attribute dno,dname,address etc and
"Employee" entity contain attribute like Empno,Empname,date,time etc
and theres Many to Many relationship between Employee and Deapartment Entity set,i.e.each employee can work in any department, and each department has at least one employee (Many to Many relationship)
What should be the SQL statement to create table for Many to Many relationship sets for Employee and Department set..
Any helps will be appreciated.
Femicreate 3 tables: employee, department and empdept
in the empdept table you reference foreign keys from the 2 other tables. so if my employee id was 42 and I work for departments 1,2 and 3, this table would look like this:
emp_fk | dept_fk
42 1
42 2
42 3 -
How to Retrieve SQL Statements in RDF Reports
I need to retrieve the SQL statements from my reports without having to call each of them up in Reports Builder. The reports are in binary (RDF format). Does anyone know of a way to do this?
Hello,
Convert your RDF into a text format :
- REX
- XML/HTML/JSP if your are using Reports 9.0.x or greater)
and search in these text files .
Regards -
How to store sql statement in oracle table?
I tried it in this way:
SQL> insert into sql_text values('select invoice,invoice_dt,DT_INVOICED from PS_BI_HDR where DT_INVOICED= '21
JAN-2010' and BILL_STATUS='INV'');
insert into sql_text values('select invoice,invoice_dt,DT_INVOICED from PS_BI_HDR where DT_INVOICED= '21-JAN-
010' and BILL_STATUS='INV'')
ERROR at line 1:
ORA-00917: missing comma
Please help to solve it, i can't use concatenation (||),
coz
'select invoice,invoice_dt,DT_INVOICED from PS_BI_HDR where DT_INVOICED= '21-JAN-2010' and BILL_STATUS='INV' 'it is dynamic.user2060331 wrote:
No sql statement is a dynamic value inserted by a user for executing it on SQl prompt.Then use q-literals:
SQL> ACCEPT stmt PROMPT "Enter statement: "
Enter statement: select invoice,invoice_dt,DT_INVOICED from PS_BI_HDR where DT_INVOICED= '21-JAN-2010' and BILL_STATUS='INV'
SQL> insert into sql_text values('&stmt');
old 1: insert into sql_text values('&stmt')
new 1: insert into sql_text values('select invoice,invoice_dt,DT_INVOICED from PS_BI_HDR where DT_INVOICED= '21-JAN-2010' and BILL_STATUS='INV'')
insert into sql_text values('select invoice,invoice_dt,DT_INVOICED from PS_BI_HDR where DT_INVOICED= '21-JAN-2010' and BILL_STATUS='INV'')
ERROR at line 1:
ORA-00917: missing comma
SQL> insert into sql_text values(q'[&stmt]');
old 1: insert into sql_text values(q'[&stmt]')
new 1: insert into sql_text values(q'[select invoice,invoice_dt,DT_INVOICED from PS_BI_HDR where DT_INVOICED= '21-JAN-2010' and BILL_STATUS='INV']')
1 row created.
SQL> SY.
Maybe you are looking for
-
8350 I acting squirrely since downloadin​g OS update
All sorts of unhappy things are going on since I updated my operating system. Perhaps the most annoying is the fact that I can no longer use every song in my song library as a potential ringtone. I had carefully chosen appropriate ringtones for indiv
-
i had bought an iphone4s from an american he gave me some instructions of operation it worked for amonth fairly one day after updating it stopped working and not connectig to the network what can i do ? canany one suggest asolution.
-
Adobe files not updated in Windows 7
This is an ongoing source of irritation ... when working on Indesign, Photoshop files, and I save changes, the new date isn't saved, the file always retains the original date. This is a pain since I usually search for the most recent files first. Any
-
Apple wireless Mighty Mouse not working in Windows XP Pro/Boot Camp
I was able to get Windows XP Pro to install successfully on my new iMac, but I can only get a wired Microsoft USB mouse to work with it. When I boot to WinXP with just my wireless Mighty Mouse, the wireless mouse is completely unresponsive. Has anyon
-
Premier Pro CC crashes on Mavericks after relocating user profile
Slowly but surely my OSX environment is being extricated from the absolute lunacy that every file used by any application had to reside on the machine's root drive. Adobe Premiere Pro, for example, created a $USER/Documents/Adobe subdirectory where