SQL Format Question (sorry about the previous post)

I'm trying to create a query that will produce the following output:
DNAME ENAME
ACCOUNTING CLARK, KING, MILLER
RESEARCH SMITH, ADAMS, FORD, SCOTT, JONES
SALES ALLEN, BLAKE, MARTIN, JAMES, TURNER, WARD
As opposed to this basic query:
SQL> get test.sql
1 break on dname
2 select dname, ename
3 from dept, emp
4 where emp.deptno=dept.deptno
5* order by dname
SQL> start test.sql
DNAME ENAME
ACCOUNTING CLARK
KING
MILLER
RESEARCH SMITH
ADAMS
FORD
SCOTT
JONES
SALES ALLEN
BLAKE
MARTIN
JAMES
TURNER
WARD
Any suggestions on how to accomplish this?
Thanks in advance!

-- Here is one way to do it in Oracle 8i:
-- First, run the script below to create
-- a concatenation funciton:
CREATE OR REPLACE FUNCTION concatenate
  (p_col1  IN VARCHAR2,
   p_table IN VARCHAR2,
   p_col2  IN VARCHAR2 DEFAULT '1',
   p_value IN VARCHAR2 DEFAULT 1,
   p_delim IN VARCHAR2 DEFAULT ', ')
  RETURN VARCHAR2
IS
  TYPE cursor_type IS REF CURSOR;
  c1          cursor_type;
  v_sql       VARCHAR2 (4000) := NULL;
  v_temp      VARCHAR2 (1000) := NULL;
  v_concat    VARCHAR2 (1000) := NULL;
  v_delim     VARCHAR2 (3)    := NULL;
