Solved

Problem wit spool

Posted on 2013-12-13
10
394 Views
Last Modified: 2013-12-13
Hi, from the script test.sh I have the next spool:

2013/12/11 23:55:00!13006!PSM_4___P      Calculo Demanda!0!#..!0!#..!!0!#..!!0!#..!
2013/12/11 23:55:00!13007!PSM_4___Q      Calculo Demanda!0!#..!0!#..!!0!#..!!0!#..!
UTCTIME!POINTNUMBER!POINTNAME!VALUE_INST!TLQ_INST!VALUE_PROM!TLQ_PROM!UTCTIME_MAX!VALUE_MAX!TLQ_MAX!UTCTIME_MIN!VALUE_MIN!TLQ_MIN!

Open in new window


But I need change the order of output, It must show:

UTCTIME!POINTNUMBER!POINTNAME!VALUE_INST!TLQ_INST!VALUE_PROM!TLQ_PROM!UTCTIME_MAX!VALUE_MAX!TLQ_MAX!UTCTIME_MIN!VALUE_MIN!TLQ_MIN!
2013/12/11 23:55:00!13006!PSM_4___P      Calculo Demanda!0!#..!0!#..!!0!#..!!0!#..!
2013/12/11 23:55:00!13007!PSM_4___Q      Calculo Demanda!0!#..!0!#..!!0!#..!!0!#..!

Open in new window


Could you help me?,  Where is the error?
Regards
Test.sh
0
Comment
Question by:carlino70
  • 4
  • 3
  • 2
  • +1
10 Comments
 
LVL 23

Expert Comment

by:David
ID: 39717072
Drop the "ORDER BY 1" sort, in your character set the numerals have a lower value than alpha.  However, that will drop your nice sort.

Which char set are you using?
0
 

Author Comment

by:carlino70
ID: 39717110
without "ORDER BY 1" it works,

but I need to see the output in order ascending order by "utctime"the output in order ascending from utctime

select * from database_properties
where PROPERTY_NAME in ('NLS_CHARACTERSET',
'NLS_NCHAR_CHARACTERSET');

PROPERTY_NAME|PROPERTY_VALUE|DESCRIPTION
NLS_CHARACTERSET|AL32UTF8|Character set
NLS_NCHAR_CHARACTERSET|AL16UTF16|NCHAR Character set

Open in new window

0
 
LVL 31

Expert Comment

by:awking00
ID: 39717116
The problem is the order by 1 which sets the order after the union. Change it to order by 1 desc or just eliminate it altogether.
0
 
LVL 31

Expert Comment

by:awking00
ID: 39717123
Sorry, I didn't see the other posts before I submitted.
0
 
LVL 31

Expert Comment

by:awking00
ID: 39717137
Since you're using a yyyy/mm/dd hh24:mi:ss date format, you'll be okay (other date formats might not work).
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 23

Expert Comment

by:David
ID: 39717142
Show us your session values for these two variables:

echo $LC_CTYPE      # accept iso-latin-1 characters
echo $LC_COLLATE      # collate in strict numeric order
0
 

Author Comment

by:carlino70
ID: 39717153
I don't see those variables
0
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 500 total points
ID: 39717181
You could just add the constant character "1" as the first column of the first "select", and the constant character "2" as the first column of the second "select":

select '1' dummy,
'UTCTIME!POINTNUMBER!POINTNAME!VALUE_INST!TLQ_INST!VALUE_PROM!
...
union all
SELECT '2' dummy,
TO_CHAR(H.UTCTIME,'YYYY/MM/DD HH24:MI:SS')||'!'||TO_CHAR
...

Now add after your "set" commands

column dummy noprint

and change the order statement to

order by 1,2

and you should be fine.

wmp
0
 

Author Closing Comment

by:carlino70
ID: 39717203
Excellent
Thanks and regards!
0
 
LVL 31

Expert Comment

by:awking00
ID: 39717302
Were you not satisfied or not get the right results when removing the order by1 (or making it order by 1 desc)?
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
sql query 5 52
select only modified column name  based on the status 15 38
linux boot fsck problem 3 43
Linux as a middle box 7 18
This post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now