Sort this !

Hi guys,
Its not a HTMLDB problem but a sql "order by" problem which is causing me some grief, thought would post it up here if anyone has any good ideas :-)
Please take a look at :-
http://htmldb.oracle.com/pls/otn/f?p=26396:1:12152463845138080636
I have a report which is displaying my sort_test table. Please ignore the first column (my_sort) as it is not part of the table (I just used it to display the records in right order for demonstration).
The first 14 rows (my_seq 1 to 14) is how the data currently exists and rows 16-29 is how I want them to be sorted. This data has been downloaded from a fixed length file having record types like 'H' for student header, 'M' for student matching ,'N' for student note, 'C' for student course and 'S' for student subject.
The file should always have records in the order of
H,M,N,C,S i.e first the header, then student matching, then student note, then student course and lastly subjects. A student may have 0-n courses, a student may have 0-n notes, a course may have 0-n subjects.
I am using recid to uniquely identify a student header.Therefore, the first order by clause should be rec_id. The "seq" field is just a surrogate key and means nothing.
Within 'M' the notes ('N') should be sorted by note_seq.
Within 'M' the courses should be ordered by course_cd alpha ascending.
Within 'C' the subjects should be sorted by
1.unit year
2. unit sem start dt
3. unit cd
Has anyone got any ideas on how to achieve this "messy" sort ?
thanks

I guess, I will have to tell you the whole story then.
What I am actually trying to do is to read a fixed length file produced by a third party tool and randomly add subjects/notes to it because it is missing some of them.
The file would look like this :-
H3020THIS IS THE FILE HEADER 20050503212820Q2000892 259619930Y001
MSCB97513769 PETER SMITH 19790123N0002
N100 ThIS is note one
N200 ThIS is note two
N300 ThIS is note three
C3020RBANT Bachelor of Arts (Nature Tourism) 08070101101NYN20000200510350Y026
SBBO1AE WORLD ENVIRONMENTS 20001000123C 301090001
C3020RBAS Bachelor of Applied Science 01000001101NYN19971199920300N024
SBBI110 BIOL110 CELL & ORGANISM 19971000125N 201090001
SBCH110 CHEM110 CHEMISTRY 1A 19971000125D 301050001
H3020THIS IS THE FILE HEADER 20050503212820Q2000895 259619930Y001
MSCB2527237 MICHAEL WILSON 19810807N0001
C3020ABA Bachelor of Arts 09000001101NYN20021200420191N011
SENG11TOT TEXTS OVER TIME 20021000125B 309152301
SLIN11NLA THE NATURE OF LANGUAGE A 20021000125D 309152101
I still have not started coding for it and am currently designing a solution for it. I am thinking on the lines of something like this :-
1. Read the entire file into a temp table with just 2 columns - recnum and text. recnum is a sequence number assigned when read from utl_file and text is the whole line string from the file.
2. Loop through all the records in this temp table (order by recnum) and insert them into a staging table, which would look like the sort_test you have seen before.
Therefore, if I read line 'M' then I just extract the student id from the line and put into the student_id field for REC_TYPE = 'M'. for 'C' ,I extract the course_cd, for 'S' I extract unit_code etc.
3. Then for a student id + course code I will try to find if the file is missing any units and notes, if yes, then insert them with the current recid and so on.
4. Lastly, I just need to sort this staging table and then write them to a new file.
Now, to answer your question..to be very honest I didn't even think that far :-), obviously I need to look at my design again. May be when I read a 'S' line and insert the unit_code etc into the file,I also need to insert the student_id and course_cd as well in the same line that I know that this unit belongs to this course code.that way I would be able to sort by course_cd,unit_cd etc ..
Do you think what I have designed above is going to work ? Can you suggest any better solution here ?
thanks

