What is the best way to do this? I am stuck!!

I have a block with this, PLEASE help! I am writing a plsql package that is going to create a custom table everything is going fine EXCEPT that I don’t know what will be the best way to do this. Please point me in the right direction a function or something:
I have three tables:
My custom table SZSLIFE
Two existing tables in my DATABASE:
SGBSTDN,
SLRRASG
For this pidm (primary key). I have the following records in the SLRRASG table:
SLRRASG_PIDM     SLRRASG_BLDG_CODE     SLRRASG_ROOM_NUMBER     SLRRASG_TERM_CODE     SLRRASG_RRCD_CODE     SLRRASG_BEGIN_DATE
139203     ADD     103     200490     RCOM     09/02/2004
139203     ADD     103     200510     RCOM     01/24/2005
139203     BLA     001     200390     RCOM     09/03/2003
139203     BLA     001     200410     RCOM     01/25/2004
139203     HRK     101     200690     RCOM     08/31/2006
139203     RIV     11     200590     RCOM     09/01/2005
And I have the following records in the SGBSTDN table.
SGBSTDN_PIDM     SGBSTDN_TERM_CODE_EFF     SGBSTDN_STST_CODE     SGBSTDN_LEVL_CODE     SGBSTDN_STYP_CODE     SGBSTDN_TERM_CODE_MATRIC
139203     200390     AS     UG     C     200390
139203     200410     AS     UG     C     200390
139203     200590     DW     UG     C     200390
139203     200610     IS     UG     C     200390
139203     200660     AS     UG     C     200390
139203     200690     AS     UG     E     200390
139203     200710     IS     UG     C     200390
So far I have been able to insert the following records in my custom table. This data is coming from the sgbstdn table
SZSLIFE_PIDM     SZSLIFE_SLRRASG_TERM_CODE     SZSLIFE_STUDENT_STATUS_CODE     SZSLIFE_STUDENT_STATUS_DESC     SZSLIFE_STUDENT_TYPE_CODE     SZSLIFE_STUDENT_TYPE_DESC     SZSLIFE_STUDENT_LEVEL_CODE     SZSLIFE_STUDENT_LEVEL_DESC
139203     200390     AS     Active     C     Continuing     UG     Undergraduate
139203     200410     AS     Active     C     Continuing     UG     Undergraduate
139203     200590     DW     Directed to Withdraw     C     Continuing     UG     Undergraduate
139203     200610     IS     Inactive     C     Continuing     UG     Undergraduate
139203     200660     AS     Active     C     Continuing     UG     Undergraduate
139203     200690     AS     Active     E     Readmit/Re-entry     UG     Undergraduate
139203     200710     IS     Inactive     C     Continuing     UG     Undergraduate
NOW the question is: I need to insert the rows from the term 200490 and 200510 because there is data in the slrrasg table for those terms BUT the data that I need to insert is coming from the SGBSTDN table and there is not data for those terms in sgbstdn, so my user is telling my that it is okay to insert the previous term from sgbstdn for example: for the term 200490 I need to insert trhe 200490 in the szslife_slrrasg_term_code but I also need to insert the row from the 200390(previous one) from SGBSTDN.
The same for 200510 insert 200510 in szslife_slrrasg_term_code but the rows from the term 200410 in SGBSTDN.
Please give some ideas of how to do this. I will highly appreciate.

