How to get the following output

Table 1                                        Table 2    
EmpCode    EmpName        EmpCode EmpPhone
10001         ABC                    10001    12345
10002         BCD                    10001    23456
10003         CDE                    10001    34567
10004         EFG                     10006    45678
10005         FGH                     10007    56789
10006         GHI                     10007    67890
10007         HIJ                      10010    78901
10008         IJK                      10010    89012
10009         JKL                     10010    90123
10010         KLM                    10011    13579
10011         LMN                    10012    35791
10012         MNO                   10012    57913
10013         NOP                   10012    79135
10014         OPQ                   10017    91357
10015         PQR                    10017    12390
10016         QRS                    10019    23479
10017         RST            
10018         STU            
10019         TUV  
output        
EmpCode    EmpName    EmpPhone
10001           ABC             12345/23456/34567
10002           BCD    
10003          CDE    
10004          EFG    
10005          FGH    
10006         GHI            45678
10007         HIJ           56789/67890
10008         IJK    
10009         JKL    
10010         KLM       78901/89012/90123
10011         LMN      13579
10012         MNO       35791/57913/79135
10013         NOP    
10014        OPQ    
10015        PQR    
10016       QRS    
10017       RST       91357/12390
10018       STU    
10019       TUV      23479
                          

Srimanta,
Check this:
select t1.EmpCode,t1.EmpName,STUFF((select '/'+EmpPhone from Table2 where EmpCode=t1.EmpCode for xml path('')),1,1,'') as PhoneNum
from Table1 t1
left join Table2 t2 on t1.EmpCode=t2.EmpCode
group by t1.EmpCode,t1.EmpName
Edited : small change in code(highlighted - t1 instead of t2)
Thanks,
Jay
<If the post was helpful mark as 'Helpful' and if the post answered your query, mark as 'Answered'>

