SQL output format
Dear all,
Select emp_no in emp;
my output is
1
2
3
4
But I want that as output format
1,2,3,4
Could you please tell me which application should I write it to achieve.
Concerning
Rajat
Hi, Rajat,
This is called the aggregation of the chain and this page:
ORACLE-BASE - String aggregation Techniques
shows several ways to do so. What sense does use? It depends on your requitrements and your version of Oracle. The LISTAGG built-in aggregate function is good for most purposes.
Tags: Database
Similar Questions
-
Hello. I have the following SQL code and I would like to know if there is a way to have the dates repetition appear only once? This would make the output look better. So, in the following query, I was wondering if there is a way to get the 20/07/2011 and 21/07/2011 to display only once?
1 select to_char(trunc(create_dt),'mm/dd/yyyy') byDay, create_by Agent, 2 rtrim(nvl(count(*),0)) total 3 from ttms_audit 4 where table_nm='RCPT_MPI' 5 and column_nm='RESPONSIBLE_IND' 6 and old_val='RS' and new_val <> 'RS' 7 group by rollup(to_char(trunc(create_dt),'mm/dd/yyyy'), create_by) 8* order by to_char(trunc(create_dt),'mm/dd/yyyy'), create_by SQL> / BYDAY AGENT TOTAL ---------- ------------------------------ ---------------------------------- 07/20/2011 ARHENRY 10 07/20/2011 MARTACG 1 07/20/2011 MVHOPKIN 3 07/20/2011 14 07/21/2011 MARTACG 1 07/21/2011 1 15 7 rows selected.
In SQL * more question
BREAK ON byDay
URS
-
Hello
I have 4 columns, I need the output format using carriage returns between values and removing the label for nulls, such as only the columns filled with values are displayed:
Name: emp.first_name
Medium: emp.middle_name
Name: emp.last_name
Address (line 1): emp.ext_contact_addr1
for example: -.
If the name is null then output would be
Middle: Thomas
Family name: James
Address (line 1): 10 william st
If the name is null, then output would be
First name: Tessa
Family name: James
Address (line 1): 10 william st
etc...
Please help me.
Hello
Here's a way
SELECT LTRIM (NVL2 (emp.first_name
, ' Name: '. EMP.first_name
NULL
)
|| NVL2 (emp.middle_name
, CHR (10) | ' Average: ' | EMP.middle_name
NULL
)
|| NVL2 (emp.last_name
, CHR (10) | ' Last name: ' | '. EMP.last_name
NULL
)
|| NVL2 (emp.ext_contact_addr1
, CHR (10) | ' Address (line 1): ' | EMP.ext_contact_addr1
NULL
)
, CHR (10)
) AS output_string
WCP
;
Using NVL2 like this, the label for each line gets concatenated only if there is some data to go with it.
If the name is NULL, which means that the output_string will begin with a character of new line (which is CHR (10) on my system, you may need to change this). I used LTRIM to remove this first newline character, if there be one.
You can also consider the results of unpivoting so that you have between 0 and 4 lines in the result set for each row in the emp, with 4 items on separate lines.
-
Help: Output Format complex
Hello
Data in TAB_DTL for an APPID using, I need to generate a report in the following format.
For the calculation of A logic) DAYS: difference in days of the next later DateCREATE TABLE TAB_DTL ( APPDATE DATE, AMOUNT NUMBER(12,2), STATUS VARCHAR2(1), RATE NUMBER(5,2) ); INSERT INTO TAB_DTL ( APPDATE, AMOUNT, STATUS, RATE ) VALUES TO_DATE( '13/09/2011 10:50:45 AM','DD/MM/YYYY HH:MI:SS AM'), 500000, 'D', 13 ); INSERT INTO TAB_DTL ( APPDATE, AMOUNT, STATUS, RATE ) VALUES TO_DATE( '09/11/2011 1:15:30 PM','DD/MM/YYYY HH:MI:SS AM'), 5000, 'R', 13 ); INSERT INTO TAB_DTL ( APPDATE, AMOUNT, STATUS, RATE ) VALUES TO_DATE( '15/12/2011 3:20:31 PM','DD/MM/YYYY HH:MI:SS AM'), 5000, 'R', 13 ); INSERT INTO TAB_DTL ( APPDATE, AMOUNT, STATUS, RATE ) VALUES TO_DATE( '05/01/2012 10:25:11 AM','DD/MM/YYYY HH:MI:SS AM'), 5000, 'R', 13 ); INSERT INTO TAB_DTL ( APPDATE, AMOUNT, STATUS, RATE ) VALUES TO_DATE( '02/02/2012 4:23:34 PM','DD/MM/YYYY HH:MI:SS AM'), 5000, 'R', 13 ); INSERT INTO TAB_DTL ( APPDATE, AMOUNT, STATUS, RATE ) VALUES TO_DATE( '05/03/2012 11:15:45 AM','DD/MM/YYYY HH:MI:SS AM'), 5000, 'R', 13 ); INSERT INTO TAB_DTL ( APPDATE, AMOUNT, STATUS, RATE ) VALUES TO_DATE( '30/03/2012 11:55:10 AM','DD/MM/YYYY HH:MI:SS AM'), 5000, 'R', 13 ); INSERT INTO TAB_DTL ( APPDATE, AMOUNT, STATUS, RATE ) VALUES TO_DATE( '31/03/2012 11:59:00 AM','DD/MM/YYYY HH:MI:SS AM'), 470000, 'B', 13 ); OUTPUT FORMAT : APPDATE DR CR BALANCE ACCAMT DAYS CUMM 13/09/2011 10:50:45 AM 5,00,000.00 0 5,00,000.00 10301 58 10301 09/11/2011 1:15:30 PM 0 5000 4,95,000.00 6330 36 16631 15/12/2011 3:20:31 PM 0 5000 4,90,000.00 3655 21 20286 05/01/2012 10:25:11 AM 0 5000 4,85,000.00 4823 28 25109 02/02/2012 4:23:34 PM 0 5000 4,80,000.00 5456 32 30565 05/03/2012 11:15:45 AM 0 5000 4,75,000.00 4218 25 34783 30/03/2012 11:55:10 AM 0 5000 4,70,000.00 334 2 35117 31/03/2012 11:59:00 AM 0 0 4,70,000.00 35117
(B) ACCAMT: Balance * (unlike in the days of the next Date) * rate / days in the year
With the help of CASE / SQLs of LEAD, the same thing can be accomplished.
Thank you
-
Error in the REST Web Service with the text output Format
Hi all
I am referencing a REST web service and can successfully connect to it and retrieve the results with the output XML value Format.
I don't need the node values, I want to just grab the entire XML string and fill a table with her column.
When I create a new Rest web service reference, including the text output Format value and then create a form/report to run it, I get the following error when I click on "send":
ORA-06550: line 1, column 63: PLS-00103: encountered the symbol "end-of-file" when expects it one of the following numbers: (- + new case mod not null to other current County avg exists max min prior sql stddev sum variance execute forall time timestamp interval date fusion pipe)
Error sending request.
There is control in the XML characters, but surely, this is handled by the Apex, so I'm not sure what the problem is here.
Any ideas most welcome.
Thank you
RhodriRhodri:
Request Express waiting for answer text actually be answer text, delimited by other characters that denotes a new value and a new Recordset. You should leave the response as XML. The XML document will be stored in the column xmltype01 in the collection that you specify. You can then convert this column xmltype01 in a clob, if you like using the. toClobVal().
Kind regards
Jason
-
Change default value of output format you 'Keynote 09 '.
Hi all
I use Keynote 6.6.2 and I need your help to know how to use the 'Keynote ' 09"as the default output format, without an export each time.
In my company, I'm the only one with this version of Keynote, if no one else can use my files and allows us to work on the same files really often!
Thank you for helping me.
Kind regards
Nicolas
The only way to create 09 files from Keynote 6.6.2 is to use file > export > Keynote 09
-
Output format unknown D3D on Windows Vista, while trying to activate the game simulator of mining & Tunnelling?
Need help!JackHello
D3D error could be because the DirectX wrong on the computer.
Download and install the latest version of DirectX from here:
Use DirectX Runtimes (June 2010): http://www.microsoft.com/en-us/download/details.aspx?id=35
If DirectX update does not help because the error is activation, you can contact Tunneling and mining simulator manufacturer for more assistance.
-
Hi all
Please find test data and results as XML and SQL output.
Version : Oracle Database 11 g Enterprise Edition Release 11.1.0.7.0 - 64 bit Production
create table emp_xml (empno number, emp_name varchar2 (100), by e-mail to varchar2 (100));
insert into emp_xml values (100, 'DAVID',' [email protected]');
insert into emp_xml values (101, 'ROBERT',' [email protected]');
insert into emp_xml values (102, 'DANIEL',' [email protected]');
CREATE table emp_dept_xml (empno number, dept_list varchar2 (4000));
insert into emp_dept_xml values (' 100,'10, 20, 30, ");
insert into emp_dept_xml values (' 101,'40, 20, 10, 30, 50, ");
insert into emp_dept_xml values (102, ' 10'),
Expected in SQL output
-----------------------
EMPNO EMP_NAME EMAIL DEPTNO
DAVID 100 [email protected] 10
DAVID 100 [email protected] 20
DAVID 100 [email protected] 30
ROBERT 101 [email protected] 10
ROBERT 101 [email protected] 20
ROBERT 101 [email protected] 30
ROBERT 101 [email protected] 40
ROBERT 101 [email protected] 50
DANIEL 102 [email protected] 10
Results in XML
-----------------------
< USERS_DETAILS >
< USER >
< EMPNO > 100 < / EMPNO >
DAVID < NAME > < / NAME >
< EMAIL > [email protected] < / EMAIL >
< ASSIGNED_DEPT >
< DEPT > 10 < / DEPT >
< DEPT > 20 < / DEPT >
< DEPT > 30 < / DEPT >
< / ASSIGNED_DEPT >
< / USER >
< USER >
101/EMPNO < EMPNO > >
ROBERT < NAME > < / NAME >
< EMAIL > [email protected] < / EMAIL >
< ASSIGNED_DEPT >
< DEPT > 10 < / DEPT >
< DEPT > 20 < / DEPT >
< DEPT > 30 < / DEPT >
< DEPT > 40 < / DEPT >
< DEPT > 50 < / DEPT >
< / ASSIGNED_DEPT >
< / USER >
< USER >
< > 102 EMPNO < / EMPNO >
DANIEL < NAME > < / NAME >
< EMAIL > [email protected] < / EMAIL >
< ASSIGNED_DEPT >
< DEPT > 10 < / DEPT >
< / ASSIGNED_DEPT >
< / USER >
< / USERS_DETAILS >
Thank you
Rambeau
SQL> select e.empno 2 , e.emp_name 3 , e.email 4 , regexp_substr(d.dept_list, '[^,]+', 1, level) deptno 5 from emp_xml e 6 join emp_dept_xml d 7 on e.empno = d.empno 8 connect 9 by level <= length(d.dept_list) - length(replace(dept_list, ',')) 10 and prior e.empno = e.empno 11 and prior dbms_random.value() is not null; EMPNO EMP_NAME EMAIL DEPTNO ---------- -------------------- -------------------- -------------------- 100 DAVID [email protected] 10 100 DAVID [email protected] 20 100 DAVID [email protected] 30 101 ROBERT [email protected] 40 101 ROBERT [email protected] 20 101 ROBERT [email protected] 10 101 ROBERT [email protected] 30 101 ROBERT [email protected] 50 102 DANIEL [email protected] 10 9 rows selected. SQL> select xmlelement 2 ( 3 "USERS_DETAILS" 4 , xmlagg(xmlelement 5 ( 6 "USER" 7 , xmlelement("EMPNO", empno) 8 , xmlelement("NAME", emp_name) 9 , xmlelement("ASSIGNED_DEPT", xmlagg(xmlelement("DEPT", deptno))) 10 )) 11 ).extract('*') xml_output 12 from ( 13 select e.empno 14 , e.emp_name 15 , e.email 16 , regexp_substr(d.dept_list, '[^,]+', 1, level) deptno 17 from emp_xml e 18 join emp_dept_xml d 19 on e.empno = d.empno 20 connect 21 by level <= length(d.dept_list) - length(replace(dept_list, ',')) 22 and prior e.empno = e.empno 23 and prior dbms_random.value() is not null 24 ) 25 group 26 by empno 27 , emp_name; XML_OUTPUT --------------------------------------------------------------------------------
100 DAVID 10 20 30 101 ROBERT 40 50 30 20 10 102 DANIEL 10 -
Hello community! Sorry, it's so rudimentary. Can anyone offer advice on how to better format the output of the below? As it is, it prints it just without formatting - I want out as the output format-table and I would have zero decimal places in the output of Write-Host $CurrentItemHdd.CapacityGB. Thank you!
foreach ($VmItem to $MyVms)
{
$CurrentItemHdd = get-disk hard - VM $VmItem
Write-Host $VmItem.Name $CurrentItemHdd.CapacityGB
}
To create an exit in your PowerCLI script like the Format-Table output, you must create an output object. There are several ways you can do. One way is to use the PowerShell New-Object as shown in the below script cmdlet. The properties in the New-Object cmdlet output are not classified. That's why I redirect the output to the Select-Object cmdlet to order.
Your original script will generate a table for the CapacityGB property, if a virtual machine has more than one hard drive. That's why I introduced a second foreach to browse the hard drives. Because you probably want to know that CapacityGB belongs to the hard drive, I added the property 'hard drive '.
[Math] .NET: Round() function is used to supplement the CapacityGB to zero decimal places.
The character '&' at the beginning of the script and the scriptblock around the script are necessary to allow to channel the output of the script to another cmdlet as Export-CSV. foreach is not a cmdlet, and therefor you cannot use the out of foreach in the pipeline without using this trick.
& {foreach ($VmItem to $MyVms)
{
foreach ($CurrentItemHdd in (Get-disk hard - VM $VmItem))
{
New-Object PSObject-property @ {} TypeName
VM = $VmItem.Name
"Hard drive" = $CurrentItemHdd.Name
CapacityGB = [Math]: Round($CurrentItemHdd.CapacityGB,0)
} |
Select-Object - property, CapacityGB VM, 'Hard drive'
}
}}
Post edited by: Robert van den Nieuwendijk
-
Simultaneous report runs very slowly when the output format is 'XML' on IBM 6.1
We have recently updated one of our test server database IBM AIX 5.3 to 6.1 operating system. We are witnessing a strange question in the execution time-out of simultaneous reports that have output in XML format (no server of publication and the Publisher). Whenever the output format is set to XML, the execution time seem to have increased very high than it used to be less than 5.3. A report to take 10 seconds which takes about 4 minutes to complete which is huge in comparison. Information about the version as below
Oracle EBS 11.5.10
Oracle 10.2.0.4.0 DB
IBM AIX 6.1 OPERATING SYSTEM
Oracle reports 6.0.8.28.0 (I know old enough)
Provide expert advice.
Thank you!
All the
We have solved the problem. I would like to share for the benefit of the readers of the community, if they are facing similar problems.
The reason for the slowness of the report was due to lack of installation of the 'VIEW' option that is used when XML reports. Reports whose outputs are in format PDF, XML, HTML etc, Post Script, they all need a virtual display makes setup and configuration properties of config pointing to this server whenever settings are do. It could be a windows machine with X-Server running on it for display purposes or it could be services that are running on the same server for Unix/Linux applications where the application runs. We have installed VNC as X-Server that hosts services for virual (X) output for display on UNIX itself and have configured it in the reports configuration file. It seems to have solved the problem and the reports are run as expected (must faster!)
Thank you
Girish
-
Hi all
We use ud32 to test service using fml32 buffer. One of the result field is a double, when the value of the field data are displayed in exponential format.
Is it possible config output format? I don't want no exponential format. Its config possible in ud32?, it's a shell config?
I thank in advance.Hello
Unfortunately, there is not a way to control the release of ud/ud32. It just uses Fprint() which uses the format string "%g" to print floats and doubles. What you're asking for sounds reasonable. As an alternative it would be not difficult to use a script (awk or other) to convert the exponential value to format numbers in no exponential format.
If you really need, I would suggest opening and enhancement with the Oracle customer support request.
Kind regards
Todd little
Chief Architect of Oracle TuxedoPS ud/ud32 is really a pretty simple utility and it reproduce yourself would not be a lot of work.
-
Export data to SQL Loader format bugs?
I have a problem to the export of large tables in SQL * Loader format files.
Developer SQL is sitting there with almost all CPU (> 95%) on my machine (I'm only under SQL Developer & Process Explorer) and same constantly redraw (the page is white).
The .ldr file is created, but seems to be empty. (I would have thought that he would be constantly added to the).
In fact, nothing happens.
Does anyone else have this problem? I use SQL Developer 2.1 on XP with a 9i DB.
NICUnfortunately, this is how things are done now.
If you have a better suggestion (such as hot flashes automatically recovered rows and the re-use of freed memory), you can always add this as a feature request to the exchange of SQL Developer, for other users can vote to add weight to the possible future implementation. I'd do it.Kind regards
K. -
Print SQL with SQL output statements
I am a student in learning SQL for Oracle 10 g.
Our missions are typically a set of problems that have an SQL statement as the solution.
We pass in the SQL statement and SQL output generated by the statement.
I use SQL Developer to create my scripts, print my files, etc. Very convenient.
I want to be able to do is to somehow combine the two impressions that I always generate.
So I would like to have a report which has my SQL statement (Select * From Customers ;) and)
the output of SQL that has generated this statement.
Anyway is to do it with SQL Developer? Or maybe in another tool?
Thanks for any help!Just this question before your scripts:
set echo on
Have fun
K. -
SQL * plus - formatting issues
Hi Experts,
I am trying to generate several reports using SQL * MORE tool (SQL * more: 11.2.0.1.0 release). I am facing problems of formatting the output.
I developed a .sql script like below.
TERMOUT OFF SET
SET PAGESIZE 50000
SET LINESIZE 32767
SET TRIMSPOOL ON
"SET COLSEP" "
THE VALUE NULL NULLL
REEL 'C:\Users\Suri\sampleresults.txt '.
TTITLE LEFT 'Validate ename détails' jump 1
Select * from emp where ename is null;
TTITLE LEFT 'Employees without Manager details' jump 2
Select * from emp where mgr is null;
SPOOL OFF;
Output:
no selected line
Employees without Manager details
EmployeeDetails
In the output file TITLE is not displayed whenever there is no selected line? Also I don't see all the new lines even after the words JUMP 1 or 2.
Thanks in advance for your help.
Hi Suri,
I think it's normal behavior, maybe not the one expected.
If you are working with "off feedback" you can hide the "... message of selected lines.
Or put you up a union all to display a blank line, but then you do a select with the correct number of NULL values.
Something like that
select * from emp where ename is null union all select null,null,null,null,null,null,null,null from dual;
-
Hi dev
I am currently using below version
SELECTBANNER -------------------------------------------------------------------------------- Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production PL/SQL Release 11.2.0.1.0 - Production CORE 11.2.0.1.0 Production TNS for 32-bit Windows: Version 11.2.0.1.0 - Production NLSRTL Version 11.2.0.1.0 - Production {CODE} here is my query to find out the list of indexes and positions in a single schema.
USER_INDEXES. TABLE_NAME | CHR (9) |
USER_INDEXES. INDEX_NAME | CHR (9) |
TRIM (user_ind_columns. COLUMN_NAME) | CHR (9) |
user_ind_columns.Column_Position | CHR (9) |
trim (user_ind_columns. DOWN) ORDERTYPE
From user_indexes, user_ind_columns
WHERE user_indexes. Table_name = user_ind_columns. TABLE-NAME
AND user_indexes. Index_name = user_ind_columns. INDEX_NAME
AND user_indexes.index_name NOT IN (select index_name FROM user_constraints where index_name is not null);
Table_name column_name position OrderType index_nameThe output is like :
----------------- ------------------ ------------------- ----------- ---------------
ACS_TEST ACS_TEST_IDX COL2 CSA 2
ACS_TEST ACS_TEST_IDX COL1 1 CSA
C_COLLEGE INX_COLL DEPT_ID 4 CSA
C_COLLEG LAST_NAME INX_COLL 3 ASC
C_COLLEGE INX_COLL FIRST_NAME 2 CSA
C_COLLEGE INX_COLL STUDENT_ID 1 CSA
Table_name Index_name column_namesi am trying to spool the output to .txt file. in textfile the output should be in below format :
---------------- ---------------- ------------------
ACS_TEST ACS_TEST_IDX COL1, COL2
C_COLLEGE INX_COLL STUDENT_ID, FIRST_NAME, LAST_NAME, DEPT_IDNote : Based on the position value the column name have to be placed. Please help me to get such ouput format. Thanks,
Hello
Please edit and reformat your message it's horrible.
A way to get what you need using the LISTAGG:
SELECT ui.table_name , ui.index_name , LISTAGG (uic.column_name, ',') WITHIN GROUP (ORDER BY uic.column_position) cols FROM user_indexes ui, user_ind_columns uic WHERE ui.table_name = uic.table_name AND ui.index_name = uic.index_name AND NOT EXISTS (SELECT 1 FROM user_constraints WHERE index_name = ui.index_name) GROUP BY ui.table_name, ui.index_name;
Kind regards.
Al
Maybe you are looking for
-
Problem Audio Line Out HP Docking Station A7E36AA #ABB
Hello I have the Elitebook 8570p (Win7 Pro x 64) and the Docking Station A7E36AA # ABB I plugged my speakers with audio line out of the docking station, but the sounds of music 'flat', without no bass. I tried the same speakers with the line out of t
-
Update the BIOS to boot from USB on a Satellite P20
Hi all I would like to be able to boot to a USB with my P20 drive. However, upgrades to the bios, which I find to PSP26 reference date of the 2004 numbers, a few months older than my laptop itself - which the BIOS does not have the USB boot. This mea
-
The game will crash and weird sounds occur
whenever I play prototype or all games... the game will crash and noise weird happen... I try to uninstall and install back but it doesnot work. I need help with this question... Please help me My lathop properties: Alienware m15xIntel Core i7 CPU @1
-
I had trouble with this KernelBase.dll and I need to overwrite it. How can I get permission to do?
-
How can I change the layout of a listview of Interior programically qml
Hello Is it possible to change the layout of a listview inside qml., i programically; e in both ways between the layout: StackListLayout for the layout: GridListLayout...