Thank you very much for your answer, I have to confess that I am confused, never code this way. It looks very cool, I will like to learn this technique.
This is what I have using my tables and my columns.
What is the idea here? create a table 4 on the fly with all the coulmns that I need? This is what I have but I don't thing is going to work.
2) do you need to have the same number of columns in the select like when you do a UNION?
WITH tab1 AS
(SELECT
sgbstdn_term_code_eff,
sgbstdn_term_code_eff,
sgbstdn_stst_code,
sgbstdn_styp_code,
sgbstdn_levl_code,
sgbstdn_resd_code
FROM sgbstdn
UNION ALL
SELECT
slrrasg_term_code,
slrrasg_bldg_code ,
slrrasg_room_number,
slrrasg_rrcd_code ,
slrrasg_begin_date ,
slrrasg_end_date,
slrrasg_ascd_code
FROM SLRRASG
UNION ALL
SELECT
szslife_slrrasg_term_code,
szslife_student_status_code,
szslife_student_type_code,
szslife_student_level_code,
szslife_student_level_desc,
szslife_residency_code,
szslife_building_code,
szslife_room_number,
szslife_assignment_begin_date,
szslife_assignment_end_date,
szslife_assignment_status
FROM szslife
UNION ALL
SELECT NEW_TABLE ---QUESTION what I need to select here all the columns from table 1,2,3?
tab2 AS
(SELECT
sgbstdn_term_code_eff,
sgbstdn_term_code_eff,
sgbstdn_stst_code,
sgbstdn_styp_code,
sgbstdn_levl_code,
sgbstdn_resd_code
FROM sgbstdn
UNION ALL
SELECT
szslife_slrrasg_term_code,
szslife_student_status_code,
szslife_student_type_code,
szslife_student_level_code,
szslife_student_level_desc,
szslife_residency_code,
szslife_building_code,
szslife_room_number,
szslife_assignment_begin_date,
szslife_assignment_end_date,
szslife_assignment_status
FROM szslife
UNION ALL
SELECT NVL(tab2.a,lag(tab1.a) over(ORDER BY tab1.a))
FROM tab1, tab2
WHERE tab1.a = tab2.a(+)
I will apprecite your help, I did look in my books for a similar example but not luck.
Rogelio

Similar Messages

  • My old computer is dying and I want to transfer my account to my new computer.  I will not be using the old computer at all.  What is the best way do do this?

    I want to stop using my old computer completely and transfer my itunes account to my new computer.  What is the best way to do this?

    A simple search

  • I am trying to make a pdf of a file and I need to get the file size to be no bigger than 10MB. What is the best way to do this

    I am trying to make a pdf of a file and I need to get the file size to be no bigger than 10MB. Even when I save it, the image quality at minimum the file size is 10.9 MB. What is the best way to do this

    @Barbara – What purpose is that PDF for? Print? Web?
    If web purpose, you could convert CMYK images to sRGB. That would reduce the file size as well.
    A final resort to bring down file size is:
    1. Print to PostScript
    2. Distill to PDF
    That would bring file size down even more. About 20%, depending on the images and other contents you are using, compared with the Acrobat Pro method. If you like you could send me a personal message, so we could exchange mail addresses. I could test for you. Just provide the highres PDF without any downsampling and transparency intact. Best provide a PDF/X-4.
    I will place the PDF in InDesign, print to PostScript, distill to PDF.
    Uwe

  • HT1451 I need to move my library from my old computer to my new laptop. What's the best way to do this?

    I need to move my library from my old computer to my new laptop (Windows 8). What's the best way to do this?

    These are two possible approaches that will normally work to move an existing library to a new computer.
    Method 1
    Backup the library with this User Tip.
    Deauthorize the old computer if you no longer want to access protected content on it.
    Restore the backup to your new computer using the same tool used to back it up.
    Keep your backup up-to-date in future.
    Method 2
    Connect the two computers to the same network. Share your <User's Music> folder from the old computer and copy the entire iTunes library folder into the <User's Music> folder on the new one. Again, deauthorize the old computer if no longer required.
    Both methods should give the new computer a working clone of the library that was on the old one. As far as iTunes is concerned this is still the "home" library for your devices so you shouldn't have any issues with iTunes wanting to erase and reload.
    I'd recommend method 1 since it establishes an ongoing backup for your library.
    If you have an iOS device that syncs with contact & calendar data on your computer you should migrate this information too. If that isn't possible create a dummy entry of each type in your new profile and iTunes should offer to merge the existing data from the device into the computer, otherwise the danger is that it will wipe the information from the device.
    If your media folder has been split out from the main iTunes folder you may need to do some preparatory work to make it easier to move. See make a split library portable.
    Should you be in the unfortunate position where you are no longer able to access your original library, or a backup of it, then see Recover your iTunes library from your iPod or iOS device for advice on how to set up your devices with a new library with the maximum preservation of data. If you don't have any Apple devices then see HT2519 - Downloading past purchases from the App Store, iBookstore, and iTunes Store.
    tt2

  • I want to upgrade my Imac from tiger 10.4.11 to Mac OS 10.6 Snow Leopard. What is the best way to do this.

    I have just purchased an iphone 4 and it needs me to have the latest itunes on my computer.  I have not upgraded by computer for some time and thought this is probably the time to do it. My computer is an imac intel with Tiger 10.4.11. I want to upgrade my Imac from tiger 10.4.11 to Mac OS 10.6 Snow Leopard or higher.  What is the best way to do this?  Appreciate any help as I am out of practice. I used to be an old hand at this, but things have moved on since I didn't upgrade or use my computer as much!

    Catherina wrote:
    ...  What is the best way to do this?
    The best way, really the only way, is to purchase Snow Leopard.
    Online (UK): http://store.apple.com/uk/product/MC573/mac-os-x-106-snow-leopard
    Elsewhere: call the phone number in the Apple Online Store.
    Apple's price is $19.99, £14.00, €18.
    Snow Leopard is not available to download from any legitimate source.
    Once you install Snow Leopard, upgrade iTunes to version 10.7 or the latest, iTunes 11.
    iTunes 10.6.3 is the last version of iTunes to support Mac computers with Mac OS X 10.5.8 with either Intel or PowerPC processors, but since you have an Intel iMac, the best solution is to purchase Snow Leopard. Leopard is no longer available from Apple and prices from aftermarket vendors can be unreasonably high.

  • Urchased a new desktop pc and I want to move itunes and all files including IPAD apps to my new computer and delete off my old one.  What is the best way to do this?

    I just purchased a new desktop PC and want to move Itunes and all my Ipad Apps to new computer, and delete off my old computer.  What is the best way to do this?

    Hi,
    See Here for Transferring your iTunes Library
    http://support.apple.com/kb/HT4527
    Make sure Everything is working to your satisfaction Before Deleting anything from your old computer...
    Cheers,

  • What's the best way for reading this binary file?

    I've written a program that acquires data from a DAQmx card and writes it on a binary file (attached file and picture). The data that I'm acquiring comes from 8 channels, at 2.5MS/s for, at least, 5 seconds. What's the best way of reading this binary file, knowing that:
    -I'll need it also on graphics (only after acquiring)
    -I also need to see these values and use them later in Matlab.
    I've tried the "Array to Spreadsheet String", but LabView goes out of memory (even if I don't use all of the 8 channels, but only 1).
    LabView 8.6
    Solved!
    Go to Solution.
    Attachments:
    AcquireWrite02.vi ‏15 KB
    myvi.jpg ‏55 KB

    But my real problem, at least now, is how can I divide the information to get not only one graphic but eight?
    I can read the file, but I get this (with only two channels):
    So what I tried was, using a for loop, saving 250 elements in different arrays and then writing it to the .txt file. But it doesn't come right... I used 250 because that's what I got from the graphic: at each 250 points it plots the other channel.
    Am I missing something here? How should I treat the information coming from the binary file, if not the way I'm doing?
    (attached are the .vi files I'm using to save in the .txt format)
    (EDITED. I just saw that I was dividing my graph's data in 4 just before plotting it... so It isn't 250 but 1000 elements for each channel... Still, the problem has not been solved)
    Message Edited by Danigno on 11-17-2008 08:47 AM
    Attachments:
    mygraph.jpg ‏280 KB
    Read Binary File and Save as txt - 2 channels - with SetFilePosition.vi ‏14 KB
    Read Binary File and Save as txt - with SetFilePosition_b_save2files_with_array.vi ‏14 KB

  • Form fields in LiveCycle. I want to allow users to add URLs to a form so that they can be clicked and opened on the web by form reviewers (users). what is the best way to achieve this?

    Form fields in LiveCycle. I want to allow users to add URLs to a form so that they can be clicked and opened on the web by form reviewers (users). what is the best way to achieve this?

    Once the user has entered the URL they want to add to the form. You can use the loadXML function to implement some special text in a label...
    var linkValue = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><exData contentType=\"text/html\" xmlns=\"http://www.xfa.org/schema/xfa-template/2.8/\"><body xmlns=\"http://www.w3.org/1999/xhtml\" xmlns:xfa=\"http://www.xfa.org/schema/xfa-data/1.0/\" xfa:APIVersion=\"Acroform:2.7.0.0\" xfa:spec=\"2.1\"><p style=\"font-weight:bold;text-decoration:none;letter-spacing:0in\">The new link the user have entered is:<a href=\"" + textfield.rawValue + "\">textfield.rawValue</a></p></body></exData>";
      this.resolveNode("lblURL").value.exData.loadXML(linkValue, 1, 1);

  • I have two videos and I would like to use parts of both videos with one audio track what is the best way to edit this?, I have two videos and I would like to use parts of both videos with one audio track what is the best way to edit this?

    In Final Cut Express I have two videos I'd like to merge parts of each video into a final film.  What is the best way to do this in FCE?

    Hi
    I use a slightly different way than Alchroma.
    Same
    • One video on track 1 and the other on Video.track 2
    • Resize to 25% and move one to the left and the other to the right
    Diff
    • I don't use the blade tool
    • I use the Pen tool and change the transparency - then I get fast or slow transitions in same stroke and easy to fine-tune later if needed. (But this can be done with the Roll-tool if Blade is used - so it might be as easy)
    Final
    • Resize to 100% and Center
    Video is done
    Audio - very close to this by changing the level so that best audio will dominate
    • Pen tool here too
    But that's me - the Alchroma way is as good as this or may be better for some
    Yours Bengt W

  • Contacts Sync - I have my contacts on iphone5 and MacBook Pro 2012.  I just purchased a MacBook Air 2013 and want the same contacts on that device.  What is the best way to do this?  Non-techie.  Thanks

    I have my contacts on iphone5 and MacBook Pro 2012.  I just purchased a MacBook Air 2013 and want the same contacts on that device.  What is the best way to do this?  Non-techie.  Thanks

    Follow the instructions for enabling your iCloud account on the MBAir here >  Apple - iCloud - Learn how to set up iCloud on all your devices.

  • What is the best way to approach this?

    "php 5.3.x + oracle 11g R2 XE 11.2.x.x"
    Hello everyone,
    I'm quite new to oracle (2-4 months) and php(2 weeks).
    I have one query with results that needs to be reused in several parts of my website. I can't seem to find the equivalent of the mysql_data_seek in Oracle. I wanted to reset the cursor/pointer of oci_fetch($result) so that I can scroll the result again.
    So far this are what I have come up:
    A. On first fetch put the the results in a php array and call the array later on.
    B. Do the query again.
    C. Keep on looking for a mysql_data_seek equivalent and fail.
    I'm leaning towards option 'A' but I just wanted to consult the experts.
    Thank you!

    Moved to: What is the best way to approach this? (oci_fetch problem)
    Edited by: m.davide on Oct 23, 2012 2:21 AM
    Edited by: m.davide on Oct 23, 2012 2:22 AM

  • When I upgrade from OS10.5.8 to Snow Leopard will all my data transfer.  If I need to back up what is the best way to do this?

    I plan to upgrade from OS10.5.8 to Snow Leopard. Will all my data, applications and settings transfer automatically?
    If I need to back up what is the best way to do this?

    If everything works perfectly, your data should not be touched.
    Personally I never trust my data to everything working perfectly.
    I always backup everything twice at least.

  • I would like to put the results of a proc on a local database into a table in my azure db. What is the best way to do this?

    I would like to put the results of a proc on a local database into a table in my azure db.  What is the best way to do this?  I dont see the ability to link.  The local db is on my desktop and is mssql12.
    McC

    I am not sure if i set up the linked server correctly here is the schema and an attempt to run a select and the resulting error:
    SELECT  *
    FROM  [CN5E6E9LM2.DATABASE.WINDOWS.NET,1433].[Mkerr_db].dbo.addr
    OLE DB provider "SQLNCLI11" for linked server "CN5E6E9LM2.DATABASE.WINDOWS.NET,1433" returned message "Unspecified error".
    Msg 40515, Level 16, State 2, Line 1
    Reference to database and/or server name in 'Mkerr_db.sys.sp_tables_info_90_rowset_64' is not supported in this version of SQL Server.
    McC

  • Videos emailed from my iPhone4 won't open or play on the recipients' computer.  Is this a quicktime/windows media player issue?   What is the best way to solve this ?  THANKS!

    Videos emailed from my iPhone4 won't open or play on the recipients' computer.  Is this a quicktime/windows media player issue?   What is the best way to solve this ?  THANKS!

    Is the recipient using QuickTime on their PC to view the video?
    What is the error message provided when trying to open/view the video?

  • I have Acrobat 9 on a PC I no longer use. I want to download and re-install on a different PC. What is the best way to do this?

    I have Acrobat 9 on a PC I no longer use. I want to download and re-install on a different PC. What is the best way to do this?

    Hi Chaos2015,
    Could you please specify whether you have Acrobat 9 Pro or Standard version.
    You need to deactivate Acrobat from the old machine and then install on the new one from a CD/DVD and then activate with the same serial key.
    If you do not have installation media, then you can download the Pro version from the below mentioned link:
    Download Acrobat products | 9, 8
    Please note that you can activate the software on maximum two computers. For example: Your desktop at work and laptop at home
    Regards,
    Anubha

  • I would like to display what's on my Mac Pro monitor on my iPad with as little latency as possible. What's the best way to do this?

    I would like to display what's on my Mac Pro monitor on my iPad with as little latency as possible. What's the best way to do this?

    Your image history (if I understand you properly) is stored in your catalog file, and nowhere else, and so it is only on a single drive.
    Do you mean you have edited photos on multiple drives? This isn't a problem for Lightroom at all, the software doesn't care, and you can leave things just the way they are. But if it bothers you for some reason, you can move the photos to a single drive if you want. In Lightroom select the desired photos or folders (it's easier to do this using Folders) and drag them to the desired drive.
    Alternative if you will be moving lots of folders: Adobe Lightroom - Find moved or missing files and folders

Maybe you are looking for