Ideas on how to best flatten a structure

Hello,
I need to take the data in a table and flatten it. e.g.
The data is stored like this:
Id Description
1 Cat
2 Dog
3 Bird
4 Tree
I have to make a table with the "Description" elements as columns. i.e. the final table would have the following columns:
Cat Dog Bird Tree ...
The number of columns is not fixed, it will be based on how many rows are in the original table.
I can think of a few pretty rough ways of doing it. i.e. Using Unix Shell/SQL to generate a create table script i.e.
CREATE TABLE descriptions
( cat VARCHAR2(100),
bird VARCHAR2(100)
etc);
Is there any way I can do this in straight PLSQL? can I write dynamic DDL (I assume I can?). Or is there an even more powerful/elegant way of flattening a table in the manner in Oracle 9i??
Thanks,
Dan.
[email protected]

Tom Kytes has some examples of pivot queries to do this sort of thing, but I don't believe he's extended them to handle an arbitrary number of columns. You should be able to turn Tom's statis SQL queries into dynamic SQL queries, though, which would get you to your arbitrary columns requirement.
Justin
Distributed Database Consulting, Inc.
http://www.ddbcinc.com/askDDBC

Similar Messages

  • Best practices in structuring a large Flash project?

    I'm building an educational site in Flash. A student works through a series of activities, either watching an animated video or answering a question. You can get a good idea of the basic functionality with this mockup: http://imgur.com/Mi4JyHN.
    After a student logs in, the server responds with their current activity and progress. The activity displays, and all student interaction is sent to the server to record (time spent on questions, buttons clicked, correct and incorrect answers, etc). When the student is done with an activity, the server is notified and responds with the next activity to present.
    I'm fairly new to flash and would love to hear how people with experience would structure this project. I can think of the following possibilities.
    One enormous SWF. All audio files and movie clips are embedded in the SWF and swapped out as necessary. This is not a reasonable option because the size of the resulting SWF would be huge.
    Exactly one SWF for each activity. The control buttons and progress bars are obviously shared between each activity, and it seems like a lot of duplication to have them in each compiled SWF. Also, if a button is changed, this requires re-compiling everything, right?
    One main SWF that loads others. The main SWF contains the buttons and progress bars and fetches external SWFs from the server to replace the stage area. I don’t know enough Flash to predict how this will go.
    Part JavaScript, part Flash. The buttons and progress bars are done in HTML + JavaScript. The page fetches external SWFs from the server to replace the stage area. This is the current system, and the problem is the ugliness/difficulty of managing the communication between JS and AS3.
    HTML5. While I would love for this to be a possibility, I don’t feel like it is. Animation is still way easier in Flash and we are still targeting some fairly old browsers. The best part about Flash is the consistency in experience.
    Extra questions:
    Which options leave us open to publishing to mobile using Adobe AIR?
    Which options are best for automated testing / accessibility / version control / general code layout?
    Thanks so much for any advice!

    For a Flash-based design I would go with option 3.  The general controls and objects common for use with each activity would be in the main file.  Whether or not the main file would be responsible for sending activity data to the server could depend on there being determinable similarities between data collections...  otherwise it might fall on individual activity swfs to interact with the database.  There are too many unknowns in this regard for me to offer much.
    If this was going to be a loaded application, such as an AIR app, then option 1 might be more reasonable since you only have to install once for everything to be available.
    When it comes to mobile you are likely to hit a snag if you rely on using AIR/Flash to try to deal with a main and activity swfs approach... mainly in the Apple realm...  unless I forgot a lot of what I was involved with some time ago, a loaded swf cannot contain any code when it comes to iStuff.  So you end up having to make the main file contain all of the coding to deal with each activity's processing.  Every interface/interactive element can only exist by name and the main file has to target them and assign listeners and processing and etc....a mess in my view.  That's why having the one huge AIR file is possibly a tad more reasonable.
    I have nothing to offer in the HTML5 end of things.  I have not yet journeyed down that path.  Since HTML5 is basically wingless without javascript and CSS, it might come to pass that the current system (option 4) is the way to go.

  • When I switch my time capsule to 5.0ghz mode the range of my wireless network drops significantly.  Near the Time Capsule my Macbook Pro works fine, in my bedroom I have almost no signal.  In mixed mode it works fine.  Any ideas on how to get 5.0 working?

    When I switch my time capsule to 5.0ghz mode the range of my wireless network drops significantly.  Near the Time Capsule my Macbook Pro works fine, in my bedroom I have almost no signal.  In mixed mode it works fine both placed.  Any ideas on how to get 5.0 working?  I thought 5.0Ghz was supposed to have a wider range.  Do I need to change a setting on the Macbook Pro?
    Thanks, W

    I'm not sure if you understand that 5 GHz has some upsides, but also some very significant downsides.
    The upside is that the 5 GHz signal will allow faster speeds.
    The downside is that you must always give up something in order to gain something else.Unfortunately, the marketing hype about 5 GHz does not go into very many details about this.
    In the case of 5 GHz, the 5 GHz signals are much weaker than 2.4 GHz signals, so they do not travel as far or penetrate any obstructions like walls or ceilings nearly as well as 2.4 GHz signals. In many cases, in order to get good 5 Ghz performance, you literally have to have almost a line-of-sight relationship between your computer and the wireless router.
    If you have a new dual band router, which broadcasts both a 2.4 GHz and 5 GHz signal simutaneously, your Mac will connect to the best signal quality automatically depending on its location in relation to the router. In the same room, without any obstructions, it will connec to 5 GHz. But, take the laptop down the hall a few rooms and around the corner and the Mac will connect to the 2.4 GHz signal because at that location, the 2.4 GHz signal is not only stronger, it is also faster.

  • I have a new Mac Mini and I found AdWare called TakeOverSearchAssetsMac and SearchProjects on it. I have been unable to remove it. Does anyone have any ideas on how to remedy this?

    I have a new Mac Mini and I found AdWare called TakeOverSearchAssetsMac and SearchProjects on it. I have been unable to remove it. Does anyone have any ideas on how to remedy this?

    Please review the options below to determine which method is best to remove the Adware installed on your computer.
    The Easy, safe, effective method:
    http://www.adwaremedic.com/index.php
    If you are comfortable doing manual file removals use the somewhat more difficult method:
    http://support.apple.com/en-us/HT203987
    Also read the articles below to be more prepared for the next time there is an issue on your computer.
    https://discussions.apple.com/docs/DOC-7471
    https://discussions.apple.com/docs/DOC-8071

  • Any ideas on how to do a local mirror for this situation?

    I'm starting a project to allow ArchLinux to be used on a Cluster environment (autoinstallation of nodes and such). I'm going to implement this where I'm working right now (~25 node cluster). Currently they're using RocksClusters.
    The problem is that the connection to internet from work is generally really bad during the day. There's a HTTP proxy in the middle. The other day I tried installing archlinux using the FTP image and I took more than 5 hours just to do an upgrade + installing subversion and other packages, right after an FTP installation (which wasn't fast either).
    The idea is that the frontend (the main node of the cluster) would hold a local mirror of packages so that when nodes install use that mirror (the frontend would use this also, because of the bad speed).
    As I think it should be better to only update the mirror and perform an upgrade not very often (if something breaks I would leave users stranded until I fix it), I thought I should download a snapshot of extra/ and current/ only once. But the best speed I get from rsync (even at night, where an HTTP transfer from kernel.org goes at 200KB/s) is ~13KB/s this would take days (and when it's done I would have to resync because of any newer package that could have been released in the meantime).
    I could download extra/ and current/ at home (I have 250KB/s downstream but I get like ~100KB/s from rsync), record several CDs (6!... ~(3GB + 700MB)/700MB) but that's not very nice. I think that maybe this would be just for the first time. Afterwards an rsync would take a lot less, but I don't know how much less.
    Obiously I could speed things a little If I download the full ISO and rsync current using that as a base. But for extra/ I don't have a ISOs.
    I think this is a little impractical (to download everything) as I wouldn't need whole extra/ anyways. But it's hard to know all packages needed and their dependencies to download only those.
    So... I would like to know if anyone has any ideas on how to make this practical. I wouldn't wan't my whole project to crumble because of this detail.
    It's annoying because using pacman at home, always works at max speed.
    BTW, I've read that HOWTO that explains how to mount pacman's cache on the nodes to have a shared cache. But I'm not very sure if that's a good option. Anyway, that would imply to download everything at work, which would take years.

    V01D wrote:After installation the packages that are in cache are the ones from current. All the stuff from extra/ won't be there until I install something from there.
    Anyway, if I installl from a full CD I get old packages which I have to pacman -Syu after installation (that takes long time).
    Oh, so that's how is it.
    V01D wrote:
    I think I'm going to try out this:
    * rsync at home (already got current last night)
    * burn a DVD
    * go to work and then update the packages on DVD using rsync again (this should be fast, if I don't wait long time after recording it)
    And to optimize further rsync's:
    * Do a first install on all nodes an try it out for a few days (so I install all packages needed)
    * Construct a list of packages used by all nodes and frontend
    * Remove them from my mirror
    * Do further rsync updates only updating the files I already have
    This would be the manual approach of the shared cache idea I think.
    Hmm... but why do you want to use rsync? You'll need to download the whole repo, which is quite large (current + extra + testing + community > 5.1GB, extra is the largest). I suggest you to download only those packages and their dependencies that you use.
    I have similar situation. At work I have unlimited traffic (48kbps at day and 128kbps at night), at home - fast connection (up to 256kbps) but I pay for every megabyte (a little, but after 100-500 megabytes it becomes very noticeable). So I do
    yes | pacman -Syuw
    or
    yes | pacman -Syw pkg1 pkg2 ... pkgN
    at work (especially when packages are big), then put new downloaded files on my flash drive, then put them into /var/cache/pacman/pkg/ at home, and then I only need to do pacman -Sy before installing which takes less than a minute.
    I have 1GB flashdrive so I can always keep the whole cache on it. Synchronizing work cache <-> flash drive <-> home cache is very easy.
    P.S.: Recently I decided to make complete mirror of all i686 packages from archlinux.org with rsync. Not for myself but for my friends that wanted to install Linux. Anyway I don't pay for every megabyte at my work. However it took almost a week to download 5.1 GB of packages.
    IMHO for most local mirror solutions using rsync is overkill. How many users are there that use more than 30% of packages from repos? So why to make full mirror with rsync when you can cache only installed packages?

  • Cant sync my iphone contacts with yahoo, it says "unknown error (4)" and tells me to come back later, been doing it for months. Any ideas on how to kill it?

    cant sync my iphone contacts with yahoo, it says "unknown error (4)" and tells me to come back later, been doing it for months. Any ideas on how to kill it?

    Hey joshuafromisr,
    If you resintall iTunes, it should fix the issue. The following document will go over how to remove iTunes fully and then reinstall. Depending on what version of Windows you're running you'll either follow the directions here:
    Removing and Reinstalling iTunes, QuickTime, and other software components for Windows XP
    http://support.apple.com/kb/HT1925
    or here:
    Removing and reinstalling iTunes, QuickTime, and other software components for Windows Vista or Windows 7
    http://support.apple.com/kb/HT1923
    Best,
    David

  • My music files etc were all located on my old laptop which was stolen. I have just plugged my iphone in to my new computer and it has deleted all my files. Has anybody got any ideas on how to retrieve the files?

    My music files etc were all located on my old laptop which was stolen. I have just plugged my iphone in to my new computer and it has deleted all my files. Has anybody got any ideas on how to retrieve the files?

    WINDOWS?
    Connect the iPod to your PC. If iTunes starts syncing (ie erasing) your music automatically, hit the X in the upper right hand corner of iTunes display, to the left of the search box, to stop it.
    In Control Panel, Portable Media Devices, double-click your iPod.
    In the Tools menu -> Options, in the View Tab, check "Show hidden files and folders."
    Navigate to the Music folder. On my 'pod, the full path is
    Portable Media Devices\NAME of IPOD (F:)\iPod_Control\Music
    Select all the music folders, and drag and drop them into a folder on your hard drive, or directly into iTunes.
    And you're done! The iPod music folder structure is strange and inexplicable, but once you move your files into iTunes you can set it to automatically organize your folder by artist and album to clean that up. (To do this, in iTunes Edit menu, choose Preferences and in the Advanced tab, check "Keep iTunes Music Folder organized."
    might be out of date worth a try

  • How to set the notifications structure form a form in IDM 8.0.0.5

    Hi,
    we are using Identity Manager 8.0.0.5 and we are trying to set the notifications structure which is evaluated in the Create User and Update User workflow from within our Tabbed User Form and from a ActivveSync Form.
    We had no success in either case so far.
    Any ideas on how to do this?
    What we want to achieve is send additional notifications if certain attribute conditions are met.
    Thans for any answer.
    Ugato

    A text frame in text is an anchored or inline item, so you either have to set the leading of the parent character or use the anchored options of the frames.
    Dave

  • How to get PNP Org Structure to reflect the org structure as of key date?

    I created a custom program using the PNP logical database.  I defined a custom report category indicating the selection period = employee selection period and allowing org.structure.  I’m also using the standard SAP PNP_DEFAULT selection view. 
    Inside my ABAP I initialize the pnpbegda and pnpbegps to reflect 20060930.  Upon Execution the key date reflects 09/30/2006.  I click on the org.structure button.  The org.structure displayed reflects the one as of today rather than as of Sept-30. 
    During run debug I see that the RP_PNP_ORGSTRUCTURE  program, LRPPNU11, calls function 'RH_TYPE_STRUC_HELP' to get the org.structure.  The call to this function passes 09/30/2006 for the begda and endda, but it still returns the latest org.structure.  I did some playing with this function and found that if I also pass the ACT_SEARCH_WEGID as ORGEH it works.
    Any idea on how I can get the LRPPNU11 program to pass the ACT_SEARCH_WEGID or the subsequent called functions to process for ORGEH?

    thanks. but maybe I don't describe my problem well.
    I use javascript to get some information such as position, sytle of each elements and then pass these to javafx. So the besides the dom tree, I can get more information about elements.
    I need to pass them back to javafx.
    if node support setUserData, I can associate them to each Node/Element. But webkit don't support this feature.
    BTW, If javascript pass a object to javafx. it can only deal with primary types such as string, numeric. But I need pass back a complicated javascript object like:
    {name:"parent", children:[{name:"child1"},{name:"child2"}]
    I can use (String)JSObject.getMember("name"); and JSObject children=JSObject.getMember("children");
    but I can't cast children to Object[] or JSObject[].
    so I have to use some tricky to convert Javascript Object to json string and then in javafx convert it back to Object tree.
    Edited by: user12956197 on 2013-3-11 上午4:27

  • Advice/Recommendation please? How to best handle big models with various schemas?

    Hi
    Using DM 3.3.0.747.
    We have several bespoke applications, each using its own data model in separate schemas.  They do share various entities/tables which are made available in a shared schema.  There are references to these shared tables, etc. (e.g. foreign keys)
    We want to embark on a process to reverse engineer and then maintain these applications' schemas in Data Modeller.
    I would really like your views on how to best approach this.  The main concern is that the bigger the design (or more models/sub-views) the slower actions like saving and loading it becomes.  Once you also have it version controlled more time is added onto saving and synchronising with the sub-version repository and between team members.
    The thinking is to primarily have each application (and hence its own schema) in separate designs (projects), but include tables from the shared/core schema as needed.  Would this be a good/recommended approach?
    How does one address potential changes made (differences introduced) that may conflict between these separate designs?
    e.g. in physical model the schema becomes a user that has permissions, etc.  and that same user may be in multiple designs.  Each design is version controlled, but in the end only exists once in the database.  If each design is synch'ed with the database, DDL generated and executed, this can cause one design to add permissions, etc. that the second DDL from the second design removes or replaces with its own?
    I hope my question/scenario is clear enough.  If not, please revert to me for more clarification.
    Thank you & Regards

    Hi Hans,
    I think it's better to use DM 4.0 and have everything in one design.
    1) You can import all schemas you need into one design (one relational model). Save that design - important to do it before using "remote objects" approach
    2) Use "Create new models based on schema names" wizard available in context menu for relational model in browser. Wizard will create new relational model for each schema in originating model and create there tables and views that
    belong to that schema. All objects in originating model become read-only "remote objects".
    If table (in new model) has a foreign key that refer table in another schema (now that table is moved to another new model) then "remote object" presentation is created for referred table.
    At the end you'll have one large model with read-only remote objects and set of relational models that keep the track of foreign keys between tables in different schemas in database.
    You can keep the originating model (the large one) in order to have global picture or delete it.
    Properties from physical model are also transferred to new models in DM 4.0.
    3) Check "Show 'Select relational models' dialog" in "Preferences>Data Modeler" - upon "open design"  that will bring up dialog allowing to select which model   to be loaded. The choice is persisted and
    applied next time you open design (no need to see that dialog again if no change in what to be loaded).
    4) For each model you can create "DDL generation" configuration (one or more) and exclude remote object from generation in DDL. Permissions should be maintained in model where table is editable and where DDL for that table will be generated.
    The thinking is to primarily have each application (and hence its own schema) in separate designs (projects), but include tables from the shared/core schema as needed.
    I won't recommend it. I know it's possible to have remote object in another design but you'll face following problems:
    1) You cannot use design level domains and definitions in data types model
    2) Remote object from another design are sensible to location of that remote design. You need to maintain the same directory structure everywhere designs (all related) are checked out and they need all to be checked out before dependent design to be open
    3) You need to add remote objects manually while wizard described above will do it for you in the scope of one design
    The main concern is that the bigger the design (or more models/sub-views) the slower actions like saving and loading it becomes.
    The number of models shouldn't be a problem with support of "Select relational models" dialog. Subviews will impact loading if only they are large and are visible when "save" is used.
    Total number of objects in model doesn't impact "save' operation - only modified objects are saved.
    Yes, there is overhead for versioned designs - one more reason to move to DM 4.0 - SVN client 1.7 is used there.
    Philip

  • How to best use IDSM in promiscuous mode?

    Hi folks
    I need some input and ideas how to best set up my IDSM2 module.
    Today I have the module set up to capture traffic from the 6513 using SPAN in both directions and two different firewalled VLANs as sources. The destination is data-port 1 on the IDSM. This setup is working fine but I'm curious as how to best use the second data-port. Our 6513 runs IOS 12.2(18)SXF3 and has a limit of only one SPAN session set up to capture an entire VLAN in both directions.
    My idea was to use the second data-port as SPAN destination for our external/non-firewalled VLAN, but this isn't allowed.
    Does anyone have or had a similar problem? Would using a VLAN access list with data-port 2 as destination be an option or are the dual IDSM interfaces mainly used for inline mode?
    Regards
    Fredrik Hofgren

    Fredrik,
    I am using VACLs in the switch that has the IDSM. This will preserve your SPAN sessions.
    You can specify which vlans go to which port on the IDSM.
    We actually have our external vlan set up as an inline vlan pair on data port 2.

  • How to create a record structure dynamically

    Hi,
    I would like to create a record structure dynamically in the body of my pl/sql procedure.
    I don't want to create the structure in the declaration because my record structure depends on some parameters that the procedure will receive.
    Thank you

    > I would like to create a record structure dynamically in the body of my pl/sql procedure
    Terrible idea. Why? Because if the structure is dynamic then you need to write pretty complex code to handle this structure that could be anything. Complex code means buggy code. Inconsistent code. Weird run-time errors. Etc.
    Yes, you can create dynamic "structures" - for example, you can create a user defined type that at execution time can decide what properties it has. Similar to a an object in an o-o language that has a RTTI (Run Time Type Information) interface.
    But this is complex. And what did I say about complex code above? Not the best of ideas most of the time.
    There is however a very easy way to deal with dynamic data via a "dynamic" structure that is in fact a statically defined structure. Arrays aka collections aka associative arrays.
    E.g.
    create or replace type TStrings as table of varchar2(4000);
    Using this I can create a SQL statement (cursor) on any table, with any predicates, and pass the results (dynamic list of columns) to a procedure for processing:
    select TStrings(object_id,object_type,object_name) as DYNAMIC_LIST from user_objects order by object_type, object_name
    Using this I can create a procedure that accepts a dynamic list of values and process these:
    create or replace procedure DynamicProcess( list TStrings ) as ...
    So when thinking "dynamic structures" - think it through carefully. There is a difference between an UNKNOWN structure and a DYNAMIC structure.
    The former needs a RTTI interface. You have no idea what the structure contains. You need an interface to call in order for it to describe the structure for you. This is complex stuff.
    The latter means that you know the structure as it is pre-defined (statically defined). At run-time, it can contain any number of elements - thus making the structure dynamic. This is easy stuff.
    I would rather go for the easy stuff than the complex stuff any time of the day - even when on my 3rd cup of coffee...

  • Any ideas on how I can reasonably priced get two decent smartphones with one upgrade?

    I have 4 phones, 700 shared minutes and unlimited text.  Already costs 160 bucks.  Would love to make 2 phones data package leave other 2 talk/text; only one upgrade available.  any ideas on how i can make this happen without having to sell my first born?

    are you asking about purchasing the 2 smartphones, or about the monthly plans? because both will be fairly expensive. the new share everything plans would cost you $190 (prior to taxes) per month just to share 1 gig between the 2 smartphones....$210 to share 4 gigs (prior to taxes). you may be able to keep your current plan and add 2 data packages at $30 each. that would be $220/month (based on you stating that you currently pay $160). if you only have one upgrade available, then your best bet would be to call and ask verizon about a certified preowned device (usually about half price of the full retail price) or check out ebay. i believe the cheapest smartphones start at $400 (and they are the very low end smartphones). you can find pretty nice ones on ebay for $200-300.

  • Since iOS 7.0.4 upgrade Mail freezes daily mid-sentence on my iPad Mini. Any ideas on how to fix?

    Since iOS 7.0.4 upgrade Mail freezes daily mid-sentence on my iPad Mini. Any ideas on how to fix?

    Hello henkeblomqvist,
    Congratulations on youre new iPad mini, and thank you for the details of the issue you are experiencing with the iPad.
    I recommend following these steps for an issue like this (you can skip 4 because it does not relate to the issue you are experiencing):
    If a single application is not responding or stops responding when it opens, you can force it to close.
    If the device is unresponsive or if certain controls aren't working as expected, restart your device.
    If the device remains unresponsive or does not turn on (or power on),reset your device.
    If there is no video or if the screen remains black, verify that the device has enough charge to turn on:
    If you are using an iPad, ensure that it's connected to the USB Power Adapter supplied with the device.
    Let charge for at least twenty minutes, then see if it starts normally.
    If there is no image on the screen, press the Sleep/Wake button to attempt to wake the device.
    If the screen displays a red battery icon, continue charging the device until the battery is fully charged.
    If the above steps do not resolve the issue, or the if the screen remains black or shows a persistent Apple logo, try restoring with iTunes:
    Connect the device to your computer and open iTunes.
    If the device appears in iTunes, select and click Restore on the Summary pane. Learn more about restoring iOS software.
    If the device doesn't appear in iTunes, try to force the device into recovery mode, and then restore it.
    If the above steps do not resolve the issue, contact Apple.
    You can find the full article here:
    iOS: Not responding or does not turn on
    http://support.apple.com/kb/TS3281
    If you get to step 5, I recommend backing up your iPhone before performing the restore:
    iOS: How to back up and restore your content
    http://support.apple.com/kb/HT1766
    Thank you for using Apple Support Communities.
    Best,
    Sheila M.

  • How are iPad Apps folders structured?

    Hi,
    I accessed the iPad's file system with an iOS file browser and wondered how the Apps folders are structured.
    all Apps have a similar file structure:
    a folder with a .app ending named after the App itself - for example "Twitter.app" or "FindMyiPhone.app".
    a Library folder.
    a folder called tmp.
    a folder called Documents
    what is the distinctive function of each of these folders?
    do I assume correctly that all files that contain user data - such as savegames, preferences, personalization - are stored under Documents? does that mean that backing up the Documents folder will preserve all data that cannot be redownloaded and reinstalled from the App Store?
    best, Ian

    thanks for the clarification.
    is it correct that all user data - by which I mean data that is relevant for a backup and cannot be restored by redownloading and reinstalling an app from the App Store - is stored in the Documents folder?
    do I assume correctly that temporary files and cached data is stored in the tmp folder while the .app as well as the Library folder contain data that can be restored by redownloading and reinstalling an app from the App Store?

Maybe you are looking for