Oracle SQL Developer script output not displaying readable format - oracle

I have queries that provide the output, but the output is really weird looking. It doesn't scroll over to look at the output, and the columns are really wide for things that are less than 20 characters. How do I get it to look normal? This is using Oracle SQL Developer. I searched online, but this doesn't seem to be what I need to do: format output archive. Although, I don't see how to get to the preference screen they are referring to either.
This is a portion of the output:
RAK SHEL SLT
---------- ---------- ------------------------------ PRT BRDBND_
---------------------------------------- ---------- DSLAM
-------------------------------------------------- VEND
-------------------------------------------------------------------------------- MODE
-------------------------------------------------------------------------------- PORT_ADDR CARRIER_ID
----------------- ----------------------------------------------------- CIRC_DE SERVICE SHELF_PT_NUM CARD_PART_NUM
---------- ---------- ------------------------- ------------------------- CARD_PT_DESC
-----------------------------------
3317 270812 1179G1 1170F1
As you can see, hopefully, it has really wide columns for the output, and column headers aren't at the top of the output window, it's in the output window. None of the output is more than 20 characters wide. I'm not sure why it's displaying that way.
Update: Plus, it's printing the column headers in the output window over and over again.

Try adding this line at the beginning of your script. It appears that your SQL Developer settings are what is making this output unreadable.
NOTE: I am using SQL Developer version 18.1.0.095
Edit: Added command to suppress reprinting of headers (pagesize) to 80 lines.
set sqlformat ansiconsole;
set pagesize 80;

Related

Is there a way to use SET MARKUP CSV on in the Command window in PL/SQL Developer?

