Where those sqlplus columns are used? - oracle

Just type col in sqlplus returns a list of columns, there are some columns ended with _recyc, where those columns are used ? I googled but could not find any documentation on them.
COLUMN droptime_plus_show_recyc ON
HEADING 'DROP TIME'
FORMAT a19
COLUMN objtype_plus_show_recyc ON
HEADING 'OBJECT TYPE'
FORMAT a12
COLUMN objectname_plus_show_recyc ON
HEADING 'RECYCLEBIN NAME'
FORMAT a30
COLUMN origname_plus_show_recyc ON
HEADING 'ORIGINAL NAME'
FORMAT a16

They're used by the show recyclebin command. If you run that you get headings like:
ORIGINAL NAME RECYCLEBIN NAME OBJECT TYPE DROP TIME
---------------- ------------------------------ ------------ -------------------
...
If you do clear columns and run it again you get:
ORIGNAME_PLUS_SHOW_RECYC OBJECTNAME_PLUS_SHOW_RECYC OBJTYPE_PLUS_SHOW_RECYC DROPTIME_PLUS_SHOW_
-------------------------------- ------------------------------ ------------------------- -------------------
...
Whatever underlying query show recyclebin is using (some variant of select .. from user_recyclebin presumably) is aliasing the columns in the resultset; SQL*Plus is configured to format those aliased names.
The other pre-set column definitions are similar; for example, show edition gives a column displayed with heading EDITION, but if you clear columns it reverts to the underlying NAME_COL_PLUS_SHOW_EDITION. Anything with _PLUS_SHOW_ is going to be for some output from a show command.

Related

Classic report dynamic heading in APEX 5.1

I have a classic report driven by a SQL query.
How can I dynamically set column headings, based on the value of another column?
For example, my SQL returns columns A, B, VERSION. I'd like the classic report column heading for SQL column A to be 'Foo' if VERSION is 1, but 'Bar' if VERSION is 2.
I don't know what you meant by saying that the query is constrained by primary key.
Anyway, here's a suggestion which might (or might not) help.
Based on sample SCOTT schema, I created a simple classic report as
select e.ename, e.job
from emp e
where e.deptno = :P42_DEPTNO
I also created a P42_DEPTNO item which - kind of - constrains the result to just one department. For example, if you enter 10 into P42_DEPTNO, you'll get employees that work in the ACCOUNTING department.
Furthermore, I created a hidden item P42_DNAME whose souce is a SQL query
select dname
from dept
where deptno = :P42_DEPTNO
and it returns department name for the P42_DEPTNO value. Its "Used" property is set to "Always, replacing any existing value in session state". This item (P42_DNAME) will be used as a custom heading for the ENAME column returned by the report.
In order to do that, open ENAME column's properties and put this into the "Name" property: &P42_DNAME. (literally ampersand + item name + dot - don't forget the trailing dot!).
That's all;
run the report
enter 10 into P42_DEPTNO item
press ENTER key
report will display employees that work in department 10, and ENAME column's heading will be ACCOUNTING

Oracle columns were missed while fetching data to CSV file using || in select query

We are trying to fetch data from oracle to CSV file through oracle spool.
But all columns were not fetched some columns were missing. Using below query
select colm1||'"~"'||colm2||'"~"'||...colm159||'"~"'|| from table;
It fetched only few columns.
While using same select query separated with ',' fetching all columns
eg: colm1,colm2,colm3...colm159 from table;
Please help me to sort this out
Thanks
Many IDEs such as SQL Developer support CSV export with a right-click menu but you can do it in SQL*Plus like this:
SQL> set colsep '~'
SQL> set echo off
SQL> set pages 0
SQL> set line 5000 -- or whatever is enough up to 32767
SQL> spool your_table.tsv
SQL> select /* csv */ * from your_table;
SQL> spool off
I recommend using the .tsv file extension. If you use .csv Excel assumes comma separation whereas with .tsv we get a nice dialog box to specify the separator.
If your longest line is more than 32k characters you'll need a different approach.

##### appears instead of actual values in sql table

i used
[column sal format A10;
set linesize 1500;]
to set width for the column sal and mgr. after that when i view the table the values in mgr and sal columns appears as ######.
now how to get the actual values??
You are using an invalid format model for a number column. The valid elements are listed in the documentation. SQL*Plus doesn't know what you mean, so it seems to be defaulting to the same behaviour it has if a number won't fit in a valid number format: "If a value cannot fit in the column, SQL*Plus displays pound signs (#) instead of the number."
You would only use the charcater column formatting like A10 if the result returned by the query was already a string, e.g. if you did to_char(sal, '999G999G999') as sal; but even then the maximum length is already set by the format model (to 12 in that case, to allow the +/- sign).
You probably don't need to format those columns at all, but if you are retrieving them as numbers and want to add formatting you need to use an appropriate model, e.g.
column salary format 999G999G999

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...

Resources