BEGIN
  v_sql :=
     ' SELECT '   || p_col1
  || ' FROM '     || p_table
  || ' WHERE '    || p_col2  || ' = '''
                  || p_value || ''''
  || ' ORDER BY ' || p_col1;
  OPEN c1 FOR v_sql;
  LOOP
    FETCH c1 INTO v_temp;
    EXIT WHEN c1%NOTFOUND;
    v_concat := v_concat
             || v_delim
             || v_temp;
    v_delim := p_delim;
  END LOOP;
  CLOSE c1;
  RETURN v_concat;
END concatenate;
--Then to use the function in a query:
COLUMN   enames FORMAT A50 word_wrapped
SELECT   DISTINCT dname,
         concatenate ('ename', 'emp',
                      'emp.deptno', emp.deptno) enames
FROM     dept, emp
WHERE    emp.deptno = dept.deptno
ORDER BY dname, enames
-- results:
DNAME          ENAMES
ACCOUNTING     CLARK, KING, MILLER
RESEARCH       ADAMS, FORD, JONES, SCOTT, SMITH
SALES          ALLEN, BLAKE, JAMES, MARTIN, TURNER, WARD

Similar Messages

  • Sorry about the x-post: USB connector lo

    The USB connector on my jukebox has popped off the player's mainboard. The result, when I plug the cable into it the there is no connection so I cannot detect the device on the computer.
    If anyone has any insight as to where I might get this little dilemma solved, let me know. I don't know if there is any way to just reconnect the USB connector to the mainboard, or if a new mainboard is an option, somehow.
    The player works fine otherwise, I just cannot add, change access the contents of the dri've from the computer. I do have an IDE to USB connector device, if there any way to utilize that to access the files to back them up.
    Thanks
    Scott

    Chances are it's broken away from the PCB, so it requires resoldering. You can either get it repaired by Creative, which you should definitely do if it's under warranty. If it's not under warranty you can still get it done as a paid repair by Creative, or you will need to find someone expert in surface mount soldering.

  • Sorry about the repeat post,,that wasnt me,,it froze and i just hit refresh

    Ok so I know that I need to upgrade from 1GB of RAM to 2. But it used to run just fine with one.MY main thing I do is Run traktor DJ studio with it. I used to be able to run Traktor and surf the web at the same time. I went to activity monitor and looked and it said this
    page ins-676.70 mb
    page outs 706.54 mb
    swap used: 427.25mb
    Im aware that anything over 100 page outs is really bad ( I think )
    I even downloaded Onyx and did some cleaning & maintence. Traktor is still crashing on me . Heres the error report I got .Ok so I cant see where you attach files at,and I would copy and paste that into this mesage but its like 4 or 5 pages long. Should I do that,PLEASE HELP
    Message was edited by: ermac4482
    Message was edited by: ermac4482

    First off, don't hit refresh.
    If it freezes, it might mean there is a RAM problem. It might mean there is insufficient disc space on your system.
    It might mean the software you are using hasn't been tested with your operating system.
    Onyx actually is counterproductive, as it wipes the very cache files that can help speed the machine. No need to copy/paste at this point. Are you getting a four language screen that tells you to restart?

  • Pretty basic this, but I'm a total beginner.  Can anyone tell me (in simple steps!) how I burn a movie I bought in iMovies onto a DVD?  After I stick the DVD in, what happens then?  Sorry about the unsophisticated question.  Thanks.

    Pretty basic this, but I'm a beginner.  Can anyone tell me (in simple steps!) how I burn a movie I bought in imovies onto a DVD?  After I stick the DVD in, what happens then?  Do I have to be in my itunes library first?  Sorry about the unsophisticated question.  Thanks!

    Hello Jackie! (My brother lives in Brussels!)
    You may find these helpful:
    iMovie tutorials:
    http://www.apple.com/ilife/tutorials/#imovie
    and also this:
    http://www.kenstone.net/fcp_homepage/imovie_09_stone.html
    A good guide to iDVD 7 can be found here:
    http://www.kenstone.net/fcp_homepage/idvd_07_stone.html
    Apple's tutorial on iDVD 07/08 is here:
    http://manuals.info.apple.com/en/idvd_08_getting_started.pdf

  • My question is about the 'Restore Backup' option on iTunes (Not 'Restore iPhone'). So, if I click on Back Up Now, then 'Restore Backup', would that go through the process of erasing everything on my phone as new then restore whatever iTunes has backed up?

    My question is about the 'Restore Backup' option on iTunes (Not 'Restore iPhone'). So, if I click on Back Up Now, then 'Restore Backup', would that go through the process of erasing everything on my phone as new then restore whatever iTunes has backed up?
    I do not want this to happen, as with previous experience iTunes doesn't restore a mirror of what the iPhone was when it was backed up as is the case with iCloud backups.
    What I am trying to do is, as I've found a method on Youtube, there is an application where I can delete all the multimedia saved in my 'iMessages' so clear up some space. As doing that manually through the phone would take a lifetime. The method is to backup on iTunes, then using the backup created, importing that into the application then deleting the messages through that then restoring the phone using that amended backup.
    So back to my question, would restoring through 'Restore Backup' just restore the backup internally or would it flush the entire phone and then restore the backup? And if it does so, what would be lost in the restore?
    Thank you all,
    Fahmid

    iCloud should overwrite your phone with the data stored in your account, preserving your newer data.  However, to be sure I would go to Settings>iCloud and turn data syncing to Off before restoring the backup.  Then, after restoring the backup, turn the data syncing back to on, and when prompted about Merging with iCloud, choose Don't Merge.  This will ensure that the data in your iCloud account overwrites the data on your phone (which is your goal).
    Also, you don't sync text messages with iCloud so you will end up losing your more recent messages when they are overwritten by the backup.

  • Re-open the Previous posting period

    hi...
    we have closed the posting period for the month of 01-02(april-may) and open the 03-04(june-july)...
    but now we want to open the previous posting period i.e. 01-02(april-may) again...so how could we do this..
    one solution i have got is that...
    1. go to OX18 delete all the assignment for that company code and plant.
    2. go to OMSY and change the posting period..
    3.  go to OX18 and reassign the plant and company code again...
    this is the right method to do that..?
    will there be any -ive implications if I open the previous period by this procedure..?
    or suggest me some other way to do that...
    Thanks in advance

    Hi
    You can open Closed MM periods but be careful because SAP does recommend opening closed MM periods.
    Steps are :
    1) Tcode MMPI --from Tool Bar select - System - User Profile - Own Data - In parameter Tab Enter "MMPI_READ_NOTE" in parameter Field.
    Try to remove assignment of plants from company code.
    Now Go to -
    T-Code OMSY & Set the required Period.
    Re-assign Plants to Company Code & Check whether correct preriod is open thru T-Code - MMRV
    Now use T-code - OMWD to Assign Valuation grouping code to Valuation area because the earlier data gets deleted when assignment of Plants was removed.
    Use the transaction code OMS2 then select FERT (or any other Material Type used by your company)
    Then click on the quantity and value update.
    Select your plant or valuation area and put Tick Marks in Value update and Quantity update
    Even check this link...Reopening the posting period that was closed
    This will definitely reslove your problem.
    Thanking you.

  • Change in Useful life of asset in mid year, but the previous posted depreciation should not be changed

    Dear Experts,
    I have a requirement in one of my client, We need to extend the useful life of asset in mid of an asset fiscal year and the depreciation which was posted in the previous should not be changed.
    Requirement:
    Useful life of asset  is to be extended after completing depreciation for 4 years and in-between the current asset fiscal year. Provided the present asset value has to be taken as the new book value of the asset and the depreciation posted henceforth to be posted based on the new asset value till the remaining useful life.
    Previously posted depreciation should be unchanged.
    Analysis:
    1.      The fiscal Year followed - October to September.
    2.      The useful life of asset will be changed, and the depreciated value posted till 31/mar 2014 will have the old depreciation value ( based on the original acquisition value)
    3.      The Depreciation key used in of type LINR (linear), depreciation value will be calculated based on the Book value till the asset value becomes ZERO at the end of useful life of the asset.
    4.      We can change the useful life of the asset at the end of a Asset fiscal year say FY- 2014, if this is done the existing configuration will take the Book value of the asset at the end of the Fiscal as the asset value and the new depreciation will be calculated based on the new useful life of the asset. The asset value will become ZERO at the end of the newly changed Useful Life.
    5.      But the requirement is that the useful life of the asset will be changed exactly half way in between existing Asset fiscal (i.e., 31/03/2014), if this is done system will change the depreciation value based on the new useful life ( since the Dep Key is LINR), but the depreciation value will change from the fiscal start say October 2013 to September 2014 ), which will not satisfy the requirement of the client. Since the depreciation which is already posted from October 2013 to March 2014 should not be changed.
    Note:
    1. We are not willing to retire the asset and create a new asset with the remaining book value as asset value and start depreciation.
    Kindly let me know if the requirement can be fulfilled without retiring the asset.

    Dear All,
    This requirement has been completed.
    1. I created New Multi level valuation method with base 26 ( Net book value w/o Revaluation ).
    2. New depreciation key was created and the above method was assigned to it. I never changed the Base method.
    3. new interval was created in the depreciation area, with this created dep key and extended the useful life of the asset. The depreciation was calculated according to the requirement.
    Originally the asset had useful life of  5 Years, I changed the asset useful life to 8 years now with new Depreciation key 2001.
    Depreciation was already posted to the asset till 04- 2013 for an amount of 148.27 SAR.
    Net Book value carried forward to 2013 = 1575.56 SAR
    Depreciation already posted till 4th period =   148.27 SAR
    Current Net book value after useful life extension           = 1427.29 SAR .
    Now the new depreciation key 2001 with Multilevel method 201, will take this Net-book value as Asset value and will depreciate along the useful life of the asset till it becomes zero.
    Planned depreciation of 2013 ( remaining 6 months) = 166.24 SAR
    Planned depreciation of 2014 = 225.96 SAR
    Planned depreciation of 2015 = 225.96 SAR
    Planned depreciation of 2016 = 225.96 SAR
    Planned depreciation of 2017 = 225.96 SAR
    Planned depreciation of 2018 = 225.96 SAR
    Planned depreciation of 2019 = 131.25 SAR
    Total      = 1427.29 SAR ( the Asset value becomes zero at the end of its remaining useful life.
    The previously posted depreciation from 01.01.2013 to 30.04.2013 was untouched.

  • Sorry for the multiple posts.

    I cant delete them as there seems to be no option.
    I was pressing the post and it was giving me error but it seems like it was actually working ok, hence the multiple posts.

    rhuhman wrote:
    >
    > Sorry for the multiple posts... I am trying to find the Auto-Reboot
    > default options. I would like to change the defaults to a set
    > parameter. I am looking at adding a signature to the pop-up message
    > and extending the sleep time from 2 hours to 10 hours. I thought it
    > was attached to the baseline setting but that didn't change anything.
    >
    > Can this be changed?
    >
    > Richard
    Hi
    I've been looking for this myself but can't seem to find what you are
    looking for - which is kind of a problem since it would make it a lot
    easier to deploy patches if you did not need to go in and set these
    options on every deployment.
    Niels
    A true red devil...

  • I'm loathed to ask the same question again about the ITunes library not syncing with my iPod but having just done a complete restore, ensuring the tracks are in AAC format.. There are still problems.. Apple are there with the tutorials..but no solvings!!!

    I'm using iPod 4th Gen iOS 6.1.3 and an iMac with 11.3 .. All latest versions. I have 23.4gb music according to the file but when I attached the iPod the bar at the foot of the page says 18.3gb. Some tracks are missing. Most if not all have been ripped from cd's into iTunes which is creating AAC format for each track. Other tracks play fine, some show the song but not the Artist and vice versa.
    I have tried dragging the tracks from the Mac library to the IPod music file..nothing. So I go to Safari, type the question in and read the same problems over.. Are Apple aware of their Tutorials without troubleshooting pages ?    Do they care? 
    My Pioneer DDJ/T1 is set up with Traktor and only wants to work with iTunes..  So iTunes are edging themselves in everywhere for everything... But it's still not working as it should..
    Anyone have any clues please... Tried most all the ideas so far...

    1) This is because of software version 1.1. See this
    thread for some options as to how to go back to 1.0,
    which will correct the problem...
    http://discussions.apple.com/thread.jspa?threadID=3754
    59&tstart=0
    2) This tends to happen after videos. Give the iPod a
    minute or two to readjust. It should now be more
    accurate.
    3) This?
    iPod shows a folder icon with exclamation
    point
    4) Restore the iPod
    5) Try these...
    iPod Only Shows An Apple Logo and Will Not Start
    Up
    iPod Only Shows An Apple Logo
    I think 3,4, and 5 are related. Try the options I
    posted for each one.
    btabz
    I just noticed that one of the restore methods you posted was to put it into Disk Mode First rather than just use the resstore straight off, I Have tried that and seems to have solved the problem, If it has thank you. previously I have only tried just restoring it skipping this extra step. Hope my iPod stays healthy, if it doesnt its a warrenty job me thinks any way thanks again

  • OA Framework - What is that? (sorry about the dummy question)

    Hi people,
    I was looking for some information about OA Framework and i saw that it is a "tool" to help me to customize oracle applications, right? But i can do it with oracle forms and customize or create another screens. So what is the difference or why is better to use this "OA Framework"?
    Best regards

    In summary, OA Framework is the new technology to implement Self-service pages. It WILL NOT replace forms and especially reports OVER-NIGHT but it is Oracle long-term plan for all eBusiness forms/pages. IMO, no new forms will be created in Oracle Forms but they will not be redeveloped in OA Framework unless they really have to. IMO, OA Framework will really need some massive enhancements to replace the functionality provided by the major forms and "work benches" in eBusiness Suite like the HRMS person form.

  • Question # 3 about the HDMI-DVI cable

    OK...My older DVD player is working just fine with the component video cable.
    Now let's suppose that DVD player eventually stops working and I replace it with a new one.
    On the newer DVD players, does the HDMI-DVI cable take the place of the component video cable or do both cables need to be used?  Can the newer DVD players function with just the HDMI-DVI cable alone?

    I actually just answered my own question right before I saw your reply.  But thank you for confirming what I thought.  That makes a lot of sense.  I already have my existing DVD player set up with the component video cable and you are correct about needing an audio cable.  I learned that through a process of elimination when I was setting that up and I have plenty of extra audio cables in my closet, so we're definitely on the same wavelength.  My existing DVD player doesn't have the HDMI capability but the component video cable is fine.  Now I just have a better understanding of how this works.   I believe that my existing DVD player is analog but it's very good and I will glady keep it until it goes.
    I was also just fooling with my TV settings.  On my "source" list, I had had TV selected as source but I switched it to HDMI, which is what I already connected to my HDTV --- what a difference in sound and picture quality.

  • Installing ANT 1.5.3 --Better than the previous post

    Hello all,
    I am a RIT student on my first internship an I'm in over my head. (At least that the way I'm told all first internships feel) Anyway, I am trying to install Apache's POI jar files into my JVM, so that I can easily read and write Excel files. The POI installation says that I need to install two components; ANT as well as FORREST. Below I have pasted some lines from the ANT 1.5.3 installation documentation, of which I have tagged with a few questions. The bold type followed by a Q# shows where I am getting caught up.
    <Install Document>
    Installing Ant
    The binary distribution of Ant consists of the following directory layout:
    ant
    +--- bin  // contains launcher scripts
    |
    +--- lib  // contains Ant jars plus necessary dependencies
    |
    +--- docs // contains documentation
    | +--- ant2    // a brief description of ant2 requirements
    | |
    | +--- images  // various logos for html documentation
    | |
    | +--- manual  // Ant documentation (a must read ;-)
    |
    +--- etc // contains xsl goodies to:
    // - create an enhanced report from xml output of various tasks.
    // - migrate your build files and get rid of 'deprecated' warning
    // - ... and more ;-)
    Only the bin and lib directories are required to run Ant. To install Ant, choose a directory and copy the distribution file there. [Q1] This directory will be known as ANT_HOME.
    Windows 95, Windows 98 & Windows ME Note:
    On these systems, the script used to launch Ant will have problems if ANT_HOME is a long filename (i.e. a filename which is not of the format known as "8.3"). This is due to limitations in the OS's handling of the "for" batch-file statement. It is recommended, therefore, that Ant be installed in a short, 8.3 path, such as C:\Ant.
    On these systems you will also need to configure more environment space to cater for the environment variables used in the Ant lauch script. To do this, you will need to add or update the following line in the config.sys file
    shell=c:\command.com c:\ /p /e:32768 I can do this one ;-)
    Setup
    Before you can run ant there is some additional set up you will need to do:
    Add the bin directory to your path. [Q2]
    Set the ANT_HOME environment variable[Q3] to the directory where you installed Ant. On some operating systems the ant wrapper scripts can guess ANT_HOME (Unix dialects and Windows NT/2000) - but it is better to not rely on this behavior.
    Optionally, set the JAVA_HOME environment variable (see the Advanced section below). This should be set to the directory where your JDK is installed.
    Note: Do not install Ant's ant.jar file into the lib/ext directory of the JDK/JRE. Ant is an application, whilst the extension directory is intended for JDK extensions. In particular there are security restrictions on the classes which may be loaded by an extension.
    </Install Document>
    Questions
    Q1: What is this distrobution File? -- If the directory contents are needed to answer this one, then just perhaps a brief description of what to look for (file extentions or name or somthing) would suffice.
    Q2: Add the bin directory to your path. Ok so how would I do this?
    Q3: Set the ANT_HOME environment variable... How can I do this?

    1) What you downloaded should be a packed file (zip, tar.gz, etc) that needs to be unpacked into the directory of your choice.
    2) & 3) are answered by Ant's installation documentation (the page you're quoting from):
    http://ant.apache.org/manual/index.html

  • Sorry for the multiple post.

    Sorry, I had a wrong feedback of my machine and posted too many times. Go for the
    top one that is furthermore completed.

    1) This trigger prevents people from changing their password. It also prevents people from creating users, dropping users, or modify attributes of users. That seems unlikely to be what you really want-- why would you want to force a DBA to be involved for a random user to change his database password?
    2) Assuming that you are OK with the restrictions in #1, you just need to check the USER function in your IF statement, i.e.
    IF( ora_dict_obj_type = 'USER' and USER = 'SYSADM' )
    THEN
      <<raise error>>
    END IF;Justin

  • Sorry for the second post

    Hi,
    sorry again i posted here
    Edited by: user3266490 on Feb 25, 2010 1:14 PM

    Been a few days!
    Sorry my post wasn't very clear when I said an audio patch under the set I meant that I created the patch as a child of the set, but it still didn't work. However after a bit of playing I have discovered that it all works if I load a software instrument strip in each patch even if that instrument has nothing assigned to its input. Without it my keyboard doesn't seem to trigger the software synths set at set level. I also had the problem that sustain pedal wouldn't work at patch level, but after view the board I found a solution to that.
    So all in all after a bit of teething troubles it now does what I need to do. Thanks very much for your reply and idea, they have made mainstage possible for me to use live!!!!
    PS Does it not seem madness that apple haven't implemented a way of making an instrument available to multiple patches without having to load it into memory several times. My IMac has 4gb of ram and even using some disk streaming synths I still fill that 4gb. To have a simple way of ghosting an instruments a channel (i.e. to give control at a patch level of a set / concert level instrument would seem to be a simple task)
    Once again thanks very much!!!

  • Simple SQL format question

    select add_months(sysdate,-1)
    from dual
    How do I format the output to display YYYYMM
    Thanks
    Brendon

    this?
    select to_char(add_months(sysdate,-1),'YYYYMM')
    from dual;

Maybe you are looking for

  • K330 Video card upgrade question.

    New to forum and was just about to pull the trigger on a new K330-77471CU (from BB). However, I read a customers comment saying that this unit only had an AGP port, no PCI express slots for upgrading the video card, can this be true??? Does'nt seem p

  • Windows 8.1 not able to reconnect after user accepts Gateway logon message

    I spent all morning troubleshooting a connection problem with a client. It turned out that the TS Gateway message prompted to users on first login was the culprit or rather the option to NOT display the message again. When "Do not ask again..." is se

  • VARCHAR problem with ORAData

    Hello, I am trying to implement Object functionilities of Oracle. My ORAData implementation is now working correctly, well at least working correctly for integer values. For VARCHAR fields I am getting garbage. The query that I am using for ORAData i

  • Add a new tab in IW31/IW32

    Hi, I have a requirement where in I need to add a new tab in IW331, IW32. Also, how do I add fields on to that tab? I know there is one enhancement IWO10018, but I have never worked on enhancement before. So can someone please tell me how to use this

  • TM with MyBook World Edition II

    I know that TM is only designed to work with Time Capsule or the AEBS, and trying to force it to work with any other NAS is difficult. But, I think I'd rather take the chance on a My Book World Edition II and get 4x the storage for the same price. Be