How to write the output of an SQL query to a text file?
I am using Oracle 11g and SQL plus.
I have a large table called rating.
Whenever I do
SQL> select * from rating;
The output goes much beyond what the SQL Plus screen can show. I want to therefore store the output of this query into a text file.
How can this be done? Please help. Thanks.
SQL> SPOOL results.txt
SQL> select * from rating;
SQL> SPOOL OFF
Similar Messages
-
How to Suppress The Output of a SQL Query In Oracle 11gR2
Hi Friends,
I am using oracle version 11.2.0.1, I have set a cronjob which will run on every 15 minutes and give us a log file mentioning the execution time taken for that SQL query:-
For example:
SQL> set timing on;
SQL> SELECT objProp FROM aradmin.arschema WHERE (schemaId = 175);
OBJPROP+
--------------------------------------------------------------------------------+
*6\60006\4\0\\60008\40\0\60009\4\0\\60010\4\0\\60018\4\0\\600*
*22\4\68\1\63\AR:jRL#*
Elapsed: 00:00:00.00
The above query will return the output as well as the time taken for execution of the query. I want to suppress the output of the query and only want the time taken to be printed. Is it possible by set commands. I have marked the output as bold and made it Italic.
Please help me at the earliest.
Regards,
Arijit>
I am using oracle version 11.2.0.1, I have set a cronjob which will run on every 15 minutes and give us a log file mentioning the execution time taken for that SQL query:-
The above query will return the output as well as the time taken for execution of the query. I want to suppress the output of the query and only want the time taken to be printed. Is it possible by set commands. I have marked the output as bold and made it Italic.
>
How would that even be useful?
A query from a tool such as sql*plus is STILL going to send the output to the client and the client. You can keep sql*plus from actually displaying the data by setting autotrace to trace only.
But that TIME TAKEN is still going to include the network time it takes to send ALL rows that the query returns across the network.
That time is NOT the same as the actual execution time of the query. So unless you are trying to determine how long it takes to send the data over the network your 'timing' method is rather flawed.
Why don't you tell us WHAT PROBLEM you are trying to solve so we can help you solve it? -
How to display the out put of the sql query in a text file using forms
I want to display the out put of the sql query in a text file using forms 6.0.Same could be done using spool command in sqlplus but i want it using forms....Fiaz
Have a look at the text_io package:
http://www.oracle.com/webapps/online-help/forms/10g/state?navSetId=_&navId=3&vtTopicFile=f1_help/oraini/c_text_io.html&vtTopicId=
cheers -
How to get the source code of an HTML page in Text file Through J2EE
How to get the source code of an HTML page in Text file Through J2EE?
Huh? If you want something like your browser's "view source" command, simply use a URLConnection and read in the data from the URL in question. If the HTML page is instead locally on your machine, use a FileInputStream. There's no magic invovled either way.
- Saish -
How to get the source code of an HTML page in Text file Through java?
How to get the source code of an HTML page in Text file Through java?
I am coding an application.one module of that application is given below:
The first part of the application is to connect our application to the existing HTML form.
This module would make a connection with the HTML page. The HTML page contains the coding for the Form with various elements. The form may be a simple form with one or two fields or a complex one like the form for registering for a new Bank Account or new email account.
The module will first connect through the HTML page and will fetch the HTML code into a Text File so that the code can be further processed.
Could any body provide coding hint for thatYou're welcome. How about awarding them duke stars?
edit: cheers! -
How to write the output of a mapping into a file (OWB10.2
Hi
I am using Oracle 10.2.0.1 version of OWB.
the task is to write the output of a mapping into a File (Flat File).
Please help me out!
Regards
AbiHi,
Create the file format thru OWB and mention the location in OWB. Deploy the file and it will be ready to use for target load. Make sure the connection to the target loc is available.
Regards
Bharadwaj Hari -
How to get the output of a procedure in to a log file ?
Hi, Everyone,
Could you please tell me
How do i write the output of a procedure to a log file ?
Thanks in advance...Hi,
could you please explain me more on how to use the UTL_file to get the output to a log file as in am new to PL/SQL
my script file is
EXEC pac_sav_cat_rfv.pro_cardbase (200910,'aaa',100,'test_tbl');
i need the output of this statement in a log file.
Could you please explain to me how it can be done.
thanks in advance -
How to Use the Procedures in a Sql Query
Hi Friends,
Can anyone help me out whether can we use the procedure in the sql query..
if yes help me out with an example
my requirement is
i have one sql query .. in which i need to use the procedure which returns multiple values... how can i overcome it,can anyone help me out for this..
for your reference i am pasting the sql query
SELECT paf.person_id
FROM per_all_assignments_f paf START WITH paf.person_id = p_person_id
AND paf.primary_flag = 'Y'
AND paf.assignment_type IN('E', 'C')
AND l_effective_date BETWEEN paf.effective_start_date
AND paf.effective_end_date
CONNECT BY PRIOR paf.supervisor_id = paf.person_id
AND paf.primary_flag = 'Y'
AND paf.assignment_type IN('E', 'C')
AND l_effective_date BETWEEN paf.effective_start_date
AND paf.effective_end_date
and paf.person_id not in (>>>I HAVE TO USE THE PROCEDURE HERE<<<<);
Thanks in advanceWe never saw your procedure, but maybe you could wrap it in a function
SQL> create or replace procedure get_members(in_something IN number, out_members OUT sys_refcursor)
is
begin
open out_members for
'select level member_id from dual connect by level <= :num' using in_something;
end get_members;
Procedure created.
SQL> create or replace type numbers as table of number;
Type created.
SQL> create or replace function members(in_something IN number)
return numbers
as
member_cur sys_refcursor;
members numbers;
begin
get_members(in_something, member_cur);
fetch member_cur bulk collect into members;
close member_cur;
return members;
end;
Function created.
SQL> select * from table(members(4));
COLUMN_VALUE
1
2
3
4
4 rows selected.Variant on same using piplined function
SQL> create or replace function members_piped(in_something IN number)
return numbers pipelined
as
member_cur sys_refcursor;
rec number;
begin
get_members(in_something, member_cur);
loop
fetch member_cur into rec;
exit when member_cur%notfound;
pipe row(rec);
end loop;
close member_cur;
return;
end;
Function created.
SQL> select * from table(members_piped(4));
COLUMN_VALUE
1
2
3
4
4 rows selected.
SQL> drop function members_piped;
Function dropped.
SQL> drop function members;
Function dropped.
SQL> drop type numbers;
Type dropped.
SQL> drop procedure get_members;
Procedure droppedEdit:
Sorry Blu, had not seen you already posted similar thing
Edited by: Peter on Jan 27, 2011 5:38 AM -
How to read the output of 'tarantella license query' command?
I'm trying to track my license usage (to better determine when to buy new licenses, and to track usage over time).
When I issue the 'tarantella license query command, this is typical of the output I see:
[root@sgdserver ~]# /opt/tarantella/bin/tarantella license query
License usage at: Mon Feb 11 14:03:53 EST 2008
Type In use / Total
Base 6 / 230
UNIX 4 / 230
Mainframe 0 / 230
Windows 0 / 230
AS/400 0 / 230
[root@sgdserver ~]#What is the above saying? Is it saying that I am using 10 licenses out of my 230, or am I just using 6 licenses? In other words, do I add up the numbers or just use the highest one? Or do I just have to worry about the 'Base' license number?
Thanks.The base license is the number of users that are logged into a webtop.
From there you count then connectivity type.
So you have 6 webtop licenses out of 230 consumed and of those 4 users have launched UNIX sessions out of 230 you have licensed.
hope this helps. -
How to use the result of a sql query for a max () function
Hi
I wrote a query on which i wrote
"select max(id) from users "
how can i use the returned value.
if i made the var name ="userid"
can it be userid.rows[0] or what.
thnx for any helpHi!
The result of this query will be the max ID of users' IDs.
Let say we have:
String sql="select max(users.id) from users";
Statement st = ctx.conn.createStatement();
ResultSet rs = st.executeQuery(sql);
rs.next();
So you can get the max Id in the following way:
int maxId=rs.getInt("id");
Regards,
Rossi -
How to measure the performance of a SQL query?
Hello,
I want to measure the performance of a group of SQL queries to compare them, but i don't know how to do it.
Is there any application to do it?
Thanks.You can use STATSPACK (in 10g its called as AWR - Automatic Workload Repository)
Statspack -> A set of SQL, PL/SQL, and SQL*Plus scripts that allow the collection, automation, storage, and viewing of performance data. This feature has been replaced by the Automatic Workload Repository.
Automatic Workload Repository - Collects, processes, and maintains performance statistics for problem detection and self-tuning purposes
Oracle Database Performance Tuning Guide - Automatic Workload Repository
http://download-east.oracle.com/docs/cd/B19306_01/server.102/b14211/autostat.htm#PFGRF02601
or
you can use EXPLAIN PLAN
EXPLAIN PLAN -> A SQL statement that enables examination of the execution plan chosen by the optimizer for DML statements. EXPLAIN PLAN causes the optimizer to choose an execution plan and then to put data describing the plan into a database table.
Oracle Database Performance Tuning Guide - Using EXPLAIN PLAN
http://download-east.oracle.com/docs/cd/B19306_01/server.102/b14211/ex_plan.htm#PFGRF009
Oracle Database SQL Reference - EXPLAIN PLAN
http://download-east.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_9010.htm#sthref8881 -
Hi,
I recently came across the option in PSSDiag configuration utility to collect data using the "SQL 2005 tempdb Space and Latching" option. I executed this on a test server and it generated the file {servername}_TempDBAnalysis_Startup.out.
This contains the output of a set of queries that are run in a 10s loop.
I have two questions regarding this output.
1. Are there any of the analytical tools in SQLNexus or PAL that display, summarize, or trend this data in any way? I do not see any but would like to confirm with the forum.
2. If there are no analytical outputs, is there any summary out on the web of how to analyze this data, how to import it into a db, or how to interpret the output of each individual query?
Thanks in advance for any assistance in this matter!Hi Lorrin,
You can reference the below links.
Tool to help you analyze SQL Server SQLDIAG and PSSDIAG output
How to use SQLDiag, SQLNexus and PAL tools to analyze performance issues in SQL Server
If you have any feedback on our support, please click
here.
Eric Zhang
TechNet Community Support -
Pass the result of a SQL Query as table_name for another SQL Query
Hi All,
How to pass the result of a SQL Query as parameter to another SQL Query
Eg: I am doing the steps below.
1) select distinct table_name as TAB1 from all_tab_cols where table_name like 'T_%' and column_name like '%XYZ'
2) I want to pass the table_name from step 1 above as parameter to another query "select * from TAB1"
ThanksNaveen B wrote:
Hi All,
How to pass the result of a SQL Query as parameter to another SQL Query
Eg: I am doing the steps below.
1) select distinct table_name as TAB1 from all_tab_cols where table_name like 'T_%' and column_name like '%XYZ'
2) I want to pass the table_name from step 1 above as parameter to another query "select * from TAB1"
ThanksYou should craete PL/SQL code with cursor which will accept a parameter and call that cursor inside the first one
But if the first sql returns only one row, you can do it with simple sql code
select * from (select distinct table_name as TAB1 from all_tab_cols where table_name like 'T_%' and column_name like '%XYZ')- - - - - - - - - - - - - - - - - - - - -
Kamran Agayev A. (10g OCP)
http://kamranagayev.wordpress.com
[Step by Step install Oracle on Linux and Automate the installation using Shell Script |http://kamranagayev.wordpress.com/2009/05/01/step-by-step-installing-oracle-database-10g-release-2-on-linux-centos-and-automate-the-installation-using-linux-shell-script/] -
Report the size of all SharePoint Databases in a text file using PowerShell?
I am new to Powershell. please help me for following question with step by step process.
How to report the size of all SharePoint Databases in a text file using PowerShell?Hi Paul,
Here is the changed script, which will also include the size for the Config DB.
Please let me know if it worked:
#Get SharePoint Content database sizes
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
$date = Get-Date -Format "dd-MM-yyyy"
#Variables that you can change to fit your environment
$TXTFile = "D:\Reports\SPContentDatabase_$date.txt"
$SMTPServer = "yourmailserver"
$emailFrom = "[email protected]"
$emailTo = "[email protected]"
$subject = "Content & Config Database size reports"
$emailBody = "Daily/Weekly/Monthly report on Content & Config databases"
$webapps = Get-SPWebApplication
$configDB = Get-SPDatabase | ?{$_.Name -eq ((Get-SPFarm).Name)}
$ConfigDBSize = [Math]::Round(($configDB.disksizerequired/1GB),2)
Add-Content -Path $TXTFile -Value "Config Database size: $($ConfigDBSize)GB"
Add-Content -Path $TXTFile -Value ""
foreach($webapp in $webapps)
$ContentDatabases = $webapp.ContentDatabases
Add-Content -Path $TXTFile -Value "Content databases for $($webapp.url)"
foreach($ContentDatabase in $ContentDatabases)
$ContentDatabaseSize = [Math]::Round(($ContentDatabase.disksizerequired/1GB),2)
Add-Content -Path $TXTFile -Value "- $($ContentDatabase.Name): $($ContentDatabaseSize)GB"
if(!($SMTPServer) -OR !($emailFrom) -OR !($emailTo))
Write-Host "No e-mail being sent, if you do want to send an e-mail, please enter the values for the following variables: $SMTPServer, $emailFrom and $emailTo."
else
Send-MailMessage -SmtpServer $SMTPServer -From $emailFrom -To $emailTo -Subject $subject -Body $emailBody -Attachment $TXTFile
Nico Martens - MCTS, MCITP
SharePoint 2010 Infrastructure Consultant / Trainer -
How to write the code to send the report output to the local file.
dear all,
how to write the code to send the report output to the local file.
Thanks & Regards,
Jyothi.Hi,
Try this , it will display report and download the file as well. Just vhange the path and execute
TYPE-POOLS : SLIS.
DATA : IT_SCARR TYPE TABLE OF SCARR,
IT_FCAT TYPE SLIS_T_FIELDCAT_ALV.
SELECT *
FROM SCARR
INTO TABLE IT_SCARR.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
* I_PROGRAM_NAME =
* I_INTERNAL_TABNAME =
I_STRUCTURE_NAME = 'SCARR'
* I_CLIENT_NEVER_DISPLAY = 'X'
* I_INCLNAME =
* I_BYPASSING_BUFFER =
* I_BUFFER_ACTIVE =
CHANGING
CT_FIELDCAT = IT_FCAT
* EXCEPTIONS
* INCONSISTENT_INTERFACE = 1
* PROGRAM_ERROR = 2
* OTHERS = 3
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER =
* I_BUFFER_ACTIVE = ' '
* I_CALLBACK_PROGRAM = ' '
* I_CALLBACK_PF_STATUS_SET = ' '
* I_CALLBACK_USER_COMMAND = ' '
* I_STRUCTURE_NAME =
* IS_LAYOUT =
IT_FIELDCAT = IT_FCAT
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
* IT_SORT =
* IT_FILTER =
* IS_SEL_HIDE =
* I_DEFAULT = 'X'
* I_SAVE = ' '
* IS_VARIANT =
* IT_EVENTS =
* IT_EVENT_EXIT =
* IS_PRINT =
* IS_REPREP_ID =
* I_SCREEN_START_COLUMN = 0
* I_SCREEN_START_LINE = 0
* I_SCREEN_END_COLUMN = 0
* I_SCREEN_END_LINE = 0
* IR_SALV_LIST_ADAPTER =
* IT_EXCEPT_QINFO =
* I_SUPPRESS_EMPTY_DATA = ABAP_FALSE
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = IT_SCARR
* EXCEPTIONS
* PROGRAM_ERROR = 1
* OTHERS = 2
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_DOWNLOAD
EXPORTING
* BIN_FILESIZE =
FILENAME = 'C:\Documents and Settings\sap\Desktop\Hi.xls' " Change path
* FILETYPE = 'ASC'
* APPEND = SPACE
* WRITE_FIELD_SEPARATOR = SPACE
* HEADER = '00'
* TRUNC_TRAILING_BLANKS = SPACE
* WRITE_LF = 'X'
* COL_SELECT = SPACE
* COL_SELECT_MASK = SPACE
* DAT_MODE = SPACE
* CONFIRM_OVERWRITE = SPACE
* NO_AUTH_CHECK = SPACE
* CODEPAGE = SPACE
* IGNORE_CERR = ABAP_TRUE
* REPLACEMENT = '#'
* WRITE_BOM = SPACE
* TRUNC_TRAILING_BLANKS_EOL = 'X'
* IMPORTING
* FILELENGTH =
CHANGING
DATA_TAB = IT_SCARR
* EXCEPTIONS
* FILE_WRITE_ERROR = 1
* NO_BATCH = 2
* GUI_REFUSE_FILETRANSFER = 3
* INVALID_TYPE = 4
* NO_AUTHORITY = 5
* UNKNOWN_ERROR = 6
* HEADER_NOT_ALLOWED = 7
* SEPARATOR_NOT_ALLOWED = 8
* FILESIZE_NOT_ALLOWED = 9
* HEADER_TOO_LONG = 10
* DP_ERROR_CREATE = 11
* DP_ERROR_SEND = 12
* DP_ERROR_WRITE = 13
* UNKNOWN_DP_ERROR = 14
* ACCESS_DENIED = 15
* DP_OUT_OF_MEMORY = 16
* DISK_FULL = 17
* DP_TIMEOUT = 18
* FILE_NOT_FOUND = 19
* DATAPROVIDER_EXCEPTION = 20
* CONTROL_FLUSH_ERROR = 21
* NOT_SUPPORTED_BY_GUI = 22
* ERROR_NO_GUI = 23
* others = 24
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>EXECUTE
EXPORTING
DOCUMENT = 'C:\Documents and Settings\sap\Desktop\Hi.xls' "Change path
* APPLICATION =
* PARAMETER =
* DEFAULT_DIRECTORY =
* MAXIMIZED =
* MINIMIZED =
* SYNCHRONOUS =
* OPERATION = 'OPEN'
* EXCEPTIONS
* CNTL_ERROR = 1
* ERROR_NO_GUI = 2
* BAD_PARAMETER = 3
* FILE_NOT_FOUND = 4
* PATH_NOT_FOUND = 5
* FILE_EXTENSION_UNKNOWN = 6
* ERROR_EXECUTE_FAILED = 7
* SYNCHRONOUS_FAILED = 8
* NOT_SUPPORTED_BY_GUI = 9
* others = 10
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Maybe you are looking for
-
Conflicts with ATI Radeon 5770?
Hello, I am using a Mac Pro 3.1, 2x2.8 quad core Xeon, with OSX 10.6.7. I recently upgraded to a ATI Radeon HD 5770 in slot 1 and put my original ATI Radeon 2660XT in Slot 4 to run an older DVI monitor. It ran ok for a while, but my computer starti
-
I do not want to access my MAC mail via my browser, I prefer accessing my mail in the Mac Mail application! How do I do this?
-
IWeb and SEO Tool - best practice?
I have made an iweb website (published to a MobileMe account) and have downloaded iWeb SEO Tool. I have understood that there is one certain procedure in doing SEO that's a lot better than the other. What I usually do after making changes in iWeb is
-
I have lost the ability to track my daughters phone using her log in for find my iPhone since updat
-
Hello, I'd be very grateful if someone could help with the following query that I received from a colleague. This issue was raised after I asked all members of staff, to standardise their email signatures. "I followed your script for this: my image c