Similar Messages

  • My ipad just won't let me enter my apple password on FaceTime or iMessage, it works fine on my iPhone, I have tried numerous things but nothing works, can anybody help please, will a bug fix sort this out when they finally make one

    My ipad just won't let me sign in with my apple password on FaceTime or iMessage since updating to ios7 it says check my network connection, even though my iPhone works fine with the same password, can anybody help please, I have tried numerous things but nothing  works.  Will I have to wait for a bug fix to sort this? I hear they are working on one a the minute, I hate ios7

    Try a Restart.
    Press and hold the Sleep/Wake button for a few seconds until the red "slide to power off" slider appears, and then slide the slider. Press and hold the Sleep/Wake button until the Apple logo appears.
    Resetting your settings
    You can also try resetting all settings. Settings>General>Reset>Reset All Settings. You will have to enter all of your device settings again.... All of the settings in the settings app will have to be re-entered. You won't lose any data, but it takes time to enter all of the settings again.
    Resetting your device
    Press and hold the Sleep/Wake button and the Home button together for at least ten seconds, until the Apple logo appears. Apple recommends this only if you are unable to restart it.
    Or if this doesn't work and nobody else on the blog doesn't have a better idea you can contact Apple.
    Here is a link to their contacts with most of the information below.
    http://www.apple.com/contact/

  • My phone keeps coming up as sim failed, got till november to sort this out, dont haved an apple shop nearby, tried sim replacement, What do I do!

    I've had my phone since last November, so I'm rushing to sort this out because my garuntee will run out soon! I'm in a residential college and my phone keeps Sim failing up to thirty times a day at least! had this problem ever since I got the phone, gone to the orange store and they sent me to apple, I dont have an apple store anywhere near where I live different customer services tell me different things, change your sim, update and have tried both, my temperary solution is to re boot my phone but because i dont know when it sim fials till I look at my phone, I only find out thatt I've missed inportant phone calls and old messages when I turn it back on, then five minutes later it Sim Fails again! I'm so frustrated because obvously I'm away form home and its been a buger to sort out I htink I've just ran out of choices. Got an expensive phone, on an expensive contract, when it doens't even work properly, bad signal, bad internet connection, dont know what else to do!

    Is the phone carrier locked to O2 (sounds like it is)?  Unless your friend requested they unlock it before giving it to you (ie. while it was still on an account on their network), it will be carrier locked to them.
    You can contact O2 and ask them about unlocking it (they do support unlocking) but I don't know what they will tell you now that the account is closed and it is off their network.  Regardless, they are the only ones who can help you with a phone locked to their network.

  • I have locked myself out of my iPad and can not restore unless I go onto the iPad and turn off FindMyiPhone, how do I sort this out?

    After installing iOS7  I was prompted to make a passcode, I did so and stupidly forgot and now continually am disabling my iPad, ways in which I have read you can sort this is restoring your iPad, however I can not restore without iTunes telling me I need to go onto the iPad and turn off FindMyiPhone! How else can I sort this? It is logged into my apple account and everything! This is an iPad 2 also ASAP help!!

    Hello shanefox,
    This can be done by logging in at iCloud.com and removing your device via the Find My iPhone web interface.
    iCloud: Remove your device from Find My iPhone
    http://support.apple.com/kb/PH2702
    Cheers,
    Allen

  • HT1267 The Apple ID in my new IPhone is not the same as my ID . how can i sort this

    Hi, The Users ID on My New IPhone Is not the same as my apple ID
    How can I sort this ...

    Got it!!!!  A re-install is NOT the answer.  You need to turn on individual notifications under Settings > Facebook > Push Notifications, BUT (and this is a big and confusing BUT) you also need to turn on global push settings under Settings > Mail, Contacts, Calendards > Fetch New Data (and change the Push slider to 'on').  This doesn't sound like it makes sense, but I guess that the push slider under 'Mail, Contacts, Calendars' is actually for ALL push notifications on iPhone, and not just Mail, Contacts and Calendar apps!

  • Some calendars in iCal appear corrupted but OK on iPhone. If I sync will the calendar data on the phone restore info on the desktop iCal? any other ideas for how to sort this please?

    Some calendars in iCal appear corrupted (ie have red exclamation mark by them) but are still OK on iPhone. If I sync, will the calendar data on the phone restore info on the desktop iCal or will I lose that as well? Or could I back up the calendars on my iPhone somewhere and then import them into iCal? any other ideas for how to sort this please? it's driving me mad. thanks.

    I don't think there will be a solution to this. Exchange 2003 just isn't supported.

  • When i sync my ipod, i have notice that not all the music syncs and when i click on the ipod tab, some of the music has a round/two arrows?! How can i sort this out?!

    When i sync my ipod, i have noticed on the left hand side, under devices, my ipod, when i click on music, some of the songs are grey, and the others are black. The ones which are grey have a round circle with two arrows in. These are the ones which havent copied onto my ipod. I had no problem before until recently and all of a sudden! Can anyone please help me sort this out so that all my music will transfer onto my ipod, i have been trying for over a week!

    Never mind, the problem just fixed itself when i searched for an artist that wasn't there. That was odd.

  • I've just updated my iPad 3 to IOS 7 and when i try to type any thing be it a password or e-mail there is a long lag any idea how to sort this out ?

    I've just updated my iPad 3 to IOS 7 and when i try to type any thing be it a password or e-mail there is a long lag any idea how to sort this out ?

    Upgrade to Snow Leopard - it's compatible with the latest version of iTunes, and still supports PowerPC applications.
    $19.99 - http://store.apple.com/us/product/MC573Z/A/mac-os-x-106-snow-leopard
    Snow Leopard is required if you wanted to upgrade to Lion, anyway, which you may want to in the future if the latest version of iTunes no longer supports Snow Leopard.

  • Need to show proof of purchase to my insurance company, but my phone was replaced by apple so has a different imei number to the one on my receipt, how do you sort this out??

    Need to show proof of purchase to my insurance company, but my phone was replaced by apple so has a different imei number to the one on my receipt, how do you sort this out??

    Contact Apple and see if they can provide any documentation of the device swap.

  • I've had a fault with the hard drive on my laptop, it's been replaced and now my iphone and ipod can not sync unpurchased items with itunes. Is there anyway of sorting this without uploading all of my CD's again?

    I've had a fault with the hard drive on my laptop, it's been replaced and now my iphone and ipod can not sync unpurchased items with itunes. Is there anyway of sorting this without uploading all of my CD's again?

    If your CDs are on your iPod/iPhone, they can be recovered from there,see this post:
    https://discussions.apple.com/message/11857427#11857427
    Your problem shows the importance of making backups.

  • What's wrong with the IOS5 download, it downloads and then after its finished it says server timed out, how do i sort this out

    What's wrong with the IOS5 download, it downloads and then after its finished it says server timed out, how do i sort this out?

    The Firefox versions which come with many Linux distros have the default Mozilla Firefox updater disabled and use the distros built-in updater.
    See this - http://linuxforums.org.uk/netbooks/install-firefox-6-on-an-acer-aspire-one-running-linpus-lite-linux/

  • I have reset my iphone 5c and now has apple logo on the screen. I have tried holding home and lock buttons for 10 seconds, but to no avail. How do i sort this please ?

    I have reset my iphone 5c and now it has the apple logo on the screen.  Nothing is happening, apart from the screen going off for a few seconds, only to go back to black screen and white apple log.  I have tried holding home and lock buttons for 10 seconds, but to no avail.  I did a reset on settings as the IOS 8 was just slowing down my phone horrendously.   How do i sort this please ?

    Hi MartinH78,
    If your iPhone isn't responding or won't start up past the Apple logo, you may find the troubleshooting steps outlined in the following article helpful:
    iOS: Not responding or does not turn on
    Regards,
    - Brenden

  • And when i try to Re-install itunes i get a message from itunes ERROR 7 (windows error 1114), now how do i sort this out ???

    and when i try to Re-install itunes i get a message from itunes ERROR 7 (windows error 1114), now how do i sort this out ???

    Hey deepakmenonfrompune,
    Thanks for the question. I understand that you are experiencing issues with iTunes for Windows. The following resource may help to resolve your issue:
    iTunes 11.1.4 for Windows: Unable to install or open
    http://support.apple.com/kb/TS5376
    Some Windows customers may experience installation issues while trying to install or open iTunes 11.1.4.
    Symptoms may include:
    "The program can't start because MSVCR80.dll is missing from your computer"
    "iTunes was not installed correctly. Please reinstall iTunes. Error 7 (Windows Error 126)”
    "Runtime Error: R6034 - An application has made an attempt to load the C runtime library incorrectly"
    "Entry point not found: videoTracks@QTMovie@@QBE?AV?$Vector@V?$RefPtr@VQTTrack@@@***@@$0A@VCrashOnOverf low@@***@@XZ could not be located in the dynamic link library C:\Program Files(x86)\Common Files\Apple\Apple Application Support\WebKit.dll”
    Resolution
    Follow these steps to resolve the issue:
    Check for .dll files
    1. Go to C:\Program Files (x86)\iTunes and C:\Program Files\iTunes and look for .dll files.
    2. If you find QTMovie.DLL, or any other .dll files, move them to the desktop.
    3. Reboot your computer.
    Note: Depending on your operating system, you may only have one of the listed paths.
    Uninstall and reinstall iTunes
    1. Uninstall iTunes and all of its related components.
    2. Reboot your computer. If you can't uninstall a piece of Apple software, try using theMicrosoft Program Install and Uninstall Utility.
    3. Re-download and reinstall iTunes 11.1.4.
    Thanks,
    Matt M.

  • Cant open PDF's message keeps coming up to accept end user licence agreement how do I sort this out.

    Have a Mac OS X that had adobe reader installed on it but had to try and print a document but it kept telling me to download adobe reader update now I can't open PDF's  and message that comes up says I need to accept end user license agreement. Where do I do this or how do I sort this out URGENTLY PDF's needed for my business

    You don't need to delete anything, just launch it. Can you explain how you launched it, and what happened? It turns out that a lot of people misunderstand the word launch, so we need to ask.

  • Well, i was on my laptop now and all of a sudden a pop up message appeared and said "your download is complete" so i went to go check it out and it was 'MacProtector'. i cant delete it and it keeps opening unwanted web pages, please help me sort this out?

    Well, i was on my laptop now and all of a sudden a pop up message appeared and said "your download is complete" so i went to go check it out and it was 'MacProtector'. i cant delete it and it keeps opening unwanted web pages, please help me sort this out someone?

    Refer to:  http://cantalktech.com/2011/05/08/mac-protector/.

  • I've tried to register as a homeschooling family with iTunes U. (The registration options weren't geared to allow me to say as much.) My application was denied. Can anyone help me sort this out?

    I've tried to register as a homeschooling family with iTunes U. (The registration options weren't geared to allow me to say as much.) My application was denied. Can anyone help me sort this out?

    Private courses support up to 50 students, so you shouldn't have to register your family.
    Have you contacted Apple support?
    http://www.apple.com/support/itunes-u/public-site-manager/contact.html

