Sqlplus set statement:format the output without specifying every col length
Hi ppl,
i am writing below query inside a shell script. Is there any way to format the output of sqlplus without providing the name of all the columns that we are going to output. for example, in below code i have specified the column width of the columns i want to output. but if the number of columns is large (or when we want to do a select * from...) then it becomes tedious to write all of them. Is there any way i can define display length all the columns to be of same size.. or at least all the number columns of one size, char columns of one size etc...
sqlplus -sa/passwd@db_name << EOF
SET ECHO ON;
SET HEADING ON;
COLUMN USERNAME FORMAT A20;
COLUMN USER_ID FORMAT A20;
COLUMN PASSWORD FORMAT A20;
spool filename.txt
some qry... ;
exit
EOFThanks
Edited by: KnockTurnAll on 25 Oct, 2010 10:41 PM
Edited by: KnockTurnAll on 26-Oct-2010 04:25
My SQL*Plus is a bit rusty, but I don't think you can for characters. You can set NUMWIDTH for a default size for numeric columns.
You could write a small bit of SQL to generate the required column definitions. You could even hit ALL_TAB_COLUMNS to generate a generic 'set every column width' file and run it as a separate sql script in your main script. Not sure if there is an upper limit on the number of Columns you can define.
Back in the day when we did everything with SQL*Plus scripts, we had a standard columns file that we called in all our scripts, just for this purpose.
Carl
Similar Messages
-
Formatting the output (currency with decimals)
hi all,
i want to format the output of the currency field. Right now it displays the exact value like say 23 or 43.5 etc. But my requirement is i need it to display in a standard format as 23.00 , 43.50 , 565.00 etc. i,e if there is no decimals then it should be filled with zero's.
I have gone through some of the threads which speaks of formatting the output if it is a value node. But here i have directly bounded the table to a model node.
Domian level datatype of the field is Currency in R/3. After model import in dictionary it is showing as decimal.
How can i achieve this?I Appreciate if someone can help me on this.
Regards,
G Nidhi,
Go thru this link it might helps you.
column heading -refer to the webdynpro tutorial 34
Change the currency data type char and specify the length.
Thanks,
Lohi. -
Hi everyone in the forum,
I do not know if i should post this question here, but i think is the best place. Sorry if i were wrong.
just a question because i have no idea how to format the output i need.
I have a REAL or FLOAT and the output restrictions shows that it should be:
1.0000 D-08 if the value is less than 1
1.0000 if the value is [1,9]
1.0000 D+03 is value bigger than 9
and the other problem is whith other variable (type String) which represents integers, e.g, 0.000000 1.0000000 2.000000; and i have to return only 0 1 2 .
Any suggestion about how to format the output?
ThanksDecimalFormat
-
I formatted the computer without turning off my products what should I do?
I formatted the computer without turning off my products what should I do?
Install them all again.
Sorry, in seriousness, are you worrying about activation of a perpetual license? Pick up the phone and call Adobe Customer Support. Explain to them that you've reinstalled everything from scratch after formatting your system, and would like them to make it possible for you to activate Photoshop again. They'll work their database magic and you should be good to go to activate with your serial number again.
If you're on the Creative Cloud I don't believe you need to call anyone. Just log in with your Adobe ID.
-Noel -
To display the output without clicking on the View Output button
Hi,
I have a requirement in which i created a menu option in PO through which i submit a PO report using the fnd_request.submit_request. Now there is an additional requirement to view the output of that report (submitted using menu option) without even going to the SRS window. I would like to know if there are any possibilities of doing this.
Thanks.None.
-
Formatting the Output of a Table
Quite simply I am trying to format the laytout of a VC tabe so that
a)I can display the columnj header on 2 lines(narrower column)
and
b) I want to sort in descending order by a Key Figure
Is such things possiblw with the VC.
I have tried my book but no details on it.
ThanksJohn
Displaying column header text over multiple lines is not possible.
Sorting is possible. Use the sort operator between data service and table. Unfortunately you have to reconfigure the table because you cannot add the operator without dragging new lines between objects.
Henning -
Alv -change the output without modify the code
hi...............
how can we change the alv output without modifying the code .
plz help me.hi satya vani ,
use this code..after execution choose the button(ctrl+f8) then you can give the position and length of the output field..
then it will automatically changed...
report .
TABLES:LFA1.
SELECT-OPTIONS:LIFNR FOR LFA1-LIFNR.
DATA:BEGIN OF ITAB OCCURS 0,
LIFNR LIKE LFA1-LIFNR,
NAME1 LIKE LFA1-NAME1,
LAND1 LIKE LFA1-LAND1,
ORT01 LIKE LFA1-ORT01,
REGIO LIKE LFA1-REGIO,
SORTL LIKE LFA1-SORTL,
CFIELD(4) TYPE C,
END OF ITAB.
DATA:LINE TYPE I.
SELECT * FROM LFA1 INTO CORRESPONDING FIELDS OF TABLE ITAB WHERE LIFNR
IN LIFNR.
DESCRIBE TABLE ITAB LINES LINE.
LOOP AT ITAB.
IF SY-TABIX = LINE.
ITAB-CFIELD = 'C410'.
MODIFY ITAB.
ENDIF.
ENDLOOP.
TYPE-POOLS:SLIS.
DATA:FCAT TYPE SLIS_T_FIELDCAT_ALV.
DATA:LAYOUT TYPE SLIS_LAYOUT_ALV.
DATA:SORT TYPE slis_t_sortinfo_alv WITH HEADER LINE.
LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
LAYOUT-WINDOW_TITLEBAR = 'VENDORS DETAILS SCREEN'.
LAYOUT-EDIT = 'X'.
LAYOUT-info_fieldname = 'CFIELD'.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = SY-REPID
I_INTERNAL_TABNAME = 'ITAB'
I_INCLNAME = SY-REPID
CHANGING
CT_FIELDCAT = FCAT.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
IS_LAYOUT = LAYOUT
IT_FIELDCAT = FCAT
TABLES
T_OUTTAB = ITAB.
regards,
venkat. -
Common-net telnet formatting the output ?
Hi, I am using the code below to establish a telnet connection with a windows XP system. The code connects and successfully issues commands, however the output contains a lot of junk characters which i would like to exclude from the output. Does anyone have any experience with commons-net telnet and if so is there a way to tell the system that i am connecting to a winXP telnet server so that the output is formatted accordingly.Thanks
Sorry tried to post my code with the appropiate tags but it would not display correctly!Hello Saugat K.C,
This forum is about .NET Framework Setup, it is not related to dev. To help you get a direction, I would recommend you consider WCF forum or Web service forum, they are related to your case.
Since you haven't choosed the technology, I will move your case to off-topic. Please consider post this question to the forum I mentioned.
Best regards,
Barry
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey. -
Formatting the output in file out
Hi,
I have 5 fields in the internal table. I have used GUI_DOWNLOAD for downloading the file.
The down loaded file looks like this.
Field1 Field2 field3 filed4 field5
ABC 1234 20080131/405FED 161.65 161.65
ABC 1234 20080131/560 7883.76 7883.76
ABC 1234 20080131/701FED 6184.77 6184.77
But I want the output like this:
1. Spacing between columns 1 and 2 should be 3 spaces from after the last digit in column 1 to the first digit in column 2.
2. Spacing between columns 2 and 3 should be 5 spaces from after the last digit in column 2 to the first digit in column 3.
3. Spacing between columns 3 and 4 should be 8 spaces from after the last digit in column 3 to directly after the last digit in column 4.
4. Spacing between columns 4 and 5 should be 10 spaces from after the last digit in column 4 to directly after the last digit in column 5.
Please help how to procedure.
Thanks,
Sham.I just tried this piece of code and it seems to work fine:-
TYPES : BEGIN OF ty_1,
f1 TYPE char15,
f2 TYPE char15,
f3 TYPE char15,
END OF ty_1,
BEGIN OF ty_2,
text TYPE char100,
END OF ty_2.
DATA : lt_1 TYPE TABLE OF ty_1, lt_2 TYPE TABLE OF ty_2,lc_ct TYPE i,lc_star TYPE char10,
ls_1 TYPE ty_1,ls_2 TYPE ty_2,ls_3 TYPE ty_2.
FIELD-SYMBOLS <fs> TYPE ANY.
ls_1-f1 = 'A'.ls_1-f2 = 'AA'.ls_1-f3 = 'AAA'.APPEND ls_1 TO lt_1.
ls_1-f1 = 'B'.ls_1-f2 = 'BB'.ls_1-f3 = 'BBB'.APPEND ls_1 TO lt_1.
ls_1-f1 = 'C'.ls_1-f2 = 'CC'.ls_1-f3 = 'CCC'.APPEND ls_1 TO lt_1.
ls_1-f1 = 'D'.ls_1-f2 = 'DD'.ls_1-f3 = 'DDD'.APPEND ls_1 TO lt_1.
ls_1-f1 = 'E'.ls_1-f2 = 'EE'.ls_1-f3 = 'EEE'.APPEND ls_1 TO lt_1.
LOOP AT lt_1 INTO ls_1.
DO.
ASSIGN COMPONENT sy-index OF STRUCTURE ls_1 TO <fs>.
IF sy-subrc <> 0.
EXIT.
ENDIF.
CASE sy-index.
WHEN 1.
DO.
lc_ct = lc_ct + 1.
IF lc_ct > 3.
CONCATENATE <fs> lc_star INTO ls_2.
EXIT.
ENDIF.
CONCATENATE lc_star '*' INTO lc_star.
ENDDO.
WHEN 2.
DO.
lc_ct = lc_ct + 1.
IF lc_ct > 5.
CONCATENATE <fs> lc_star INTO ls_2.
EXIT.
ENDIF.
CONCATENATE lc_star '*' INTO lc_star.
ENDDO.
WHEN 3.
DO.
lc_ct = lc_ct + 1.
IF lc_ct > 8.
CONCATENATE <fs> lc_star INTO ls_2.
EXIT.
ENDIF.
CONCATENATE lc_star '*' INTO lc_star.
ENDDO.
ENDCASE.
CONCATENATE ls_3 ls_2 INTO ls_3.
CLEAR: ls_2, lc_star,lc_ct.
ENDDO.
TRANSLATE ls_3 USING '* '.
APPEND ls_3 TO lt_2.
CLEAR : ls_3,ls_1.
ENDLOOP.
Result:-
A AA AAA
B BB BBB
C CC CCC
D DD DDD
-- Dedeepya -
Downloading my entire library from the cloud without clicking every song
OK I have a every large iTunes library. I haven't used a local drive in years. And my back up or so dated that I would not trust them. My question is can I downliAd my music with just on click or do I have to click the cloud icon for every song. Im using the latest version of itunes for Yosemit.
Thanks for your helpTo download all purchases - https://discussions.apple.com/message/22016876#22016876
If the items are not purchases you have to get them from a backup or original source. -
Formating the output using SO_NEW_DOCUMENT_SEND_API1
Hi ,
I am using the FM 'SO_NEW_DOCUMENT_SEND_API1' for sending data in an internal table as an email . I am wondering whether it will be possible to to send it in the table format with the field names intact. Currently i am able to send the mail but without the table field names . Please help
Regards,
Tashihello gurus,
please check this below program.
TABLES : ADR6.
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
PARAMETERS : SPOOLNO TYPE TSP01-RQIDENT OBLIGATORY.
SELECT-OPTIONS : MAILS FOR ADR6-SMTP_ADDR DEFAULT 'xyz.com' OBLIGATORY NO INTERVALS.
SELECTION-SCREEN END OF BLOCK B1.
DATA SEND_REQUEST TYPE REF TO CL_BCS.
DATA DOCUMENT TYPE REF TO CL_DOCUMENT_BCS.
DATA RECIPIENT TYPE REF TO IF_RECIPIENT_BCS.
DATA BCS_EXCEPTION TYPE REF TO CX_BCS.
DATA SENT_TO_ALL TYPE OS_BOOLEAN.
DATA PDF_SIZE TYPE SO_OBJ_LEN.
DATA PDF_CONTENT TYPE SOLIX_TAB.
DATA PDF_XSTRING TYPE XSTRING.
DATA MAILTO TYPE AD_SMTPADR.
START-OF-SELECTION.
PERFORM CREATE_PDF.
PERFORM SEND.
*& Form send
FORM SEND.
TRY.
-------- create persistent send request ------------------------
SEND_REQUEST = CL_BCS=>CREATE_PERSISTENT( ).
-------- create and set document -------------------------------
PDF_CONTENT = CL_DOCUMENT_BCS=>XSTRING_TO_SOLIX( PDF_XSTRING ).
DOCUMENT = CL_DOCUMENT_BCS=>CREATE_DOCUMENT(
I_TYPE = 'PDF'
I_HEX = PDF_CONTENT
I_LENGTH = PDF_SIZE
I_SUBJECT = 'sending pdf as email' ). "#EC NOTEXT
add document object to send request
SEND_REQUEST->SET_DOCUMENT( DOCUMENT ).
LOOP AT MAILS. " for sending multiple mails we can use this logic
MAILTO = MAILS-LOW.
--------- add recipient (e-mail address) -----------------------
create recipient object
RECIPIENT = CL_CAM_ADDRESS_BCS=>CREATE_INTERNET_ADDRESS( MAILTO ).
add recipient object to send request
SEND_REQUEST->ADD_RECIPIENT( RECIPIENT ).
ENDLOOP.
---------- send document ---------------------------------------
SENT_TO_ALL = SEND_REQUEST->SEND( I_WITH_ERROR_SCREEN = 'X' ).
COMMIT WORK.
IF SENT_TO_ALL IS INITIAL.
MESSAGE I500(SBCOMS) WITH MAILTO.
ELSE.
MESSAGE S022(SO).
ENDIF.
------------ exception handling ----------------------------------
replace this rudimentary exception handling with your own one !!!
CATCH CX_BCS INTO BCS_EXCEPTION.
MESSAGE I865(SO) WITH BCS_EXCEPTION->ERROR_TYPE.
ENDTRY.
ENDFORM. "send
*& Form create_pdf
Create PDF Content
1) get attributes of spool request
2) convert spool request to PDF dependent on document type
FORM CREATE_PDF.
DATA RQ TYPE TSP01.
DATA BIN_SIZE TYPE I.
DATA DUMMY TYPE TABLE OF RSPOATTR.
------------ get attributes of spool request ---------------------
CALL FUNCTION 'RSPO_GET_ATTRIBUTES_SPOOLJOB'
EXPORTING
RQIDENT = SPOOLNO
IMPORTING
RQ = RQ
TABLES
ATTRIBUTES = DUMMY
EXCEPTIONS
NO_SUCH_JOB = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
MESSAGE E126(PO) WITH SPOOLNO.
ENDIF.
--- convert spool request into PDF, dependent on document type ---
IF RQ-RQDOCTYPE = 'OTF' OR RQ-RQDOCTYPE = 'SMART'.
CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'
EXPORTING
SRC_SPOOLID = SPOOLNO
NO_DIALOG = 'X'
PDF_DESTINATION = 'X'
NO_BACKGROUND = 'X'
IMPORTING
PDF_BYTECOUNT = BIN_SIZE
BIN_FILE = PDF_XSTRING
EXCEPTIONS
ERR_NO_OTF_SPOOLJOB = 1
ERR_NO_SPOOLJOB = 2
ERR_NO_PERMISSION = 3
ERR_CONV_NOT_POSSIBLE = 4
ERR_BAD_DSTDEVICE = 5
USER_CANCELLED = 6
ERR_SPOOLERROR = 7
ERR_TEMSEERROR = 8
ERR_BTCJOB_OPEN_FAILED = 9
ERR_BTCJOB_SUBMIT_FAILED = 10
ERR_BTCJOB_CLOSE_FAILED = 11
OTHERS = 12.
IF SY-SUBRC <> 0.
MESSAGE E712(PO) WITH SY-SUBRC 'CONVERT_OTFSPOOLJOB_2_PDF'.
ENDIF.
ELSEIF RQ-RQDOCTYPE = 'LIST'.
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
SRC_SPOOLID = SPOOLNO
NO_DIALOG = 'X'
PDF_DESTINATION = 'X'
NO_BACKGROUND = 'X'
IMPORTING
PDF_BYTECOUNT = BIN_SIZE
BIN_FILE = PDF_XSTRING
EXCEPTIONS
ERR_NO_ABAP_SPOOLJOB = 1
ERR_NO_SPOOLJOB = 2
ERR_NO_PERMISSION = 3
ERR_CONV_NOT_POSSIBLE = 4
ERR_BAD_DESTDEVICE = 5
USER_CANCELLED = 6
ERR_SPOOLERROR = 7
ERR_TEMSEERROR = 8
ERR_BTCJOB_OPEN_FAILED = 9
ERR_BTCJOB_SUBMIT_FAILED = 10
ERR_BTCJOB_CLOSE_FAILED = 11
OTHERS = 12.
IF SY-SUBRC <> 0.
MESSAGE E712(PO) WITH SY-SUBRC 'CONVERT_ABAPSPOOLJOB_2_PDF'.
ENDIF.
ELSE.
MESSAGE E789(PO) WITH RQ-RQDOCTYPE.
ENDIF.
PDF_SIZE = BIN_SIZE.
ENDFORM. "create_pdf -
How to format the output of Today() ⨍(x) when used in a formula
This table should explain what I'm asking to do. Have the Wed, Nov 2, 2011 applied to a date when I use the Today() function. Without the workaround of refernencing another cell to pickup formatting like I do in the final row.
Formula
Cell Format
Result
=CONCATENATE("Today is ",TODAY())"
Date: Mon,Jan 5, 2009 Time: None
Today is 02/11/2011
=TODAY()
Date: Mon,Jan 5, 2009 Time: None
Wed, Nov 2, 2011
= CONCATENATE("Today is ",C3)
Date: Mon,Jan 5, 2009 Time: None
Today is Wed, Nov 2, 2011Hi Barry
I just discover this thread.
The main problem here is that as we aren't allowed to define the format used by TODAY() in the described formula, we have to use a formula which is localization dependant which is really annoying.
For my own use, I will just use two columns :
In the first one the formula would be :
=IF(MID(""&1/2,2,1)=".","Nous sommes le","Today is")
In the second one it would be :
=TODAY()
The vertical border between the two columns is set to white.
But I think that the most efficient answer would be that Apple give us the ability to pass a parameter to TODAY() and/or NOW().
This parameter would define the format which would remain the current one when the parameter is omitted.
Yvan KOENIG (VALLAURIS, France) 07 /11 /2011 17:38:15
iMac 21”5, i7, 2.8 GHz, 4 Gbytes, 1 Tbytes, mac OS X 10.6.8 and 10.7.2
My iDisk is : <http://public.me.com/koenigyvan>
Please : Search for questions similar to your own before submitting them to the community -
Need help to format the output of the query.
First of all i would like to say I m newbi in oracle query
and of course thanks to read the thread.
I have a problem formatting a query output.
Actually the query is like the following :
select a1
,b1
,c1
from table
where id.table=1
UNION
select a2
,b2
,c2
from table2
where id.table2=1
order by 1;
exit;
my actual output
a1 b1 c1
a2 b2 c2
a1 b1 c1
a2 b2 c2
my desired output
a1 b1 c1
a2 b2 c2
a1 b1 c1
a2 b2 c2
So what i need is an empy row between the groups of results
and to shift the union query.
thanks in advanceSQL>select * from t1;
C1 C2 C3
1 2 3
2 3 4
3 4 5
SQL>select * from t2;
C1 C2 C3
30 40 50
20 30 40
10 20 30
SQL>select c1,c2,c3
2 from( select c1,c2,c3,1 flg
3 from t1
4 union all
5 select c1,c2,c3,2
6 from t2
7 union all
8 select null,null,null,1
9 from dual)
10 order by flg,c1,c2,c3 nulls last;
C1 C2 C3
1 2 3
2 3 4
3 4 5
<br>
10 20 30
20 30 40
30 40 50
7 rows selected.
Funny....... -
Format the output file by command spool
Hi,
I use sqplus in oracle to output the command output to text file .
I use below set environment varialble.
SQL> set echo off;
SQL> set linesize 3999;
SQL> set feedback off;
SQL> set feedback off;
SQL> set termout off;
SQL> set pagesize 0;
SQL> spool mapping.txt
select C_SIM_MSISDN,C_SIM_IMSI from RCA_SMART_CARD order by C_SIM_MSISDN;
In ouput file , it look like
SQL> select C_SIM_MSISDN,C_SIM_IMSI from RCA_SMART_CARD order by C_SIM_MSISDN;
060010007 10007
SQL> spool off;
any setting or command that allow me to remove
the first sql command line" SQL>select XXXX"
and the last command "SQL>spool off" after start up the "spool mapping.txt"Hi,
Don't type those commands (at least the ones between SPOOL and SPOOL OFF, inclusive) directly into SQL*Plus. Instead, put them in a script, run the script.
For example, if you create a file called d:\foo\bar\smart_card.sql, that looks like this:
set echo off;
set linesize 3999;
set feedback off;
set feedback off;
set termout off;
set pagesize 0;
spool mapping.txt
select C_SIM_MSISDN
, C_SIM_IMSI
from RCA_SMART_CARD
order by C_SIM_MSISDN;
spool offThen all you type at the SQL> prompt is
@c:\foo\bar\smart_card -
My friend bought on my advice a macbook pro. He has no internet connection at home. Getting started with the macbook pro, we can't skip the internet connection information box.
This may seem a little strange in a www organised world, but he only wants to use the macbook for storing photos and music.
Is there something we overlooked, or is internet connection a must?
ThxThere should be a place to select "Other network options" or some such wording, where you can select "This Mac does not connect to the internet."
Maybe you are looking for
-
After upgrading to Leopard on iMac, I cannot login.
I have gotten my iMac barely yesterday. It came with the Leopard Software Upgrade on CD. Before I installed the Leopard, I had turned it on to see if it works and it did. Right away, I installed the Leopard and it said that everything was successfull
-
Login issue in OIM 11g R2 from a custom application
Hi All, We are facing the below error while trying to login to OIM 11gR2 from a client application. javax.security.auth.login.LoginException: javax.security.auth.login.LoginException: java.lang.SecurityException: java.lang.ClassCastException: weblog
-
Need a exit while deleting the line item in PO
Hi to all experts , My requirement is to find an exit or badi when the user deletes a line item and click on save the line item should be captured,. Is there any badi or exit which can do it .
-
How to put your ipod in recovery mode
how do i put my ipod in recovery mode because i forget my password
-
I am unable to reach the my content page of mysites from the name link within my site collection
For some reason I am no longer able to get to the personal mysites page from within our site collection. My name appears at the top right and it has an option for setting which leads to some minimal page but I can no longer use this to get to the act