Similar Messages

  • How to get the Query output to Excel

    Hi ,
    Can you tell me how to get the Query output to excel with out using any third party tool?
    Can you tell me how to write the code in Webservice and call it..
    Please explain it Elaboartly..
    Thanks in Advance!!!
    Mini

    whats your source system?
    you can use Live office, or query as a webservice if you are getting data from universe
    if you're getting data from SAP BI query and you have a java stack on your netweaver then you can get the data directly using sap bi connector in xcelsius.
    good luck

  • How to get the following-sibling nodes until a specific node

    XSL people,
    I need to get all the following-sibling nodes for every <h> node until the next <h> node.
    Example:
    <body>
    <h>Header1</h>
    <a>Line 11</a>
    <b>Line 12</b>
    <c>Line 13</c>
    <a>Line 14</a>
    <h>Header2</h>
    <a>Line 21</a>
    <c>Line 22</c>
    <a>Line 23</a>
    <b>Line 24</b>
    </body>
    So I need to get this strings:
    from the first <h> node: Line 11Line 12Line 13Line 14
    from the second <h> node: Line 21Line 22Line 23
    When using following-sibling
    <xsl:value-of select="following-sibling::a"/>
    <xsl:value-of select="following-sibling::b"/>
    <xsl:value-of select="following-sibling::c"/>
    I am not getting the second <a> node (of course!), so for the first <h> node I am only getting
    Line 11Line 12Line 13
    and not
    Line 11Line 12Line 13Line 14
    and I don't know how to get it.
    Thank you.
    Anatoliy Smirnov

    Thanks Sudipto for trying to help. I did try that, and as I mentioned in the previous posting, it doesn't work for the tree nodes (multiple RowSetIterator). the following is my code, where the treeVO is the vo instance for the firstLevel tree nodes and it has view link to its children. I am not sure how to sort all children for each level. Even for the first level where I did the explicit sorting in memory, it still not sorting at all.
    treeVO.setSortBy("code");
    treeVO.setQueryMode(ViewObject.QUERY_MODE_SCAN_ENTITY_ROWS|ViewObject..QUERY_MODE_SCAN_DATABASE_TABLES);
    treeVO.executeQuery();

  • How to get the desired output in the format ...?

    Hi all,
    I am having data like this.
    Col1 col2 col3
    1 2 1
    1 2 2
    1 2 3
    2 3 7
    2 3 8
    2 3 9
    I want to output the data like this
    1 2 1,2,3
    2 3 7,8,9
    How to get this.
    Thanks in advance,
    Pal

    In simple sql...
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
    With the Partitioning, OLAP and Data Mining options
    SQL> select * from t
      2  /
          COL1       COL2       COL3
             1          2          1
             1          2          2
             1          2          3
             2          3          7
             2          3          8
             2          3          9
    6 rows selected.
    SQL> select max(decode(rno,1,to_number(col1||col2||col3))) col1, max(decode(rno,2,col3)) col2, max(decode(rno,3,col3)) col3
      2    from (select row_number() over(partition by col1,col2 order by col3) rno, t.*
      3           from t)
      4  group by col1
      5  /
          COL1       COL2       COL3
           121          2          3
           237          8          9
    SQL>Thanks,
    Karthick.

  • How to get the given output format..

    Hi,I want to write a code in ABAP in such a way that I should get the output in the right side format.
    Ex:
    1200 - > 1,200
    12000  - > 12,000
    120000 ->  120,000
    1200000 -> 1,200,000
    12000000 -> 12,000,000
    120000000 - > 120,000,000
    Thanks.

    HI tushar,
    1. I don't know whether i understood u r question !
    2. FOr writing with COMMA,
      if we use simple WRITE,
      then it will show just as u want !
    regards,
    amit m.

  • How to print the following output

    hi everyone,
    I want to print the output like this
    deptno ename
    10 CLARK KING MILLER
    20 SMITH JONES SCOTT ADAMS FORD
    in a particular dept who are the emp's working .....I am using oracle 8i...if any idea let me know...
    thanks & regards
    sekhar.

    Hi~
    following code will helpful to you. but, still have 4000 bytes restriction, because of in 8i, clob||varchar2 is not working.
    so, i use res varchar2(4000) instead of res clob;
    Thanks.
    create or replace function get_all_ename(p_deptno in number)
        return varchar2
        is
                  res          varchar2(4000);
                    i           number:=0;
                    v_ename     emp.ename%TYPE;
                    cursor c1 is
                    select ename from emp where deptno=p_deptno;
        begin
             open c1;
               loop
                   fetch c1 into v_ename;
                    EXIT WHEN c1%NOTFOUND;                         
                    res :=res||' '||v_ename;
               end loop;          
               close c1;
               return res;
       end;
    select get_all_ename(deptno) from dept;
    GET_ALL_ENAME(DEPTNO)
    CLARK KING MILLER
    SMITH JONES SCOTT ADAMS FORD
    ALLEN WARD MARTIN BLAKE TURNER JAMES

  • How to get the following field values?

    I have an invoice number. How can I find out (from which tables and fields) the ship date, vessel, port of loading, port of discharge. I think it is VTTK table and fields are datbg, text1, add01 and add02, but if so what should I give in VTTK table to get these values?
    Please give your input.
    I appreciate and points assured for helpful answers.
    Krishen

    Hi Krishen,
    For ship date you can find the data in LIKP table itself. All other details like vessel, port of laoding and port of discharge will be found at the shipping point level.
    Select the delivery number in VL03n and from the menu GOTOITEMSHIPMENT you will find the shipping point details.
    Cheers
    VJ

  • How to get the job output to be displayed/send in a report?

    Dear All,
    IHAC that have a couple of jobs which they all work fine and return the desired value, and now the customer wants to take the output of the jobs and place it in one big report?
    The jobs created are the daily health checks that the DBAs run. They would like to have all the output from all the jobs consolidated in one report to be sent to them every morning on their emails.
    Kindly advise if this is doable.

    There isn't really a way to redirect a job's output. Unless you try to dig it out of the repository. Trust me it will be a hell of a job to puzzle out the locations and SQL statements to get it.
    You might consider trying to migrate your jobs into reports (if possible). Reports can be redirected to e-mail recipients.
    Regards
    Rob

  • How to get the desire output from sql query

    Consider an Order Table: ...
    Order Table:
    Order Id Item Qty
    O1 A1 5
    O2 A2 1
    O3 A3 3
    Please provide SQL which will explode the above data into single unit level records as shown below
    Desired Output:
    Order Id Order Id Qty
    O1 A1 1
    O1 A1 1
    O1 A1 1
    O1 A1 1
    O1 A1 1
    O2 A2 1
    O3 A3 1
    O3 A3 1
    O3 A3 1

    How do I ask a question on the forums?
    SQL and PL/SQL FAQ

  • How to get the console output generated by a executable program?

    when I am trying to use method getOutputSteam of Process to gain the outputStream,I got nothing!
    I have also tried to use stream redirect,also no result!
    please help me! Thank you in advance!
    my main code are below:
    Process ps=Runtime.getRuntime().exec("xxx.exe");/*xxx.exe is a executable program which will generate a console with the message I want to gain.*/
    int exitVal= ps.waitFor();
    if(exitVal==0){
    BufferredReader br = new BufferedReader(new InputStreamReader(ps.getInputStream()));               String st;
    while((st = br.readLine()) !=null){
    System.out.println("write:"+st);
    }//my result show that I got nothing from the progam.
                                                           }

    I've seen this kind of problem with an offending xxx.exe. Generally it means that the program isn't flushing its output immediately, so your java program never sees it.

  • How to get the query output depending on the current date

    i created a region of type "query",inside it created region using wizard of type "table" . in the query i filter the data depending on the current date (taken from dual table) . but still it showing no output on the page. i run the same query in the toad and its showing the 2-3 rows.
    If anybody know where the problem is then do inform me.
    thanks in advance.

    i got the answer by trying out in OAF

  • How to get the desired output

    My Table Data
    ContractID     MaterialGroup      CommodityCode     Amount
    C123       Travel     200     100
    C123      Travel     201     100
    C123             Travel     203     100
    C124            Stationery     315     500
    C126            Travel             200     600
    C126            Admin             413     600
    My expected output
    ContractID     MaterialGroup      CommodityCode     Amount
    C123        Travel             200|201|203     100
    C124             Stationery             315                     500
    C126            Travel|Admin     200|413           600
    My Present Output
    CONTRACTID MATERIALGROUP    COMMODITYCODE AMOUNT
    C123            Travel|Travel|Travel  200|203|201        100
    C124            Stationery               315                     500
    C126            Travel|Admin           200|413               600
    My Query:
      SELECT ContractID,
      RTrim(
                  xmlagg(
                          xmlelement(e, MaterialGroup|| '|')).extract('//text()'),'|') MaterialGroup,
      RTrim(
                  xmlagg(
                          xmlelement(e, CommodityCode|| '|')).extract('//text()'),'|') CommodityCode,Amount
    FROM (
    WITH t1 AS (
    SELECT 'C123' ContractID,     'Travel'MaterialGroup,      200     CommodityCode, 100 Amount FROM dual UNION all
    SELECT 'C123',            'Travel',     201,     100 FROM dual UNION all
    SELECT 'C123',            'Travel',     203,     100 FROM dual UNION all
    SELECT 'C124','Stationery',     315,     500 FROM dual UNION all
    SELECT 'C126','Travel',     200,     600 FROM dual UNION all
    SELECT 'C126','Admin',413,     600 FROM dual)
    SELECT * FROM t1)
    GROUP BY ContractID,Amount;

    select t.*,
            case when cdm = 1 and cm > 1
                    then substr(materialgroup,1, instr(materialgroup,'|', cdm)-1)
                    else materialgroup end materialgroup_edit,
             case when cdm = 1 and cm > 1 then mm else materialgroup end materialgroup_edit2
    from
              select contractid,
              count(materialgroup) cm,
              count(distinct materialgroup) cdm,
              max(materialgroup) mm,
              rtrim(
                          xmlagg(
                                  xmlelement(e, materialgroup|| '|')).extract('//text()'),'|') materialgroup,
              rtrim(
                          xmlagg(
                                  xmlelement(e, commoditycode|| '|')).extract('//text()'),'|') commoditycode,amount
            from (
            with t1 as (
            select 'C123' contractid,    'Travel' materialgroup,     200    commoditycode, 100 amount from dual union all
            select 'C123',            'Travel',    201,    100 from dual union all
            select 'C123',            'Travel',    203,    100 from dual union all
            select 'C124','Stationery',    315,    500 from dual union all
            select 'C126','Travel',    200,    600 from dual union all
            select 'C126','Admin',413,    600 from dual  )
            select * from t1)
            group by contractid,amount
            ) t;
    CONTRACTID         CM        CDM MM         MATERIALGROUP        COMMODITYCODE            AMOUNT MATERIALGROUP_EDIT   MATERIALGROUP_EDIT2
    C123                3          1 Travel     Travel|Travel|Travel 200|203|201                 100 Travel               Travel             
    C124                1          1 Stationery Stationery           315                         500 Stationery           Stationery         
    C126                2          2 Travel     Travel|Admin         200|413                     600 Travel|Admin         Travel|Admin       
    3 rows selected.
    select contractid,
              case when count(distinct materialgroup) = 1 and count(materialgroup) > 1 then max(materialgroup)
              else
              rtrim(
                          xmlagg(
                                  xmlelement(e, materialgroup|| '|')).extract('//text()'),'|') end materialgroup,
              rtrim(
                          xmlagg(
                                  xmlelement(e, commoditycode|| '|')).extract('//text()'),'|') commoditycode,amount
            from (
            with t1 as (
            select 'C123' contractid,    'Travel' materialgroup,     200    commoditycode, 100 amount from dual union all
            select 'C123',            'Travel',    201,    100 from dual union all
            select 'C123',            'Travel',    203,    100 from dual union all
            select 'C124','Stationery',    315,    500 from dual union all
            select 'C126','Travel',    200,    600 from dual union all
            select 'C126','Admin',413,    600 from dual  )
            select * from t1)
            group by contractid,amount;
    CONTRACTID MATERIALGROUP        COMMODITYCODE            AMOUNT
    C123       Travel               200|203|201                 100
    C124       Stationery           315                         500
    C126       Travel|Admin         200|413                     600
    3 rows selected.
    with t1 as (
            select 'C123' contractid,    'Travel' materialgroup,     200    commoditycode, 100 amount from dual union all
            select 'C123',            'Travel',    201,    100 from dual union all
            select 'C123',            'Travel',    203,    100 from dual union all
            select 'C124','Stationery',    315,    500 from dual union all
            select 'C126','Travel',    200,    600 from dual union all
            select 'C126','Admin',413,    600 from dual  ),
            t2 as
            select contractid, materialgroup
            from t1
            group by contractid, materialgroup
    select  t1.contractid,
              t2.materialgroup,
              rtrim(
                          xmlagg(
                                  xmlelement(e, commoditycode|| '|')).extract('//text()'),'|') commoditycode,amount
    from t1,
                    select contractid,
                                rtrim(
                                      xmlagg(
                                              xmlelement(e, materialgroup|| '|')).extract('//text()'),'|') materialgroup
                    from t2
                    group by contractid
                    ) t2
    where t1.contractid = t2.contractid
    group by t1.contractid, t2.materialgroup, t1.amount;
    CONTRACTID MATERIALGROUP        COMMODITYCODE            AMOUNT
    C123       Travel               200|203|201                 100
    C124       Stationery           315                         500
    C126       Admin|Travel         200|413                     600
    3 rows selected.

  • How to generate the following XML-Output?

    Hi all,
    I would like to generate the following XML-Output without defining any types or tables:
    <?xml version = '1.0'?>
    <DEPARTMENTS_EMPLOYEES>
    <DEPARTMENT NAME="ACCOUNTING">
    <DEPTNO>10</DEPTNO>
    <LOC>NEW YORK</LOC>
    <EMPLOYEES_OF_DEPARTMENT>
    <EMPNO>...</EMPNO>
    <ENAME>...</ENAME>
    </EMPLOYEES_OF_DEPARTMENT>
    </DEPARTMENT>
    <DEPARTMENT NAME="RESEARCH">
    <DEPTNO>20</DEPTNO>
    <LOC>DALLAS</LOC>
    <EMPLOYEES_OF_DEPARTMENT>
    </EMPLOYEES_OF_DEPARTMENT>
    </DEPARTMENT>
    </DEPARTMENTS_EMPLOYEES>
    Unfortunately the following SQL-Statement does not working:
    select xmlElement("DEPARTMENTS_EMPLOYEES",
    xmlAttributes(d.deptno as "DEPTNO"),
    xmlElement("DNAME", d.dname),
    xmlElement("LOC", d.loc),
    xmlElement("EMPLOYEES_OF_DEPARTMENT",
    (select xmlAgg(xmlElement("EMPLOYEE", xmlAttributes(e.empno as "EMPNO"), xmlForest(e.ename as "ENAME", e.job as "JOB", e.hiredate as "HIREDATE", e.sal as "SAL", e.comm as "COMM", m.empno as "MGRNO", m.ename as "MGRNAME" ) )
    from emp e, emp m
    where e.deptno = d.deptno
    and m.empno = e.mgr
    ) as XML
    from dept d;
    1. When I provide this statement with SQL*Plus
    (unfortunately 9.0.1.3.0) then I get the
    following output:
    XML()
    XMLTYPE()
    XMLTYPE()
    XMLTYPE()
    XMLTYPE()
    2. When I provide this statement with SQL Navigator
    4.3.0.456 then I get the following error:
    [1]: (Error): OCI-21560: argument 3 is null, invalid,
    or out of range
    3. When I execute the following PL/SQL-Code then I get
    the XML-Error message:
    DECLARE
    x CLOB;
    xmlstr VARCHAR2(32767);
    line VARCHAR2(2000);
    BEGIN
    x := dbms_xmlquery.getxml('select xmlElement("DEPARTMENT",
    xmlAttributes(d.deptno as "DEPTNO"),
    xmlElement("DNAME", d.dname),
    xmlElement("LOC", d.loc),
    xmlElement("EMPLOYEELIST",
    (select xmlAgg(xmlElement("EMPLOYEE",
    xmlAttributes(e.empno as "EMPNO"),
    xmlForest(e.ename as "ENAME",
    e.job as "JOB",
    e.hiredate as "HIREDATE",
    e.sal as "SAL",
    e.comm as "COMM",
    m.empno as "MGRNO",
    m.ename as "MGRNAME"
    from emp e, emp m
    where e.deptno = d.deptno
    and m.empno = e.mgr
    ) as XML
    from dept d');
    xmlstr := dbms_lob.SUBSTR(x,32767);
    LOOP
    EXIT WHEN xmlstr IS NULL;
    line := SUBSTR(xmlstr,1,INSTR(xmlstr,CHR(10))-1);
    DBMS_OUTPUT.PUT_LINE(line);
    xmlstr := SUBSTR(xmlstr,INSTR(xmlstr,CHR(10))+1);
    END LOOP;
    END;
    <?xml version = '1.0'?>
    <ERROR>oracle.xml.sql.OracleXMLSQLException: Unimplemented Feature</ERROR>
    4. When I provide the following PL/SQL-Code then I get the same xml-error:
    DECLARE
    x CLOB;
    xmlstr VARCHAR2(32767);
    line VARCHAR2(2000);
    BEGIN
    x := dbms_xmlquery.getxml('select xmlElement("SYSDATE", xmlElement("Datum", to_char(sysdate,''DD.MM.YYYY'')),
    xmlElement("Zeit", to_char(sysdate,''HH24:MI:SS''))) as XML
    from dual');
    xmlstr := dbms_lob.SUBSTR(x,32767);
    LOOP
    EXIT WHEN xmlstr IS NULL;
    line := SUBSTR(xmlstr,1,INSTR(xmlstr,CHR(10))-1);
    DBMS_OUTPUT.PUT_LINE(line);
    xmlstr := SUBSTR(xmlstr,INSTR(xmlstr,CHR(10))+1);
    END LOOP;
    END;
    <?xml version = '1.0'?>
    <ERROR>oracle.xml.sql.OracleXMLSQLException: Unimplemented Feature</ERROR>
    Can I generate the needed XML-Output from Database with SQL or PL/SQL?
    Can anybody help me?
    Regards
    Leonid Pavlov

    I have this done with:
    DECLARE
    qryCtx DBMS_XMLGEN.ctxHandle;
    result CLOB;
    xmlstr VARCHAR2(32767);
    line VARCHAR2(2000);
    BEGIN
    qryCtx := dbms_xmlquery.newContext('select deptno, dname, loc, cursor(select e.empno, e.ename, e.job,
    to_char(e.hiredate,''DD.MM.YYYY'') hiredate, e.sal, e.comm,
    m.empno MGRNO, m.ename MGRNAME
    from emp e, emp m
    where e.deptno = dept.deptno
    and m.empno(+) = e.mgr) emp
    from dept');
    dbms_xmlquery.useNullAttributeIndicator(qryCtx, FALSE);
    dbms_xmlquery.setRowsetTag(qryCtx, 'DEPARTMENTS_EMPLOYEES');
    dbms_xmlquery.setrowtag(qryCtx, 'DEPARTMENT');
    DBMS_XMLQuery.setRowIdAttrName(qryCtx, 'ID');
    DBMS_XMLQuery.setRowIdAttrValue(qryCtx, 'DEPTNO');
    -- dbms_xmlquery.setrowidattrname(qryCtx, NULL);
    result := dbms_xmlquery.getXML(qryCtx);
    DBMS_XMLQuery.closeContext(qryCtx);
    xmlstr := dbms_lob.SUBSTR(result,32767);
    LOOP
    EXIT WHEN xmlstr IS NULL;
    line := SUBSTR(xmlstr,1,INSTR(xmlstr,CHR(10))-1);
    DBMS_OUTPUT.PUT_LINE(line);
    xmlstr := SUBSTR(xmlstr,INSTR(xmlstr,CHR(10))+1);
    END LOOP;
    END;
    But how can I rename the <EMP>-Element to Employees?

  • How to get the return message after running BD20 tranaction ?

    Hi Gurus,
    My requirement is to Post vendor invoice through ALE/IDOC ( Inbound IDOC ).
    - For that I had generated the IDOC using  Function module 'IDOC_INBOUND_WRITE_TO_DB '
    - Then I had processed that generated IDOC by calling the standard program rbdapp01(BD20-Tranaction ) using the below statment
    SUBMIT rbdapp01 WITH SELECTION-TABLE lt_seltab .
    Could any one suggest me how to get the report output of standard program (rbdapp01) to an internal table so that I dispaly as an seperated report like Posted Document number with messages or Error message
    Suggest me any Function module or any other standard program to process the IDOC so that I can fulfill my requirement.
    Regards
    Paul

    Use can read the IDOC status after processing...
    Eg.
      SELECT * FROM edidc INTO TABLE t_idoc_control_tmp
          FOR ALL ENTRIES IN t_update WHERE docnum = t_update-docnum.
    and then add your own logic IF SY_SUBRC EQ 0.
    I hope this will help you.
    Regards,
    Amey

  • IPhone: How to get the original photo image with  Picker

    Hi!
    I'm trying to pick and send (via HTTP) the original image taken by the camera, the 1,600 x 1,2000 image that's available in iPhoto after syncing.
    As far as I gathered, the UIImage doesn't help me here, since it's scaled down to 640x480, probably to safe memory. But one should supposedly be able to access the underlying CIImage.
    Here's what I'm doing right now:
    I'm setting up an ImagePickerController in my
    - (void)viewDidLoad
    imagePickerController = [[UIImagePickerController alloc] init];
    imagePickerController.delegate = self;
    imagePickerController.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
    [self refreshView:self];
    and process the picked image with
    - (void)imagePickerController:(UIImagePickerController )picker didFinishPickingImage:(UIImage )image editingInfo:(NSDictionary )editingInfo
    CGImageRef imgRef = image.CGImage;
    CGFloat owidth = CGImageGetWidth(imgRef);
    CGFloat oheight = CGImageGetHeight(imgRef);
    NSLog(@"Original size = %f %f",owidth,oheight);
    NSData imageData = [NSData dataWithData: UIImagePNGRepresentation(image)];//(image, 1.0)
    However, I still get the following output:
    2008-07-25 11:44:58.543 myApplication[1564:20b] Original size = 640.000000 480.000000
    Obviously still scaled down - but there must be a way to access the original.
    What am I doing wrong?

    Yes, I'm trying on the iPhone, as the camera is unavailable on the simulator.
    Here is the code I'm using:
    // In my main code, to initialise the picker
    UIImagePickerController *picker;
    // Check if camera is available
    if ( ![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera] )
    UIAlertView *alertView = [[UIAlertView alloc]
    initWithTitle:@"Can't access camera" message:@"The camera is unavailable!" delegate:nil cancelButtonTitle:nil otherButtonTitles:@"OK", nil ];
    [alertView show];
    [alertView release];
    return;
    picker = [[UIImagePickerController alloc] init];
    picker.sourceType = UIImagePickerControllerSourceTypeCamera;
    picker.delegate = self;
    [_myView addSubview:picker.view];
    [_myView performSelectorOnMainThread:@selector(setNeedsDisplay) withObject:nil waitUntilDone:NO];
    // The delegate methods
    - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo
    NSLog( @"Image dimensions: %fx%f", image.size.width, image.size.height );
    // Remove the picker interface and release the picker object.
    [picker.view removeFromSuperview];
    [picker release];
    - (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
    // Remove the picker interface and release the picker object.
    [picker.view removeFromSuperview];
    [picker release];
    }

Maybe you are looking for