Maybe you are looking for

  • How to Change Item catgegory in sales Order

    Hi all, I am creating sales order with reference to sales contract but at the time of sales order we don't have en off stock to deliver to customer , so we have deiced to go for Third party sales process But the problem is while creating a sales orde

  • Which program for basic business presentations?

    Forgive me but I need to ask for advice on what program to use for video editing for basic business presentations. I think Premiere Pro is way beyond my needs, mainly in terms of learning curve (as well as the cost). For what it's worth, I'm an avid

  • How to remove the 1st level folder under the main ones at each level

    In the normal mode, either in the Content Areas section or in your Folder Portlet on your page - all the sub folders are rendered in blue, and then under each one, its corresponding sub folders are also rendered in smaller font. Is there a way to dis

  • Oracle 10g 10.2.0.4 enterprise edition windows xp 32

    HI I am looking for oracle 10g 10.2.0.4 enterprise edition for windows xp 32.I didnt find it in oracle Site. Please refer to the following screen shot from oracle.com.Is it not available for windows xp 32.      Oracle Database 10g Release 2 (10.2.0.4

  • I cant call a procedure within a data template

    Hi, I m working in a data template because i want to call a prcedure befor running the report. My procedure is under the folder of procedure. it is not under a package. So i left the defaultpackage empty in the data model. *<dataTemplate name="Extrac