My code currently that I am running in the Command Window in PL/SQL Developer:
SET MARKUP CSV ON DELIMITER | QUOTE OFF
SET FEEDBACK OFF
SPOOL C:\Users\Desktop\SpoolTest.csv
select *
from Vendor_data t
where rownum < 20
;
SPOOL OFF;
My output:
222339 |067 |001
306811 |045 |001
024253 |067 |001
I need to remove the trailing spaces:
222339|067|001
306811|045|001
024253|067|001
I am getting Cannot SET MARKUP. I have to run my spooling in a command window in PL/SQL Developer. Is there a way to do this? This is a snippet of code which is actually quite long.
SET commands belong to Oracle's command line tool, SQL*Plus.
I don't use PL/SQL Developer (and quick Google doesn't return anything useful), so - does PL/SQL Developer support SET commands at all? If not, you're out of luck, but you could install Oracle Client (if you already don't have it) and run your script directly in SQL*Plus.
On the other hand & unless I'm wrong, SET MARKUP CSV is valid for Oracle 18c and above; in lower versions, it is SET MARKUP HTML you can use (i.e. no CSV option).
The PL/SQL Developer's command-line tool is a different product than Oracle SQL*Plus command-line utility, and it has a different set of supported commands. PL/SQL Developer's command line mimics a real SQL*Plus functionality but does it only partially. For example, it doesn't support the SET MARKUP CSV command. You can find the full list of supported commands in the PL/SQL Developer's Manual (Help -> User's Guide).
In your case, trailing spaces appear because you are printing headers of columns. Apparently, PL/SQL Developer tries to align rows by the maximum length of the column:
spool file.txt
select ao.object_name, ao.object_id, ao.created, ao.status
from all_objects ao
where rownum <= 3;
OBJECT_NAME OBJECT_ID CREATED STATUS
-------------------------------------------------------------------------------- ---------- ----------- -------
TS$ 16 26.01.2017 VALID
ICOL$ 20 26.01.2017 VALID
Keeping in mind that PL/SQL Developer's supports of SET commands is very limited, we can achieve the CSV like spooling by simply not printing headers and setting colwidth to 1:
spool file.txt
set colsep |
set heading off
set colwidth 1
select ao.object_name, ao.object_id, ao.created, ao.status
from all_objects ao
where rownum <= 3;
spool off
it saves this to the spool file:
TS$|16|26.01.2017 13:52:45|VALID
ICOL$|20|26.01.2017 13:52:45|VALID
C_FILE#_BLOCK#|8|26.01.2017 13:52:45|VALID
If you must print the headers, you can add an additional select from dual before the main sql just to print headers.

Oracle truncating column

I have the following query.
insert into ORDER_INFO(ORDINF_PK,ORDINF_LGNDET_PK_FK,MEDIA_TYPE,ORDINF_MUSIC_FK,DAT)
values (1,1,'Music',21,TO_DATE('14-OCT-2015','DD-MON-YYYY'));
insert into ORDER_INFO(ORDINF_PK,ORDINF_LGNDET_PK_FK,MEDIA_TYPE,ORDINF_MUSIC_FK,ORDINF_SERIES_FK,DAT)
values (2,2,'Series',71,23,TO_DATE('07-NOV-2015','DD-MON-YYYY'));
however when I do:
select * from ORDER_INFO;
I get:
truncating (as requested) before column ORDINF_SERIES_FK
truncating (as requested) before column ORDINF_MOVIES_FK
ORDINF_PK ORDINF_LGNDET_PK_FK MEDIA_TYPE ORDINF_MUSIC_FK DAT
---------- ------------------- -------------------- --------------- ---------
1 1 Music 21 14-NOV-14
2 2 Series 71 07-NOV-15
I understand that it is truncating ORDINF_MOVIES_FK because there is no entry in that column, but why is it truncating the column ORDINF_SERIES_FK?
I managed to solve the issue, I did this.
set wrap on;
set pagesize 50000;
set linesize 120;
link here: http://www.anattatechnologies.com/q/2012/01/sqlplus-pagesize-and-linesize/
Pay attention - both rows inserted and ARE in the database, so INSERT succeeded.
The warning you get is a warning from SQLPlus program that means that column is display not with full width (maybe the definition of column is long and SQLPlus decides to show column shorter because data you have in there is short).
You do not need to worry about this in any case.
See this link for more explanation about SQL*Plus wrap.

oracle column heading interferes to another column

I have problem with Oracle 10g database headig format.
I have this code
COLUMN id HEADING "Rodné|číslo" FORMAT A10
COLUMN name HEADING "Meno" FORMAT A20
COLUMN surname HEADING "Priezvisko" FORMAT A20
--some select here
Column id is char(10) type, other columns are varchar2(30) type. Result is this
Rodné
číslo Meno Priezvisko
---------- -------------------- --------------------
7951051548 Bohdana Filcova
4054207561 Bohumila Kmecova
As you can see header "Meno" interferes to first column and header "Priezvisko" interferes to second. I can't understand why. How can I solve this issue?
This seems to be a character set issue. SQL*Plus supports globalisation, so perhaps one of the characters you're using isn't in your session's characterset. If I set my NLS_LANG:
export NLS_LANG="ENGLISH_UNITED KINGDOM.WE8ISO8859P1"
Rodné
číslo Meno Priezvisko
---------- -------------------- --------------------
7951051548 Bohdana Filcova
4054207561 Bohumila Kmecova
... then I get the same behaviour you do. (It's slightly modified, but not fixed by set tab off). If I change my session to UTF8 then it aligns properly:
export NLS_LANG="ENGLISH_UNITED KINGDOM.UTF8"
Rodné
číslo Meno Priezvisko
---------- -------------------- --------------------
7951051548 Bohdana Filcova
4054207561 Bohumila Kmecova
This is in 11gR2, incidentally, so it isn't an Oracle 10g issue; my database character set is AL32UTF8. Also interesting is taking a dump of the value in each session, with 'select dump('Rodné|číslo', 1016) from dual'; with WE8ISO8859P1:
DUMP('RODNé|číSLO',1016)
--------------------------------------------------------------------------------
Typ=96 Len=20 CharacterSet=AL32UTF8: 52,6f,64,6e,c3,83,c2,a9,7c,c3,84,c2,8d,c3,8
3,c2,ad,73,6c,6f
... and with UTF8:
DUMP('RODNÉ|ČÍSLO',1016)
--------------------------------------------------------------------------------
Typ=96 Len=14 CharacterSet=AL32UTF8: 52,6f,64,6e,c3,a9,7c,c4,8d,c3,ad,73,6c,6f
Presumably with the former it thinks the output is taking up a bit more space than it actually is, so it isn't padding the heading quite right.
The č seems to be the problem. It is defined in Unicode, but not in WE8ISO8859P1 or WE8MSWIN1252 (sourced from here). In the Unicode version that's shown in the dump as c4,8d, and for the non-unicode it's building it from c3,84,c2,8d. Quite how and why that causes the effect you see is going beyond my understanding of character sets...

How to get long running report current status?

While running a long running report in Oracle Application Server 10g, the status of the report is exist in OAS admin console something like "25 of 3225 Pages completed".
How can I got this value from the OAS to be able to display it to the user in oracle forms.
Not certain but it's possible it might be stored in v$session_longops. See here for examples.
Some oracle code writes into V$session_longops but you can also encode into your own applications using some provided PLSQL functions.
If OAS or the report itself is writing something into here, you can get that information from an oracle form to display to the user when the report is run.
While the above code is running, the contents of the v$session_longops view can be queried as follows.
COLUMN opname FORMAT A20
COLUMN target_desc FORMAT A20
COLUMN units FORMAT A10
SELECT
opname,
target_desc,
sofar,
totalwork,
time_remaining,
units
FROM
v$session_longops
The type of output expected from this v$session_longops query is listed below.
OPNAME TARGET_DESC SOFAR TOTALWORK UNITS
-------------------- -------------------- ---------- ---------- ----
BATCH_LOAD BATCH_LOAD_TABLE 3 10 rows

sqlplus command problems

I am a newbie to sqlplus. I am trying to write a simple script to extract data to a file.
First problem I am having: It describes the variables on the top of the output file, like
Old Value was
New Value is
I want this not be output if possible.
Secondly, i am trying to write the contents of a field to a file. The content of the field can vary, I have set the Linesize to 8000 but the return is around 50 characters or so. How do i get the full contents of the field?
Thank you in advance for your help.
To prevent SQL*Plus showing the old and new variable values you need to set verify off:
SQL> SET VERIFY OFF
To pipe the output to a file you need the spool command:
SQL>SPOOL C:\myfile.txt
SQL>SELECT sysdate
2 FROM dual;
SYSDATE
---------
30-NOV-11
SQL> SPOOL OFF
Hope it helps...

Resources