Please help with the sql logic

The below is going to be a record set from for a view from the FROM CLAUSE
1. Find component DOCUMENT where the document type = Square Metres (DOC.UOM_STD_ID = 'METR_MTR) If any components are found, retrieve the Document records for these components ONLY.
2. Otherwise, if no components exist with a Document type = Square Metres, look for components with a Document type of Acres (DOC.UOM_STD_ID = 'ACRE'). If found, retrieve the Space Lease records for these components ONLY.
3. Otherwise, if the Document does not have components with a type = Square Metres or Acres, look for components with the type of (DOC.UOM_STD_ID = 'PARK'). Then retrieve the departments associated with these parking components.
For Space Lease records above, retrieve the associated Org ID (SPACE.SPORG).
Return all departments where
the associated Org Type (ORG.ORGCLASS) = 'NON'
or the associated Org Type (ORG.ORGCLASS) = 'GD'
Thank you

maybe something like:
SQL> select emp.empno, emp.ename, emp.deptno
  2    from emp,
  3         (select case when (select 1 from emp where deptno = 10 and rownum  = 1) = 1 then 1
  4                      when (select 2 from emp where deptno = 60 and rownum  = 1) = 2 then 2
  5                      else 3
  6                 end case_col
  7            from dual) d1
  8   where deptno = decode(d1.case_col,1,10,
  9                                     2,60,
10                                     3,70);
     EMPNO ENAME          DEPTNO
      7839 KING               10
      7782 CLARK              10
      7934 MILLER             10
SQL> in you code it will be something like:
select ...
   from document t1,        
        (select case when (select 1 from document doc where DOC.UOM_STD_ID = 'METR_MTR' and rownum  = 1) = 1 then 1
                     when (select 1 from document doc where DOC.UOM_STD_ID = 'ACRE' and rownum  = 1) = 2 then 2
                     else 3
                end case_col
           from dual) d1
where t1.uom_std_id = decode(d1.case_col,1,'METR_MTR',
                                         2,'ACRE',
                                         3,'PARK',
                                           null);note: untested

Similar Messages

  • Please Help with the sql below for hierarchies

    Hi all.
    I have a table named stg_org_hier whose data looks like this
    i would like to build the hierarchy from BU,AREA,REGION,DISTRICT,TERR
    There are data cyles in the data below
    stg_org has this data
    QTR_CD     HIER_LVL_CD CURR_RDT_ID     DISTRICT_RDT_ID
    2007Q4     AREA     E0F7B00000000     E0F7B00000000
    2007Q4     BU     E0F7B00000000     E0F7B00000000
    2007Q4     AREA     E0F7B40000088     E0F7B40000000
    2007Q4     REGION     N0F7B40400000     E0F7B40000000
    2007Q4     REGION     E0F7B40700000     E0F7B40000000
    2007Q4     AREA     E0F7B00000088     E0F7B00000000
    2007Q4     AREA     E0F7B40000000     E0F7B00000000
    2007Q4     DISTRICT     N0F6B40405C99     N0F7B40400000
    2007Q4     REGION     N0F7B40400088     N0F7B40400000
    2007Q4     DISTRICT     N0F7B40405M99     N0F7B40400000
    2007Q4     TERR     N0F1B40405201     N0F7B40405M99
    they would like to see the output in the below in the below form
    QTR_CD     HIER_LVL_CD CURR_RDT_ID     DISTRICT_RDT_ID
    2007Q4     BU     E0F7B00000000     E0F7B00000000
    2007Q4     AREA     E0F7B00000000     E0F7B00000000
    2007Q4     AREA     E0F7B00000088     E0F7B00000000
    2007Q4     AREA     E0F7B40000000     E0F7B00000000
    2007Q4     AREA     E0F7B40000088     E0F7B40000000
    2007Q4     REGION     E0F7B40700000     E0F7B40000000
    2007Q4     REGION     N0F7B40400000     E0F7B40000000
    2007Q4     DISTRICT     N0F6B40405C99     N0F7B40400000
    2007Q4     REGION     N0F7B40400088     N0F7B40400000
    2007Q4     DISTRICT     N0F7B40405M99     N0F7B40400000
    2007Q4     TERR     N0F1B40405201     N0F7B40405M99
    Here is the sql i have written :
    select curr_terr_rdt_id,district_rdt_id,hier_lvl_cd,level from STG_ORG_QTR_SF_HCHY
    connect by prior
    curr_terr_rdt_id=district_rdt_id

    qtr_cd,hier_lvl_cd,curr_rdt_id,  district_rdt_id
    2007Q4,BU,         E0F7B00000000,E0F7B00000000
    2007Q4,AREA,       E0F7B00000000,E0F7B00000000
    2007Q4,AREA,       E0F7B00000088,E0F7B00000000
    2007Q4,AREA,       E0F7B40000000,E0F7B00000000
    2007Q4,AREA,       E0F7B40000088,E0F7B40000000
    2007Q4,REGION,     E0F7B40700000,E0F7B40000000
    2007Q4,REGION,     N0F7B40400000,E0F7B40000000
    2007Q4,DISTRICT,   N0F6B40405C99,N0F7B40400000
    2007Q4,REGION,     N0F7B40400088,N0F7B40400000
    2007Q4,DISTRICT,   N0F7B40405M99,N0F7B40400000
    2007Q4,TERR,       N0F1B40405201,N0F7B40405M99Not having a database at hand right now is helpful this time ;)
    Indenting the data clearly shows that the hierarchy rules are being violated (cycles you are mentioning do not matter in this case):
    Each node must have a unique predecessor except the root having none (in your case data on lines 3 and 4 both point to lines 1 and 2)
    2007Q4,BU,         E0F7B00000000,E0F7B00000000
    2007Q4,AREA,       E0F7B00000000,E0F7B00000000
           2007Q4,AREA,       E0F7B00000088,E0F7B00000000
           2007Q4,AREA,       E0F7B40000000,E0F7B00000000
                  2007Q4,AREA,       E0F7B40000088,E0F7B40000000
                  2007Q4,REGION,     E0F7B40700000,E0F7B40000000
                  2007Q4,REGION,     N0F7B40400000,E0F7B40000000
                         2007Q4,DISTRICT,   N0F6B40405C99,N0F7B40400000
                         2007Q4,REGION,     N0F7B40400088,N0F7B40400000
                         2007Q4,DISTRICT,   N0F7B40405M99,N0F7B40400000
                                2007Q4,TERR,       N0F1B40405201,N0F7B40405M99Removing the first data line or changing it's curr_rdt_id will make hierarhical queries work (lines 1 and 2 would better not point to themself)
    Regards
    Etbin
    Message was edited by: Etbin
    user596003

  • Please help with the sql

    Hi ALL,
    Test_dpnt is a table.from this i want to find the total no.of applications
    (ssc,ssa,ssb,ssd,map,maq,oet,oet)---total 8.
    parent - 2(since oet is indepentdent)
    children---4
    independent-2
    source_app is the parent applications
    dpnt_app---child application of parent
    source_app dpnt_app
    ssc ssa
    ssc ssb
    ssc ssd
    mad map
    mad maq
    oet oet
    I want the output likethis
    total parent child independent
    8 2 4 2
    How to write the sql for this

    still unclear to me on how you will be able to get the output as
    total parent child independent
    8     2      4     2based on the sample data you have posted below:
    app_srce app_dpnt app_dpnt-typ-c
    43       190      R
    43       191      R
    150      200      R
    150      201      R
    300      300      Rdo you mean by the output should look something like this:
    srce count dpnt count
    2          1        
               1        
    2          1
               1
    1          1or that it needs to count all the rows for each of the 3 columns

  • Hi, please help with the installation of Lightroom 4, I bought a new Mac (Apple) and I want to install a software that I have on the album cd. My new computer does not have the drives. Can I download software from Adobe? Is my license number just to be ab

    Hi, please help with the installation of Lightroom 4, I bought a new Mac (Apple) and I want to install a software that I have on the album cd. My new computer does not have the drives. Can I download software from Adobe? Is my license number just to be able to download the srtony adobe.

    Adobe - Lightroom : For Macintosh
    Hal

  • Please help with an sql to show more than one records into single row for each student

    From the following data I would like to create an sql to get the information  as the following layout
    studentid,  firstTerm,  EnglishMark1,ScienceMark1,MathsMark1, Secondterm,EnglishMark2,ScienceMark2,MathsMark2,
    ThirdTerm,EnglishMark3,ScienceMark3,MathsMark3 // As single rows for each student
    Example
    1 First, 30,40,20,Sec,30,40,20,  simillarly next row for next row for another sudent. Please help to generate the sql for the same.
    Please help it would be very appreciate.
    With Thanks
    Pol
    polachan

    create table yourdata (studentid int, term varchar(10), section varchar(50), Mark int)
    insert into yourdata values
    (1,'First','Math',20),(1,'First','English',30),(1,'First','Science',40),
    (2,'First','Math',20),(2,'First','English',30),(2,'First','Science',40),
    (3,'First','Math',20),(3,'First','English',30),(3,'First','Science',40),
    (1,'Sec','Math',20),(1,'Sec','English',30),(1,'Sec','Science',40),
    (2,'Sec','Math',20),(2,'Sec','English',30),(2,'Sec','Science',40),
    (3,'Sec','Math',20),(3,'Sec','English',30),(3,'Sec','Science',40)
    Select studentid
    ,max(case when term='First' and section='English' Then Mark End) as EnglishMark1
    ,max(case when term='First' and section='Science' Then Mark End) as ScienceMark1
    ,max(case when term='First' and section='Math' Then Mark End) as MathMark1
    ,max(case when term='Sec' and section='English' Then Mark End) as EnglishMark2
    ,max(case when term='Sec' and section='Science' Then Mark End) as ScienceMark2
    ,max(case when term='Sec' and section='Math' Then Mark End) as MathMark2
    ,max(case when term='Third' and section='English' Then Mark End) as EnglishMark3
    ,max(case when term='Third' and section='Science' Then Mark End) as ScienceMark3
    ,max(case when term='Third' and section='Math' Then Mark End) as MathMark3
    From yourdata
    Group by studentid
    drop table yourdata

  • Please help with PL/SQL

    Hi All,
    This is driving me nuts but I can't see what I am doing wrong....
    I have a simple PL/SQL with :
    DECLARE
    xxx NUMBER;
    BEGIN
    FOR z in 1..htmldb_application.g_f02.count loop
    xxx:=htmldb_application.g_f02(z);
    select task_id into present_task from dm_process_steps where process_id=:P34_ID AND task_id = xxx;
    htp.p(xxx);
    IF htmldb_application.g_f02(z) = present_task THEN
    htp.p('PRESENT');
    ELSE
    htp.p('NOT PRESENT');
    END IF;
    END;
    The above fails with:
    ORA-01403: no data found
    However if I replace the marked xxx with the number then the code works fine.
    I do not understand the reason for this since I know that xxx has in fact a value and the select should be valid!
    Kindly asking for any help on this!
    Pawel.

    Scott,
    This will probably be a quite extended but I'll try to make it as clear as possible. I took a different approach to find the element which is causing the problem.
    I have 2 TABLES defined as:
    DM_PROCESS_STEPS
    ID Number
    PROCESS_ID Number
    TASK_ID Number
    TASK_ORDER Number
    DM_TASKS
    TASK_ID Number
    TASK_TITLE Varchar2
    ...and some more columns ...
    On the page I have a PL/SQL Region with:
    DHTML_SHUTTLE (
    pSQL_1=>'select "TASK_TITLE","TASK_ID" from "DM_TASKS"',
    pSQL_2=>'select t.task_title, p.task_id from dm_tasks t,dm_process_steps p where t.task_id = p.task_id and process_id = :P34_ID order by p.task_order',
    pID_1=>'1',
    pID_2=>'2',
    pSort1=>'N',
    pSort2=>'Y',
    pFixed1=>'Y',
    pHeight=>'300',
    pWidth=>'400',
    pImagePrefix=>v('WORKSPACE_IMAGES')
    NOTE: All above code comes from a working shuttle_sample code. The only things I modified were pSQL_1 and pSQL_2
    - In this case I want to have "All available tasks in the first list"
    - Since the syntax for pSQL_2 item must return two columns I wrote a joined queary so that I can see the Task_Title on the second list although this column doesn't directly come from DM_PROCESS_STEPS.
    I also have a After Submit Process which is fired upon pressing an apply button:
    DECLARE
    BEGIN
    -- Clean the Tasks from current Process --
    delete from dump where process_id = :P34_ID;
    -- Populate the Process with new list
    FOR z in 1..htmldb_application.g_f02.count loop
    INSERT INTO DUMP
    (ID,TASK_ID,PROCESS_ID,TASK_ORDER)
    VALUES (DM_PROCESS_STEPS_SEQ.nextval,htmldb_application.g_f02(z),:P34_ID,z);
    END LOOP;
    END;
    Now, the problem is with htmldb_application.g_f02(z) element. If understand correctly (please verify this!) the value of this element is whatever the pSQL_2 returns in the second column. In this case, htmldb_application.g_f02(z) returns the Task_Id.
    However, when I view the contents of the DM_PROCESS_STEPS table I can see that the first row (or rows) contain PROCESS_ID under TASK_ID column !!! This is were I am most confused as I cannot figure out were these htmldb_application.g_f02(z) come from !!!
    For example:
    1. I am trying to edit tasks for a process with process_id = 421:
    2. In my select list I have 3 tasks (who's task_id are 746,782 and 785)
    When executing the above update process I get the following results:
    ID TASK_ID PROCESS_ID TASK_ORDER
    1737 421 421 1
    1738 421 421 2
    1739 421 421 3
    1740 746 421 4
    1741 782 421 5
    1742 785 421 6
    If I am not mistaken the value of
    htmldb_application.g_f02(1) - should be the Task_Id of the first element on my select list
    htmldb_application.g_f02(2) - should be the Task_Id of the second element on my select list and so on....
    Why does htmldb_application.g_f02(1-3) hold a different value is beyond me !
    Questions which bother me:
    - Is there any way to lookup to 'contents' of htmldb_application.g_f02(1) from a separate SQL session or does it has to be in run-time?
    - Perhaps there is a way to flush or clean the htmldb_application.g_f02 ?
    Your help would be greatelly appriciated !
    Regards,
    Pawel.

  • Please help with the query (INSERT RETURNING BULK COLLECT INTO)

    I am trying to write a query inside the C# code where I would insert values into a table in bulk using bind variables. But I also I would like to receive a bulk collection of generated sequence number IDs for the REQUEST_ID. I am trying to use RETURNING REQUEST_ID BULK COLLECT INTO :REQUEST_IDs clause where :REQUEST_IDs is another bind variable
    Here is a full query that use in the C# code
    INSERT INTO REQUESTS_TBL(REQUEST_ID, CID, PROVIDER_ID, PROVIDER_NAME, REQUEST_TYPE_ID, REQUEST_METHOD_ID, SERVICE_START_DT, SERVICE_END_DT, SERVICE_LOCATION_CITY, SERVICE_LOCATION_STATE, BENEFICIARY_FIRST_NAME,
    BENEFICIARY_LAST_NAME, BENEFICIARY_DOB, HICNUM, CCN, CLAIM_RECEIPT_DT, ADMISSION_DT, BILL_TYPE,
    LANGUAGE_ID, CONTRACTOR_ID, PRIORITY_ID, UNIVERSE_DT, REQUEST_DT, BENEFICIARY_M_INITIAL,
    ATTENDING_PROVIDER_NUMBER, BILLING_NPI, BENE_ZIP_CODE, DRG, FINAL_ALLOWED_AMT, STUDY_ID, REFERRING_NPI)
    VALUES
    (SQ_CDCDATA.NEXTVAL, :CIDs, :PROVIDER_IDs, :PROVIDER_NAMEs, :REQUEST_TYPE_IDs,
    :REQUEST_METHOD_IDs, :SERVICE_START_DTs, :SERVICE_END_DTs, :SERVICE_LOCATION_CITYs,
    :SERVICE_LOCATION_STATEs, :BENEFICIARY_FIRST_NAMEs, :BENEFICIARY_LAST_NAMEs, :BENEFICIARY_DOBs,
    :HICNUMs, :CCNs, :CLAIM_RECEIPT_DTs, :ADMISSION_DTs, :BILL_TYPEs, :LANGUAGE_IDs,
    :CONTRACTOR_IDs, :PRIORITY_IDs, :UNIVERSE_DTs, :REQUEST_DTs, :BENEFICIARY_M_INITIALs,
    :ATTENDING_PROVIDER_NUMBERs, :BILLING_NPIs, :BENE_ZIP_CODEs, :DRGs, :FINAL_ALLOWED_AMTs,
    :STUDY_IDs, :REFERRING_NPIs) RETURNING REQUEST_ID BULK COLLECT INTO :REQUEST_IDs
    However, when I run this query, it gives me a strange error ORA-00925: missing INTO keyword. I am not sure what that error means since I am not missing any INTOs
    Please help me resolve this error or I would appreciate a different solution
    Thank you

    You cannot use (and do not want to in this case) the BULK COLLECT.
    create table for_testing
       the_id      number not null primary key,
       some_data   number
    declare
       l_return_value for_testing.the_id%type;
    begin
      4 
       insert into for_testing
          the_id,
          some_data
       values
          1,
          5
       returning the_id into l_return_value;
       dbms_output.put_line('the return values is ' || l_return_value);
    end;
    20  /
    the return values is 1
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:00.02
    TUBBY_TUBBZ?Is a simple example. In the future, please use the tags to preserve formatting on your code like i have so it remains readable .                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Please help with the GUI quiz question!

    Hi Folks,
    Please help me with the code for the following GUI.
    The display window of the application should have two panels at the top level (you could have multiple panels contained within a top-level panel). The first top level panel should have a grid or a border layout and should include apart from various label objects: 1) a textfield to store the info entered, 2) a combobox 3) a combobox or a list box , 4) a radio-button group , 5) a combo box 6) checkboxes for additional accessories, and 7) checkboxes .
    The second top-level panel that is placed at the bottom of the window should have a submit button, a clear button and a textarea for output.
    Thanks a lot.

    Please be a little more explicit about what you're doing, what you expect to happen, and what you actually observe.
    Please post a short, concise, executable example of what you're trying to do. This does not have to be the actual code you are using. Write a small example that demonstrates your intent, and only that. Wrap the code in a class and give it a main method that runs it - if we can just copy and paste the code into a text file, compile it and run it without any changes, then we can be sure that we haven't made incorrect assumptions about how you are using it.
    Post your code between [code] and [/code] tags. Cut and paste the code, rather than re-typing it (re-typing often introduces subtle errors that make your problem difficult to troubleshoot). Please preview your post when posting code.
    Please assume that we only have the core API. We have no idea what SomeCustomClass is, and neither does our collective compiler.
    If you have an error message, post the exact, complete error along with a full stack trace, if possible. Make sure you're not swallowing any Exceptions.
    Help us help you solve your problem.

  • Can anyone please help with the 2.3 update in UK?

    Can anyone please help?  I have an unbranded x10 in the UK.  PC companion constantly tells me my phone software is up to date (with android 2.1) so I cannot upgrade to 2.3.  I've tried all the tips on the SE support page like deleting the database content and looking for the setting to update the phone next time it's connected which doesn't exist (very informative SE!).  I'm not keen on this independent software installation through the rapidshare download, it seems full of glitches looking at the forums.  http://www.sonyericsson.com/update/?lc=en&cc=gb&pid=xperiax10  This link clearly tells us the update is available through PC companion, no joy for me though.  Any help is welcome.

    Have a look at this and check your version number see if its listed
    http://forum.xda-developers.com/showthread.php?t=1186045
    As for generic roms you have probable read about custom roms
    See this thread it is a stock SE rom not a custom rom and will give you just that a stock SE rom if you want
    http://talk.sonyericsson.com/thread/19762

  • Help with the sql

    Table 2 is a subset of table 1. All the accounts in table2 are in table 1. Now i want all the accounts in table 1 which are not in table 2. I wrote a sql something like below but ended up getting all the accounts, i know it's because of the left outer join. I need some idea someone please help. Thank you.
    select a.account from table 1 a
    left outer join
    ( select account from table 2) turr on turr.account <> a.ccount

    There are many ways to achieve that. Here are some ideas:
    SELECT account FROM TABLE_1
    MINUS
    SELECT account FROM TABLE_2
    SELECT account
    FROM   table_1
    WHERE  NOT EXISTS
           ( SELECT null
             FROM   table_2
             WHERE  table_2.account = table_1.account
    SELECT account
    FROM   table_1
    WHERE  account NOT IN (SELECT account FROM table_2)
    SELECT table_1.account
    FROM      table_1
    LEFT JOIN table_2 ON table_1.account = table_2.account
    WHERE  table_2.account IS NULL
    ;

  • Please help with the URL class

    Hello,
    I am trying to write a Java app that will take a url and download it.
    I believe you can do this with the URL class but I don't understand how to. For example, if the http url location points to a picture file, how would I code the app to retrieve this picture and save it to a specified directory?
    Also, is there a way that my java app could open another program, let's say Microsoft Internet Explorer?
    Please be as specific as possible, thanks!

    You'll see below an example to download a file
    private static String copyFile (String url, String nomFichier){
         // construction du fichier de sortie
         File outputFile = new File(repertoire + "\\fichiers\\" + nomFichier);
         // si le fichier existe d�j�, il ne sert � rien de le t�l�charger !
    if (outputFile.exists())
         return "fichiers/" + nomFichier;
              try {     
         HttpURLConnection connect = (HttpURLConnection)new URL(url).openConnection();
    boolean connected = false;
    while (!connected){
    try {
    connect.connect();
    connected = true;
         catch (java.io.IOException e1) { System.out.print("...Tentative de connection"); }     
    DataInputStream reader = new DataInputStream(
    connect.getInputStream());
         FileOutputStream out = new FileOutputStream(outputFile);
         int length = 1024;
         byte[] buf = new byte[length];
         int offset = 0;
         long offsetCourant = 0;
         int nb=0;
         while ((nb=reader.read(buf,offset,length))!= -1) {
              out.write(buf,0,nb);
         out.close();
         catch (java.net.MalformedURLException e) { System.out.println("pb d'url"); }
         catch (java.io.IOException e1) { System.out.println(e1.getMessage()); }
         return "fichiers/" + nomFichier;
    }

  • Please help with UIPickerView didSelectRow logic.

    Hello all,
    Im still a noob so forgive me if these are way off base.
    My app is coming along thanks to the help of Ray and others in this forum so thanks for that!
    I have a Q&A type app with 3 separate question formats, ie... Multiple Choice, True and False and Combo, and more to come in the future...
    Each type of question has its own view controller and its own plist of questions. So... MultipleChoiceViewController loads the MultipleChoice.plist and off it goes.
    My current app flow...
    QuestionFormatViewController with 3 buttons for each type of question.
    So when the user picks the MultipleChoice button I take them to MultipleChoiceViewController as I mentioned above.
    example...
    - (IBAction) mcFormatSelected:(id)sender {
    NSLog (@"mcFormatSelected ");
    MCQuestionsViewController *mcQuestionsViewController = [[MCQuestionsViewController alloc] initWithNibName:@"QuestionsViewController" bundle:nil];
    mcQuestionsViewController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
    [self presentModalViewController:mcQuestionsViewController animated:YES];
    [mcQuestionsViewController release];
    I wanted a way to let the user not only choose the question format but also the number of questions returned. So I thought a UIPickerView with 2 components would work well for this.
    So I went on the hunt for some UIPickerView examples and found one that presents itself in an action sheet which is perfect because I can also provide a Done button.
    This particular sample code found here... http://discussions.apple.com/thread.jspa?threadID=1674641&start=15&tstart=0
    has me subclass UIActionSheet and then upon a button press it presents the action sheet with the UIPickerView. Thats as far as I can get on my own.
    PickerActionSheet.h
    #import <UIKit/UIKit.h>
    @interface PickerActionSheet : UIActionSheet {
    UIPickerView *picker;
    BOOL layoutDone;
    @property (nonatomic, retain) UIPickerView *picker;
    @end
    PickerActionSheet.m
    #import "PickerActionSheet.h"
    @implementation PickerActionSheet
    @synthesize picker;
    - (id)initWithTitle:(NSString *)title delegate:(id < UIActionSheetDelegate >)delegate
    cancelButtonTitle:(NSString *)cancelButtonTitle
    destructiveButtonTitle:(NSString *)destructiveButtonTitle
    otherButtonTitles:(NSString *)otherButtonTitles, ... {
    self = [super initWithTitle:title delegate:delegate cancelButtonTitle:cancelButtonTitle
    destructiveButtonTitle:destructiveButtonTitle otherButtonTitles:otherButtonTitles];
    if (self) {
    UIPickerView *p = [[UIPickerView alloc] initWithFrame:CGRectZero];
    [self addSubview:p];
    self.picker = p;
    [p release];
    return self;
    - (void)dealloc {
    [super dealloc];
    * Determine maximum y-coordinate of UILabel objects. This method assumes that only
    * following objects are contained in subview list:
    * - UILabel
    * - UITextField
    * - UIThreePartButton (Private Class)
    - (CGFloat) maxLabelYCoordinate {
    // Determine maximum y-coordinate of labels
    CGFloat maxY = 0;
    for( UIView *view in self.subviews ){
    if([view isKindOfClass:[UILabel class]]) {
    CGRect viewFrame = [view frame];
    CGFloat lowerY = viewFrame.origin.y + viewFrame.size.height;
    if(lowerY > maxY)
    maxY = lowerY;
    return maxY;
    - (void)layoutSubviews {
    [super layoutSubviews];
    if(!layoutDone) {
    CGRect frame = [self frame];
    CGFloat alertWidth = frame.size.width;
    CGFloat pickerHeight = self.picker.frame.size.height;
    CGFloat labelMaxY = [self maxLabelYCoordinate];
    // Insert UIPickerView below labels and move other fields down accordingly
    for(UIView *view in self.subviews){
    if([view isKindOfClass:[UIPickerView class]]){
    CGRect viewFrame = CGRectMake(0, labelMaxY, alertWidth, pickerHeight);
    [view setFrame:viewFrame];
    } else if(![view isKindOfClass:[UILabel class]]) {
    CGRect viewFrame = [view frame];
    viewFrame.origin.y += pickerHeight;
    [view setFrame:viewFrame];
    // size UIAlertView frame by height of UIPickerView
    frame.size.height += pickerHeight + 2.0;
    frame.origin.y -= pickerHeight + 2.0;
    [self setFrame:frame];
    layoutDone = YES;
    @end
    I implemented this in my HomeScreenViewController when the user presses the test button. At this point I would like to present my UIPickerView, have the user select a test type and number of questions then click Done and be taken to the appropriate viewController.
    HomeScreenViewController.h (some items omitted to conserve on space...)
    #import <UIKit/UIKit.h>
    @interface HomeScreenViewController : UIViewController <UIPickerViewDelegate, UIPickerViewDataSource, UIActionSheetDelegate> {
    NSMutableArray *numberOfQuestionsArray;
    NSMutableArray *questionFormatArray;
    @property (nonatomic, retain) NSMutableArray *numberOfQuestionsArray;
    @property (nonatomic, retain) NSMutableArray *questionFormatArray;
    - (IBAction) showPicker:(id)sender;
    @end
    HomeScreenViewController.m (again, omitted some code...)
    @implementation HomeScreenViewController
    @synthesize numberOfQuestionsArray;
    @synthesize questionFormatArray;
    - (void)dealloc {
    [super dealloc];
    [numberOfQuestionsArray release];
    [questionFormatArray release];
    // Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
    - (void)viewDidLoad {
    [super viewDidLoad];
    NSLog(@"Activities loaded");
    numberOfQuestionsArray = [[NSMutableArray alloc] init];
    [numberOfQuestionsArray addObject:@"10"];
    [numberOfQuestionsArray addObject:@"20"];
    [numberOfQuestionsArray addObject:@"30"];
    [numberOfQuestionsArray addObject:@"40"];
    [numberOfQuestionsArray addObject:@"50"];
    [numberOfQuestionsArray addObject:@"60"];
    [numberOfQuestionsArray addObject:@"70"];
    [numberOfQuestionsArray addObject:@"80"];
    [numberOfQuestionsArray addObject:@"90"];
    [numberOfQuestionsArray addObject:@"100"];
    [numberOfQuestionsArray addObject:@"All"];
    questionFormatArray = [[NSMutableArray alloc] init];
    [questionFormatArray addObject:@"True and False];
    [questionFormatArray addObject:@"Multiple Choice"];
    [questionFormatArray addObject:@"Combo"];
    - (IBAction) showPicker:(id)sender {
    PickerActionSheet * sheet = [[PickerActionSheet alloc] initWithTitle:@"Pick Question Format and Number of Questions"
    delegate:self cancelButtonTitle:@"Done" destructiveButtonTitle:nil otherButtonTitles:nil];
    sheet.picker.delegate = self;
    sheet.picker.dataSource = self;
    [sheet showInView:self.view];
    [sheet release];
    - (NSInteger) numberOfComponentsInPickerView:(UIPickerView *)thePickerView {
    return 2;
    - (NSInteger) pickerView:(UIPickerView *)thePickerView numberOfRowsInComponent:(NSInteger)component {
    if (component == 0) {
    return [questionFormatArray count];
    return [numberOfQuestionsArray count];
    - (NSString *)pickerView:(UIPickerView *)thePickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component {
    if (component == 0) {
    return [questionFormatArray objectAtIndex:row];
    return [numberOfQuestionsArray objectAtIndex:row];
    - (void)pickerView:(UIPickerView *)thePickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {
    NSLog(@"didSelectRow");
    if (component == 0) {
    NSLog(@"Selected Format: %@. Index of selected format: %i", [questionFormatArray objectAtIndex:row], row);
    NSLog(@"Selected number of questions: %@. Index of selected number of questions: %i", [numberOfQuestionsArray objectAtIndex:row], row);
    @end
    All is good with this code. It builds and runs and shows the ActionSheet with the UIPickerView in it. However, Im not sure how to get that Done button to accept the users choices and take me to the appropriate viewController for the type they select. And...
    question 2 - Once the value for numberOfQuestions is selected, how do I pass that into the QuestionsViewController to limit my questions array to the selected amount??
    What I think I need...
    In QuestionsViewController.h
    #import "HomeScreenViewController.h"
    and a variable in my QuestionsViewController of numberOfQuestions then when I transition from the HomeScreenViewController to my QuestionViewController Ill set the amount but thats where Im not sure how to implement it.
    Here is my current code for setting the questions array which is an NSMutableArray...
    QuestionsViewController.m
    - (void)viewDidLoad {
    [super viewDidLoad];
    NSString *comboPath = [[NSBundle mainBundle] pathForResource:@"ComboQuestions" ofType:@"plist"];
    NSLog(@"%s: path=%@", _func_, comboPath);
    NSMutableArray* tmpComboArray = [[NSMutableArray alloc]initWithContentsOfFile:comboPath];
    self.questions = tmpComboArray;
    [tmpComboArray release];
    [self reset];
    Any help would be appreciated!!!

    Ray, I cant thank you enough for all your help man. Fricken awesome!
    RayNewbie wrote:
    Hi Merlin -
    I'll try to outline the answers to your explicit questions, but I have some reservations about the code you found to subclass UIActionSheet. I'm also not sure I understand the controller hierarchy you described. So I'd like to wait for your response before getting into any working example code. In other words, the code in this post is only for the purpose of clarifying the text, ok?
    See this is a perfect example of me still not knowing the ins and outs of this. Im still a little unclear on documented and undocumented info. So in order to find out if a method or class is documented, do you simply search the apple reference docs for it and make sure all the instances are accounted for?
    My current control hierarchy has the HomeScreenViewController that passes the user off to the QuestionFormatViewController which upon selection of a format passes the user to the QuestionsViewController. In the spirit of KISS (Keep it simple stupid) I was attempting to get rid of the QuestionFormatViewController and present those options after a selection was made on the HomeScreenViewController. Hope that makes sense.
    iMerlin wrote:
    [question 1 -] Im not sure how to get that Done button to accept the users choices and take me to the appropriate viewController for the type they select.
    I would give the action sheet delegate responsibility for getting the picker view selections. If the delegate is the controller that created the action sheet, you might do something like this:
    - (void)actionSheet:(UIActionSheet *)actionSheet willDismissWithButtonIndex:(NSInteger)buttonIndex {
    if (buttonIndex == kActionIndexDone) {
    UIPickerView *picker = actionSheet.picker;
    // assume this controller has int ivars to store the question format and the number of questions
    self.questionFormat = [picker selectedRowInComponent:0];
    self.questionCount = [picker selectedRowInComponent:1];
    // maybe convert questionCount in some way here or later; e.g.:
    // self.questionCount = [[numberOfQuestionsArray objectAtIndex:questionCount] intValue];
    - (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex {
    if (buttonIndex == kActionIndexDone) {
    switch (questionFormat) {
    case kQuestionFormatMultipleChoice:
    MultipleChoiceViewController *mcvc = [[MultipleChoiceViewController alloc]
    initWithNibName:@"MultipleChoiceViewController", bundle:nil];
    mcvc.questionCount = questionCount;
    mcvc.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
    [self presentModalViewController:mcvc animated:YES];
    [mcvc release];
    break;
    case kQuestionFormatTrueFalse:
    break;
    This is perfect Ray. But one question on yet another area Im slightly confused by... delegates! I see you are initializing an instance of the MultipleChoiceViewCOntroller here...
    switch (questionFormat) {
    case kQuestionFormatMultipleChoice:
    MultipleChoiceViewController *mcvc = [[MultipleChoiceViewController alloc]
    initWithNibName:@"MultipleChoiceViewController", bundle:nil];
    mcvc.questionCount = questionCount;
    mcvc.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
    [self presentModalViewController:mcvc animated:YES];
    [mcvc release];
    break;
    But I was under the impression that to "set" a value in another class I would have to make it a delegate to the class Im "getting" it from. So the whole thing like...
    @protocol ActionSheetDelegate...
    id<ActionSheetDelegate> delegate;
    Then make MCVC conform to that protocol. Am I overcomplicating things again?
    Also, do the kValues need to be defined?
    question 2 - Once the value for numberOfQuestions is selected, how do I pass that into the QuestionsViewController to limit my questions array to the selected amount??
    I'm not sure I understand which controller is which, or if you need all the controller classes you mentioned (QuestionFormatViewController, QuestionsViewController, HomeScreenViewController, etc.), but the above example shows how to pass the no. of questions to the MultipleChoiceViewController. The same delegate method could send that same question count to any other controller (assuming you've provided a way for the delegate to find the address of the other controller(s).
    As to subclassing UIActionSheet, I"m not comfortable with the code you found because it implicitly relies on some undocumented details. For example, in this code:
    - (CGFloat) maxLabelYCoordinate {
    // Determine maximum y-coordinate of labels
    CGFloat maxY = 0;
    for( UIView *view in self.subviews ){
    if([view isKindOfClass:[UILabel class]]) {
    CGRect viewFrame = [view frame];
    CGFloat lowerY = viewFrame.origin.y + viewFrame.size.height;
    if(lowerY > maxY)
    maxY = lowerY;
    return maxY;
    I don't see anything in the doc about UILabel objects as components of UIActionSheet. I certainly could've missed that in the doc, or misunderstood the subclass code, but at first glance it looks like the programmer manually enumerated the subviews, discovered the "buttons" were labels, and used this information accordingly. That's going to work nicely so long as UIActionSheet continues to be implemented in the same way. But if Apple decides to make a UIActionSheel without UILabel objects in the future, this subclass might not produce the view you want.
    Completely understand now that you've explained it this way. I would hate to spend any time on something Ill ultimately have to fix anyway.
    The decision to use undocumented info is up to you. I would agree UIActionSheet will likely continue to be costructed the way it is now. But a product based on this assumption doesn't give me a really warm, fuzzy feeling. I might accept the risk if there were no other alternative, and the desired feature were really important. In this case though, there are plenty of choices that don't require any fancy subclassing. For example, it's very easy to slide in a half-screen subview containing the picker view and any control layout you want. You can add other action-sheet like behaviors as needed (e.g. tinting and disabling the covered view).
    Since you already have your subclass working, I guess it might make sense to finish up the current design and upgrade to something safer in a later version (or not).
    - Ray
    No, Im with you on this one 100%. I noticed someone mentioned it was undocumented in the other thread but I kinda skipped right over that for some reason. The reason I found this method fitting to my implementation is because it also provides the Done button. I think Im going to play with the actionSheet code you provided just to see if I can get it working. But Ill ultimately go in a new direction, like you said.
    After spending a lot of last night looking into UIPickerView and the like, not to mention your last statement, I realized I dont need an action sheet to get that Done button. I can just build a new view and present that. I think Ill go that route instead of the subclass of actionsheet. Do the above examples still fit if I build a regular view? Of course Ill have to write those setters into the didSelectRow method of the UIPickerView, right?
    Here I go again letting the implementation drive the concept! Am I on the right track by thinking I can just build a new view with a picker and a done button on it, then present that as a subView when the user selects an option on the HomeScreen?
    Sorry if Im all over the map here Ray, but you are really helping me stay on course!

  • Please help with the versioncue problem.

    I know this is not the right place to post this but please, I need fast help. When I open a project in Photoshop CS3 it says "Cannot find the missing module blablabla versioncue.dll". I've searched around a little and found someone who said that 2 updates would fix it. I downloaded the updates but when I started to install it said "Can't find the product to update".
    For some extra info, I just reformated comp and I've considered it might be something about missing files or something and if so, can someone add [email protected] and send to me because this is important. This is also because I have a schoolproject where Photoshop will be needed.
    I'm also suspicious if I actually have the documents and settings files for CS3 since I only copied the whole files from programs when I reformated it.
    Please help!

    >since I only copied the whole files from programs when I reformated it.
    you need to do a full install from the original discs david. simply copying the files won't do it.

  • Please help with the understanding of aspect ratio!!!

    Hi all,
    I'm trying to get my head around the 'aspect ratio' thing if anyone can help.
    To give an example, I have imported footage in FCE and in the details of the file it states:
    Pixel Aspect: PAL - CCIR 601
    Frame size: 720 x 576
    What exactly can I earn from the above information?
    I gather this is not widescreen but I would like the end film to be. Do I have to 'crop' this? If so, how!?
    And how do I make sure the picture looks right on a widescreen TV (so the people don't look squashed, say)?
    Many thanks in advanced for the wisdom passed on!
    Adam
    Oh and should i be thinking about this before I'm about to import from a Mini DV cam? As in settings...
    Message was edited by: Vegas Superstar

    If you check the anamorphic box on a 4:3 clip you will see some kind of distortion.
    In general you choose your setup accordingly with the way your footage has been shot.
    In the article you found that iDVD doesn't recognize the "anamorphic" flag that your footage can have in FCE.
    Therefore your exported material must be "arranged" so that you tell iDVD you have a 16:9 movie.
    When you work entirely in anamorphic 16:9 in FCE (your footage was shot in 16:9 and have the anamorphic flag on), when you export the sequence using export to quick time movie, you'll get a 720x576 PAL movie. Because iDVD will not translate the anamorphic flag, you have to manually change the movie size to 1024x576 for PAL, so that your resultant movie will be keeping the 16:9 aspect ratio.
    The native widescreen doesn't use such flag and the video is already at 16:9 aspect ratio.
    That's has to deal with pixel that are rectangular and not square as computer uses.
    I guess someone else will be more specific and detailed on this.
    Regards,
    Armando.

  • Please help with the FOR loop and the array..

    I was trying to place some words in the Movie Clip
    "TextPanel" and set a
    random position to each of them.
    But it's not working.
    1) I created a Movie Clip "word" and inside that MC I created
    a text field
    and gave it an identifier "textFiled".
    2) The linkage name for Movie Clip "word" I set to "word".
    3) In the actionscript I created an Array called "aWords".
    4) Then I created a FOR loop that should
    place (attach) Movie Clips "word0", "word1", "word2" and
    "word3" to the
    movie clip TextPanel, and set the textField text for each of
    them to the
    text from the Array.
    But the script attaches 4 Movie Clips with a name
    "Undefined", instead of 4
    different names (from the Array).
    What is wrong with this script?
    var aWords:Array = [apple,banana,orange,mango];
    for(i=0;i<aWords.length;i++){
    var v = TextPanel.attachMovie("word","word"+i,i);
    v.textFiled.text = aWords
    v._x = randomNumber(0,Stage.width);
    v._y = randomNumber(0,Stage.height);
    Thanks in advance

    But in my Post I already wrote v.textFiled.text = aWords
    so I don't understand what were you correcting..
    And one more:
    I have tested it by changing the
    v.textFiled.text = aWords; to v.textFiled.text = "some
    word";
    and it's working fine.
    So there is something wrong with the Array element, and I
    don't know why..
    "aniebel" <[email protected]> wrote in
    message
    news:ft2d5k$lld$[email protected]..
    > Change:
    > v.textFiled.text = aWords;
    >
    > to:
    > v.textFiled.text = aWords
    >
    > It needs to know which element inside the array you want
    to place in the
    > textfield (or textfiled) :)
    >
    > If that doesn't work, double check that your instance
    name is correct
    > inside
    > of "word".
    >

Maybe you are looking for

  • HT1386 can you set up 2 separate accounts on i tunes on the same computer, with have 2 i phones , how can it be done ?

    I have set up my i phone with i tunes on a non mac lap top computer. my wife now has an i phone, but i cant set up an account for her as the computer want to erase my details and start fresh with her phone.. she cant purchase apps without an i tune a

  • No Sound For Yahoo Games

    I am new to using the Beta version of Safari for Windows. Everything is working fine so far except when I try to play some games in Yahoo there is no sound. The game loads and plays fine, but no sound. I have installed all of the plug-ins as recommen

  • How to set the default value for page item in report

    Hi Gurus I currently i have company name as page item in one of my report screen ,but it is displaying the value for company name in its drop down column ,but i want to make it "*ALL* as default after the query result ",this is user requirement ,plea

  • Themes not working?

    On iMovie 6, my themes (after properly adding content to the drop zones, editing titles, and clicking apply) will render, but after rendering, appear without a thumbnail on the clip, and won't play. What am I to do?!?!

  • Exporting/Importing projects without Aperture?

    Rather than wait for Aperture to export a project, why not just use finder to copy it? I am doing that now. I right clicked on my Aperture library, Show package contents, and browsed to a location of a folder of projects(14 GB worth) Dragged that to