How to store query results into a table
I want to store the query results to a table. Is there a way to automatically redirect output to a table without using a PL/SQL script.
Run the following step only once unless you want to create the tabX everytime
Create tabX as select x,y,z from tabY;
Next time when you want to store the new results, run the following statement
Insert into tabX select x,y,z from tabY;
Similar Messages
-
How to store an image into database table
Hi
Can anyone tell me the way, how to store an image into database table.Hello,
May be this thread will help you in your requirement.
[FM for uploading Image to SAP;
Thanks,
Jayant -
I had run a query I want to insert that query result into another table how it is please suggest me
1
1
EC101
P
15
P
40
2010-11-01
1
2
1
EC102
P
10
P
30
2010-11-01
1
3
1
EC103
P
8
P
50
2010-11-01
1
4
1
EC104
P
5
P
25
2010-11-01
1
5
1
EC105
P
10
P
40
2010-11-01
1
6
1
EC106
P
12
P
45
2010-11-01
1
7
2
EC101
P
20
P
50
2010-11-01
1
8
2
EC102
P
15
P
60
2010-11-01
1
9
2
EC103
P
20
P
80
2010-11-01
1
10
2
EC104
P
14
P
46
2010-11-01
1
11
2
EC105
P
18
P
74
2010-11-01
1
12
2
EC106
P
16
P
68
2010-11-01
1
13
3
EC101
P
10
P
40
2010-11-01
1
14
3
EC102
P
20
P
60
2010-11-01
1
15
3
EC103
P
12
P
40
2010-11-01
1
16
3
EC104
P
20
P
50
2010-11-01
1
17
3
EC105
P
12
P
40
2010-11-01
1
18
3
EC106
P
14
P
60
2010-11-01
1
19
4
EC101
P
10
P
30
2010-11-01
1
20
4
EC102
P
14
P
40
2010-11-01
1
21
4
EC103
P
12
P
50
2010-11-01
1
22
4
EC104
P
8
P
46
2010-11-01
1
23
4
EC105
P
4
P
25
2010-11-01
1
24
4
EC106
P
16
P
68
2010-11-01
1
25
1
EC201
P
10
P
42
2011-04-01
2
26
1
EC202
P
18
P
60
2011-04-01
2
27
1
EC203
P
8
P
50
2011-04-01
2
28
1
EC204
P
10
P
40
2011-04-01
2
29
1
EC205
P
8
P
30
2011-04-01
2
30
1
EC206
P
20
P
50
2011-04-01
2
31
2
EC201
P
10
P
40
2011-04-01
2
32
2
EC202
P
12
P
45
2011-04-01
2
33
2
EC203
P
12
P
46
2011-04-01
2
34
2
EC204
P
20
P
40
2011-04-01
2
35
2
EC205
P
10
P
40
2011-04-01
2
36
2
EC206
P
10
P
48
2011-04-01
2
37
3
EC201
P
20
P
60
2011-04-01
2
38
3
EC202
P
18
P
70
2011-04-01
2
39
3
EC203
P
15
P
80
2011-04-01
2
40
3
EC204
P
18
P
78
2011-04-01
2
41
3
EC205
P
16
P
65
2011-04-01
2
42
3
EC206
P
10
P
30
2011-04-01
2
43
4
EC201
P
20
P
50
2011-04-01
2
44
4
EC202
P
14
P
10
2011-04-01
2
45
4
EC203
P
15
P
40
2011-04-01
2
46
4
EC204
P
20
P
46
2011-04-01
2
47
4
EC205
P
10
P
50
2011-04-01
2
48
4
EC206
P
8
P
40
2011-04-01
2
from this table I want take the semester wise result and after that I want to take that result into new table and I want take the rank also
howHey,
Just perform an INSERT AS SELECT and don't forget to add APPEND hint. Also, you can do it using parallelism so before that just enable DML parallel for the IAS. Below are the commands:
SQL> ALTER SESSION ENABLE PARALLEL DML;
SQL> INSERT /*+ APPEND */ INTO NEW_TABLE (SELECT * FROM TABLE_QUERY);
Regards.
caadecarvalho -
How to pass query result to HTML table?
Hi,
i want to get the query result in HTMl table instead of Display Grid. how to do it? i searched in help, it suggests use icommand to do this. but i dont know how to pass the select query result to HTML table.. please help me.
-senthilHi Senthil,
You can create an icommand query. You can then use the icommand retrieval methods to capture and manipulate the query data.
(http://help.sap.com/saphelp_xmii115/helpdata/en/Applet_Reference_Details/iCom
mand_Reference.htm)
Basically what we did was, use the getColumnCount() and getRowCount() methods, once you have these two numbers you can set two for loops and use String getValue(int ColID, int RowID) , within the for loops you can generate the inner html content and write the values either in a html table or html form (which is what we did). This seems to work well, I'm still playing around with it and may post this approach on sdn by end of this week.
Mahwish -
How to store XML data into Oracle Table
I had trouble to store XML data into Oracle Table with XDK (Oracle 8.1.7 ). The error is:
C:\XDK_Java_9_2\xdk\demo\java\Test>java testInsert Dept.xml
<Line 1, Column 1>: XML-0108: (Fatal Error) Start of root element expected.
Exception in thread "main" oracle.xml.sql.OracleXMLSQLException: Start of root element expected.
at oracle.xml.sql.dml.OracleXMLSave.saveXML(OracleXMLSave.java:2263)
at oracle.xml.sql.dml.OracleXMLSave.insertXML(OracleXMLSave.java:1333)
at testInsert.main(testInsert.java:8)
Here is my xml file:
<?xml version = '1.0'?>
<ROWSET>
<ROW num="1">
<DEPTNO>10</DEPTNO>
<DNAME>ACCOUNTING</DNAME>
<LOC>NEW YORK</LOC>
</ROW>
<ROW num="2">
<DEPTNO>20</DEPTNO>
<DNAME>RESEARCH</DNAME>
<LOC>DALLAS</LOC>
</ROW>
<ROW num="3">
<DEPTNO>30</DEPTNO>
<DNAME>SALES</DNAME>
<LOC>CHICAGO</LOC>
</ROW>
<ROW num="4">
<DEPTNO>40</DEPTNO>
<DNAME>OPERATIONS</DNAME>
<LOC>BOSTON</LOC>
</ROW>
</ROWSET>
and here is structure of table:
Name Null? Type
DEPTNO NOT NULL NUMBER(2)
DNAME VARCHAR2(14)
LOC VARCHAR2(13)
and here is my Java Code:
import java.sql.*;
import oracle.xml.sql.dml.OracleXMLSave;
public class testInsert{
public static void main(String[] args) throws SQLException{
Connection conn = getConnection();
OracleXMLSave sav = new OracleXMLSave(conn,"scott.tmp_dept");
sav.insertXML(args[0]);
sav.close();
conn.close();
private static Connection getConnection()throws SQLException{
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@amt-ebdev01:1521:mydept","scott","tiger");
return conn;
Could you help me ? Thanks !The problem is that you need to pass avalid URL , Document...
Please try this code instead:
import java.net.*;
import java.sql.*;
import java.io.*;
import oracle.xml.sql.dml.OracleXMLSave;
public class testInsert
public static void main(String[] args) throws SQLException{
Connection conn = getConnection();
OracleXMLSave sav = new OracleXMLSave(conn,"scott.temp_dept");
URL url = createURL(args[0]);
sav.insertXML(url);
sav.close();
conn.close();
private static Connection getConnection()throws SQLException{
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@dlsun1982:1521:jwxdk9i","scott","tiger");
return conn;
// Helper method to create a URL from a file name
static URL createURL(String fileName)
URL url = null;
try
url = new URL(fileName);
catch (MalformedURLException ex)
File f = new File(fileName);
try
String path = f.getAbsolutePath();
// This is a bunch of weird code that is required to
// make a valid URL on the Windows platform, due
// to inconsistencies in what getAbsolutePath returns.
String fs = System.getProperty("file.separator");
if (fs.length() == 1)
char sep = fs.charAt(0);
if (sep != '/')
path = path.replace(sep, '/');
if (path.charAt(0) != '/')
path = '/' + path;
path = "file://" + path;
url = new URL(path);
catch (MalformedURLException e)
System.out.println("Cannot create url for: " + fileName);
System.exit(0);
return url; -
Using RSCRM_REPORT to store query result into DSO
Hi,
Is there a way to use this transaction in order to store the query result in a DSO? I tried specifying as result table the one of active rows of the DSO but it always create a new table.
Thanks for your replyI am not familiar with the listed transaction. However, I know you can use the APD to store the results of a query in a DSO.
-
Multiple BI Query Results into one Table
Hi All
Can I embed Multiple queries into one table using VC?
I have data in different BI sources(Info Areas) like sales and distribution,Shipments etc. Can I write any universal query to retrive data from multiple sources?(If any???)Hi Jan Pasha,
My model contains two BW queries which uses UNION and sent result to one table.
I tried using UNION also but when I use it I am able to see no records to select in result table.
I donot have any coloums in common. Is it pre-requisite for using UNION? -
How to insert the select query result into table?
How to insert the select query result into table?
SELECT top 20 creation_time
,last_execution_time
,total_physical_reads
,total_logical_reads
,total_logical_writes
, execution_count
, total_worker_time
, total_elapsed_time
, total_elapsed_time / execution_count avg_elapsed_time
,SUBSTRING(st.text, (qs.statement_start_offset/2) + 1,
((CASE statement_end_offset
WHEN -1 THEN DATALENGTH(st.text)
ELSE qs.statement_end_offset END
- qs.statement_start_offset)/2) + 1) AS statement_text
FROM sys.dm_exec_query_stats AS qs
CROSS APPLY sys.dm_exec_sql_text(qs.sql_handle) st
ORDER BY total_elapsed_time / execution_count DESC;
Thanks,
Tirumala1. SELECT INTO
Below method will create table when data is inserted from one table to another table. Its useful when you need exactly same datatype as source table.
Use AdventureWorks2008R2;
Go
---Insert data using SELECT INTO
SELECT AddressLine1, City
INTO BothellAddresses
FROM Person.Address
where City = 'Bothell';
GO
---VERIFY DATA
Select AddressLine1, City
FROM BothellAddresses
---DROP TABLE
DROP TABLE BothellAddresses
GO
2. INSERT INTO SELECT
Below method will need table to be created prior to inserting data. Its really useful when table is already created and you want insert data from
another table.
Use AdventureWorks2008R2;
Go
---Create Table
CREATE TABLE BothellAddresses (AddressLine1 NVARCHAR(60), City NVARCHAR(30))
---Insert into above table using SELECT
INSERT INTO BothellAddresses(AddressLine1, City)
SELECT AddressLine1, City
FROM Person.Address
where City = 'Bothell';
---VERIFY DATA
Select AddressLine1, City
FROM BothellAddresses
---DROP TABLE
DROP TABLE BothellAddresses
GO
Regards,
Vishal Patel
Blog: http://vspatel.co.uk
Site: http://lehrity.com -
How to output a query results into a text file
How to output a query results into a text file instead of outputing it to the screen..
is there a way for us to write a SQL query which specifies to output the query results to a text file.
Pls let me know how to do it
Thanking u in advance
regards
MuralyMuraly,
If you are using SQL*Plus 8.1.6 or later, you can also spool output to a file in HTML format, eg
SET MARKUP HTML ON SPOOL ON PREFORMAT OFF ENTMAP ON
SPOOL c:\temp\report.html
SELECT DEPARTMENT_NAME, CITY
FROM EMP_DETAILS_VIEW
WHERE SALARY>12000;
SPOOL OFF
SET MARKUP HTML ENTMAP OFF
In iSQL*Plus 9.0.1 (the browser-based interface to SQL*Plus) onwards, you can also send the HTML output to a new web browser window, or an html file -- much easier than the command line method.
Alison -
How to store context data into a database table?
Hi All,
I am very new to Web Dynpro ABAP.
I am trying to store context data into database table. For this i need to write some code.
I have created one context attribute to store data and i have one database table.
Know i want to store that context attribute's data into database table.
Can anyone provide me necessary code to do this.
Thanks in Advance!
Regards,
Sreelakshmi.Hello Sreelakshmi,
i think there would be some button and when u click that, the data of the context need to get saved into the database.
For the button,create an action.
in the action handler write the following code.
DATA lo_nd_kna1 TYPE REF TO if_wd_context_node.
DATA lo_el_kna1 TYPE REF TO if_wd_context_element,
DATA lt_kna1 TYPE wd_this->elements_znode.
DATA ls_kna1 TYPE wd_this->element_znode.
lo_nd_kna1 = wd_context->get_child_node( name = wd_this->wdctx_znode ).
lo_el_kna1 = lo_nd_kna1->get_element( ).
lo_el_kna1->get_static_attributes( IMPORTING static_attributes = ls_kna1 ).
modify kna1 from ls_kna1.
Regards
Sajid -
Howto: Save prediction query results to relational table
I believe saving prediction query results to relational tables is possible (the BI studio does it!). I am not clear on how to do this w/o the BI studio, which means if I write a DMX query and want to store its output to a relational table, how do I do it?
Tips, anyone?
Thanks!a) You can write some code do this on the client-side. Use ADOMD.NET in your C# app to execute the DMX query and fetch a data reader, open up another connection to your relational database and write rows of data to the second connection as you read them from the first.
b) You can create a linked server to your Analysis Server instance in your SQL Server relational server instance and then execute a "SELECT * INTO <newtable> FROM OPENQUERY(<linkedserver>, <DMX query>)" T-SQL statement from your relational database connection. -
How to send query results from BW to R/3 abap program
Hi,
I have to bring in query results from BW into a abap program written in R/3...can anyone help me on how to accomplish this(BW to R/3) please...i was thinking if reporting agent or broadcasting should help but i dont know how to get started.
Please help.
Thank you so much.Hi Vijay,
As i know, you can send data from BW to Flat file or into any table in BW or to BW application server only.
You need 3rd party to send data to different server.
You can use
1. Tcode : RSCRM_BAPI to download query values/results into a table or into a flat file. OR
2. You can use Infospokes to generate files from ODS/CUBE/master data objects to flat files(local/application server) or to a table.
3. Using information broadcasting we can send mail(dont know much options), but i dont think generation of file possible.
You need to trnasfer generated file from BW to R/3 and load into R/3 using BDC or LSMW(if data is low).
I think, you can also use RFC function modules to read data from BW to R/3, plz check with ABAPer.
Hope it Helps
Srini -
How to return query result in procedure
Hi all,
Can anyone tell me how to return query result in pl/slq procedure using out .
thank you
regards
P PrakashProcedure for sys_refcursor:
create or replace procedure ptest(c out sys_refcursor) is
begin
open c for select * from dual;
end;Procedure for collections(although sys.ODCIVarchar2List is varray, same example you can use with "table of")
create or replace procedure ptest2(c out sys.odcivarchar2list) is
begin
select dummy
bulk collect into c
from dual;
end;Example:
declare
c sys_refcursor;
v varchar2(100);
vt sys.odcivarchar2list;
begin
ptest(c);
fetch c into v;
dbms_output.put_line('1.Cursor data: '||v);
ptest2(vt);
dbms_output.put_line('2.Collection data: '||vt(1));
end;Regards,
Sayan M. -
Write big query results into a file ? ? ?
Hi all,
The problem is: I want to write a simple query results into a file. I have no idea how to do that. Only thing I know is utl_ functions. Please advise GURUS how can I use them for big queries. Any example will be really appreciable.
Thank you in advance.
Message was edited by:
v838hi,
i´ld do it like that:
filedir varchar2(30):= '/usr/frajo/';
filename varchar2(30):= 'file.txt';
fhandle utl_file.file_type;
cursor x is
select ... (what ever)
begin
fhandle := utl_file.fopen (filedir, filename,'a');
open x;
loop
fetch x into (what ever)
exit when x%notfound;
utl_file.put_line (fhandle,'text and you results');
end loop;
utl_file.fclose(fhandle);
end;
happy xmas. franz -
I'm looking for a more efficient way to convert a query result into an HTML table so that I can paste it into an email. The procedure in sqldeveloper (version 3.1.07) is just too clunky and involves too many keystrokes and mouse clicks. And you can't save the HTML to the clipboard. (I'm talking about the "Export..." action here.)
Am I missing something? Are there any alternatives?
Thanks!... but sqlplus is so last millenium....
Seriously? I'm from the last millennium too, nevertheless I don't consider myself out of date
SQL*PLUS is still my first choice when I have to run a script. I'ts behaviour is reliably the same whereever my script is executed. I would never trust a script that needs another tool to be executed.
Generating a HTML-mail is IMHO out of scope for a database tool. It's a feature I would expect in a BI tool that specializes on reporting.
Regards
Marcus
Maybe you are looking for
-
Is it possible to get data from a smashed/broken iPod touch 4th gen?
Is it possible to get data from a smashed/broken iPod touch 4th gen?
-
Purchase order archived long back. User wants to retrieve specific POs.
Purchase order archived long back in 2004. These POs are not displayed in ME23n and ME2l. User wants to retrieve specific list of POs and make them displayed in ME23n & ME2l. Is there way to retrieve only selected (say 100 specific Purchase orders or
-
I'm writing a simple interface to drive a fairly slow (~25MHz) SPI bus, and have a few questions about best practice. The FPGA is the master device, which outputs a clock at something like 25MHz. On each rising clock edge, it drives data onto an outp
-
HI, This may not be appropriate question on this discussion forum. But in case if somebody has answer for this, please let me know: Problem: I am trying to open some documents in my JSP(JSPs are deplo
-
Dreamweaver CS5.5 hangs when synchronizing files
I work with a non-profit that has just bought two CS5.5 Design Premium licenses. One of our first tasks is to manage an organizational website in Dreamweaver CS5.5 We need both users to be able to do updates, one on a Mac (me), and the other user on