Help needed in writing a function.

I am using Oracle 11g and SQL plus. I am a complete newbie, so I need some help here in writing a function. I guess my question is more about writing the trigonometric functions within the function.
latA, longA latB, longB // these are the four input parameters,
theta = longA - longB
distX = sin( latA * PI / 180) * sin ( latB * PI /180) + cos ( latA * PI/180) * cos ( latB * PI/180) * cos ( theta * PI / 180)
distY = acos(distX) // this is arc cosine
distZ = distY * 180 / PI // PI refers to the mathematical PI
distP = distZ * 60 * 1.1515; // this value should be returned. Of course the intermediate variable names don't matter.
Please help. Thanks.

CREATE OR REPLACE FUNCTION fucntion_name(latA IN NUMBER, longA IN NUMBER, latB IN NUMBER, longB IN NUMBER) RETURN NUMBER
IS
pi      CONSTANT NUMBER:=3.14159;
theta NUMBER;
distX  NUMBER;
distY  NUMBER;
distZ  NUMBER;
distP  NUMBER;
BEGIN
theta :=longA - longB;
distX :=sin( latA * PI /180) * sin ( latB * PI /180) + cos ( latA * PI/180) * cos ( latB * PI/180) * cos ( theta * PI / 180);
distY :=acos(distX); --this is arc cosine
distZ :=distY * 180/PI;  --PI refers to the mathematical PI
distP :=distZ * 60 * 1.1515; --this value should be returned. Of course the intermediate variable names don't matter.
RETURN distP;
END;Edited by: Ora on May 3, 2011 11:46 PM

Similar Messages

  • Help needed for writing query

    help needed for writing query
    i have the following tables(with data) as mentioned below
    FK*-foregin key (SUBJECTS)
    FK**-foregin key (COMBINATION)
    1)SUBJECTS(table name)     
    SUB_ID(NUMBER) SUB_CODE(VARCHAR2) SUB_NAME (VARCHAR2)
    2           02           Computer Science
    3           03           Physics
    4           04           Chemistry
    5           05           Mathematics
    7           07           Commerce
    8           08           Computer Applications
    9           09           Biology
    2)COMBINATION
    COMB_ID(NUMBER) COMB_NAME(VARCHAR2) SUB_ID1(NUMBER(FK*)) SUB_ID2(NUMBER(FK*)) SUB_ID3(NUMBER(FK*)) SUBJ_ID4(NUMBER(FK*))
    383           S1      9           4           2           3
    384           S2      4           2           5           3
    ---------I actually designed the ABOVE table also like this
    3) a)COMBINATION
    COMB_ID(NUMBER) COMB_NAME(VARCHAR2)
    383           S1
    384           S2
    b)COMBINATION_DET
    COMBDET_ID(NUMBER) COMB_ID(FK**) SUB_ID(FK*)
    1               383          9
    2               383          4
    3               383          2
    4               383          3
    5               384          4
    6               384          2          
    7               384          5
    8               384          3
    Business rule: a combination consists of a maximum of 4 subjects (must contain)
    and the user is less relevant to a COMB_NAME(name of combinations) but user need
    the subjects contained in combinations
    i need the following output
    COMB_ID COMB_NAME SUBJECT1 SUBJECT2      SUBJECT3      SUBJECT4
    383     S1     Biology Chemistry      Computer Science Physics
    384     S2     Chemistry Computer Science Mathematics Physics
    or even this is enough(what i actually needed)
    COMB_ID     subjects
    383           Biology,Chemistry,Computer Science,Physics
    384           Chemistry,Computer Science,Mathematics,Physics
    you can use any of the COMBINATION table(either (2) or (3))
    and i want to know
    1)which design is good in this case
    (i think SUB_ID1,SUB_ID2,SUB_ID3,SUB_ID4 is not a
    good method to link with same table but if 4 subjects only(and must) comes
    detail table is not neccessary )
    now i am achieving the result by program-coding in C# after getting the rows from oracle
    i am using oracle 9i (also ODP.NET)
    i want to know how can i get the result in the stored procedure itsef.
    2)how it could be designed in any other way.
    any help/suggestion is welcome
    thanks for your time --Pradeesh

    Well I forgot the table-alias, here now with:
    SELECT C.COMB_ID
    , C.COMB_NAME
    , (SELECT SUB_NAME
    FROM SUBJECTS
    WHERE SUB_ID = C.SUB_ID1) AS SUBJECT_NAME1
    , (SELECT SUB_NAME
    FROM SUBJECTS
    WHERE SUB_ID = C.SUB_ID2) AS SUBJECT_NAME2
    , (SELECT SUB_NAME
    FROM SUBJECTS
    WHERE SUB_ID = C.SUB_ID3) AS SUBJECT_NAME3
    , (SELECT SUB_NAME
    FROM SUBJECTS
    WHERE SUB_ID = C.SUB_ID4) AS SUBJECT_NAME4
    FROM COMBINATION C;
    As you need exactly 4 subjects, the columns-solution is just fine I would say.

  • Help needed in building a function

    Hello,
    I am using Oracle DB 11g.
    I am writing a function.
    create or replace function func(tab VARCHAR2) RETURN VARCHAR2 AS
    cursor c is SELECT column_name
    FROM all_tab_columns
    WHERE table_name =tab;
    begin
    //some statements
    for i in c loop
    flag=1;
    //some statements
    end loop;
    //use the same c cursor query
    if flag!=1 then
    //repeat the block inside the for loop;
    end if;
    end;
    Function works fine.
    Now once the for loop ends,what i want is if it doesn't enter the for loop, then for just for once enter the if condition for
    any column from the table and repeat the process, which i am doing inside the for loop.
    But here i am finding repetition of same query and the block of code.
    Is there any way i can avoid that?
    Thanks

    How about you start from scratch and explain the business problem you are attempting to solve. Not a portion of a technical implementation that doesn't seem to make any sense.
    Start from the beginning, no code ... just "i have a situation where i need to .... ".
    Should be a lot more productive.

  • Help needed in writing query

    Hi,
    Could anyone help me in writing below query without syntax errors.
    I tried but no luck
    select xmlelement("g", XMLATTRIBUTES(g.contentgroup_id as "id",g.groupname as "label",
    (select xmlagg(xmlelement ("c",XMLATTRIBUTES(c.title as "title",c.content_id as "id")))) as "A"))
    as "A" from
    (SELECT g.contentgroup_id AS id, g.groupname AS label, c.title AS label, c.content_id AS id
    FROM content_ec c FULL OUTER JOIN contentgroup_ec g ON c.group_id = g.contentgroup_id
    oRDER BY g.groupname ,c.title ASC );
    Any help really appreciated.
    Thanks

    Few tips to get your question answered here
    1. Give your database version. Some thing that does not work in one version works fine in the next. And 8i,9i or 10g is not version. best way to give the version is to query your v$version table like this.
    SQL> select * from v$version where rownum = 1
      2  /
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod2. You should understand we don't have what you have, meaning you should provide your data structure and some sample data for us to help.
    3. "I got an error"... "Its not working"... and the list goes on. Sentences like this does not help. If you got a error past the entire error. If stuff does not work, tell us the details.
    4. Just don't throw some output and say i want it. Please explain to every one how you derive it.
    5. And the most important thing. Use \...\ tag to format. Please.. Please.. Please.. use it. It helps every one a lot. When you use it your SQL looks some thing like this.
    SELECT xmlelement("g", XMLATTRIBUTES(g.contentgroup_id as "id",g.groupname as "label",
         (select xmlagg(xmlelement ("c",XMLATTRIBUTES(c.title as "title",c.content_id as "id")))) as "A")) as "A"
       FROM (SELECT g.contentgroup_id AS id,
                 g.groupname AS label,
                 c.title AS label,
                 c.content_id AS id
            FROM content_ec c
            FULL OUTER JOIN contentgroup_ec g
              ON c.group_id = g.contentgroup_id
           ORDER BY g.groupname ,c.title ASC );6. And also do search this forum. Most of your my queries are answered by simple search.
    Thanks,
    Karthick.

  • Urgent help needed on writing errors in to windows application logs

    Hi all,
    we have web based application. Whenever there is critical errors encounters in our application we need to write that errors in to windows
    event viewer, application logs. Please help me on how to do this.
    do we have any specific API for this ?
    thanks in advance
    Shivakumar

    You should use WinAPI and followed functions: RegisterEventSource(), ReportEvent() and may be some more. It was some time ago as I deal with...

  • Help needed in OBIEE Rank function

    Hi All,
    I have a request having Period, Amount,Branch code. In this i need to figure out the top N ranks (N is the user input which is populated using Presentation variable) based on the amount.
    Then in the final output it should display as Top N branches with its previous period's data.
    For eg: If we try to rank the amount for period=31-dec-2010. The final output should be displayed in pivot table as
    *(Branchname in Pivottable section)*
    * (Period to be displayed columnwise) 31-Mar-2010 30-Jun-2010 30-Sep-2010 31-Dec-2010*
    Amount (Measure)
    Can you guide me to achieve the above request?
    Is there a way to calculate rank based on two columns?
    Kindly help me.
    Regards,
    Bhuvan R

    CREATE OR REPLACE FUNCTION fucntion_name(latA IN NUMBER, longA IN NUMBER, latB IN NUMBER, longB IN NUMBER) RETURN NUMBER
    IS
    pi      CONSTANT NUMBER:=3.14159;
    theta NUMBER;
    distX  NUMBER;
    distY  NUMBER;
    distZ  NUMBER;
    distP  NUMBER;
    BEGIN
    theta :=longA - longB;
    distX :=sin( latA * PI /180) * sin ( latB * PI /180) + cos ( latA * PI/180) * cos ( latB * PI/180) * cos ( theta * PI / 180);
    distY :=acos(distX); --this is arc cosine
    distZ :=distY * 180/PI;  --PI refers to the mathematical PI
    distP :=distZ * 60 * 1.1515; --this value should be returned. Of course the intermediate variable names don't matter.
    RETURN distP;
    END;Edited by: Ora on May 3, 2011 11:46 PM

  • Help needed  in writing a Query/Procedure

    Hello All,
    Need all ur help in writing a query or procedure
    Lets say the Table name is DEMO
    There i have one column like num it has values
    1
    2
    3
    4
    5
    8
    9
    10
    my query output should be
    1-5
    8-10
    i,e .. if the diff between two rows is greater than 1 then it result should be in a separate group
    I need a query/Procedure for this. Kindly help
    Regards,
    Chandra

    Tried obtaining the output using SQL and the result is as follows:
    SQL> WITH T AS
      2  (
      3  SELECT 1 COL1 FROM DUAL
      4  UNION
      5  SELECT 2 COL1 FROM DUAL
      6  UNION
      7  SELECT 3 COL1 FROM DUAL
      8  UNION
      9  SELECT 4 COL1 FROM DUAL
    10  UNION
    11  SELECT 5 COL1 FROM DUAL
    12  UNION
    13  SELECT 8 COL1 FROM DUAL
    14  UNION
    15  SELECT 9 COL1 FROM DUAL
    16  UNION
    17  SELECT 10 COL1 FROM DUAL
    18  UNION
    19  SELECT 13 COL1 FROM DUAL
    20  UNION
    21  SELECT 14 COL1 FROM DUAL
    22  UNION
    23  SELECT 15 COL1 FROM DUAL
    24  UNION
    25  SELECT 16 COL1 FROM DUAL
    26  UNION
    27  SELECT 23 COL1 FROM DUAL
    28  UNION
    29  SELECT 24 COL1 FROM DUAL
    30  )
    31  SELECT OUTPUT FROM
    32  (
    33  SELECT DECODE(COL3,NULL,COL1, COL2)  || '-' || LEAD(DECODE(COL3,NULL,COL3, COL1)) OVER (ORDER BY DECODE(COL3,NULL,COL1, COL2)) OUTPUT  FROM
    34  (
    35  SELECT COL1, LEAD(COL1) OVER (ORDER BY COL1) COL2, LAG(COL1) OVER (ORDER BY COL1) COL3 FROM T
    36  )
    37  WHERE
    38  (COL2 - COL1 > 1 OR COL2 IS NULL OR COL3 IS NULL)
    39  )
    40  WHERE OUTPUT != '-';
    OUTPUT                                                                         
    1-5                                                                            
    8-10                                                                           
    13-16                                                                          
    23-24

  • Very urgent help needed in activating a function module

    Hello experts.
    I had a standard report and i copied into an z report. i need to change some field output , and that field is there in a standard function module.so i copied that fun module  into z fun module and stored in a new fun group. Now it is showing the error in the z fun module. include in the fun module is giving the error stating that it is not existing. please help me in coping the standard fun module correctly . please its very urgent.

    Hi,
    You should not copy a Function module alone, as it will have some dependant INLCUDES and global data in TOP include of the function group.
    SO if you want the function module copy the entire Function Group into Z function group.
    Regards,
    Sesh

  • Help Needed With "Extend Marker" Function Not Working

    I have several Clips and used the "DV Start/Stop Detect" function to find the time code breaks, which seems to work well. I've now got a clip full of Segment markers.
    The problem arises when I try to use Extent Markers "Option + `" to make subclips. When I put the play head on a subsequent marker, the Marker/Extend function is grayed out.
    Extending a marker that I have created using the M key works perfectly.
    Why can I not use the Extend function on Segment Markers?
    Any help on this is greatly appreciated. I have 30 odd clips that I need to set up segments for, and doing it manually will add hours to my workload.
    Thanks
    Gary
    Dual G5 2.5 GHz Dual Core, 2.5 GB RAM, 500 GB HDD   Mac OS X (10.4.3)   Final Cut Studio FCP 5.0.4

    Thanks for the reply.
    I am completely aware of items 1 through 3, and never Extend markers in the Timeline. Only the Viewer.
    To perform an Extend Marker and avoid headaches, load the captured clip - the one with the video icon in the Browser - into the Viewer. Then, as you scrub along in the Viewer, Option-` as needed.
    That is precisely what I am doing.
    To Extend the marker I first double click the clip to load the entire clip into the Viewer, where all the Section markers are displayed. I then check Mark>Markers>Extend and the function is grayed out. However, if I move the playhead one frame prior to the Section marker, the previous Section marker extends to the frame prior to the new play head position.
    If I do this with manually entered markers (using the M key, creating Marker 1, 2, 3.... in sequence on the Viewer timeline), then the Previous marker is extended to the frame immediately prior the the current play head position - i.e. from Marker 1 to Marker 2. I do not have to move off the Marker 2 position to be able to extend Marker 1.
    Also, simply selecting all your Markers and either dragging them to another bin (or pressing Command-U) does not produce the needed subclips?
    Of this I am also aware. I find the Command-U process just confuses the issue, creating more clips to manage (others may disagree). I prefer to simply drag the "Subclips" directly from the Main clip into a Timeline.
    Because you're doing all this to get subclips, right? Or wrong?
    If I understand your reply correctly, I think you misunderstood my problem. I have been using subclips for several years, and find them VERY useful, especially with multi-camera shoots. So, I am quite familiar with creating and extending markers.
    I just started experimenting with the Detect feature and find it works quit well (most of the time). My problem is that the Segment markers created by the Detect process, do not perform the same as manually place markers, as far as the Extend marker function is concerned, anyway.
    BTW - By using the TC display in my Panasonic PV-GS400 Camera, and sending the FCP video via Firewire to the camera, the camera displays the TC on the captured clip, which I then rename the marker to for TC reference. As long as the Date/Time on the cameras are properly synced, syncing clips in the Timeline is a breeze!!
    Anyway, to clarify, my process is as follows:
    1. Capture a clip.
    2. Display the clip in the Viewer
    3. Select "DV Start/Stop Detect" and watch as the section markers appear in the Viewer.
    4. In Viewer, place play head on the first Section marker
    5. Press the M key to Edit Marker.
    6. Change the Name of the marker to the timecode of the Marker now displayed in the Camcorder window.
    7. Use Shift-Down Arrow to move to the next Section Marker
    8. Press Option+` to Extend the previous marker - which does not work and is grayed out in the Mark>Markers>Extend menu.
    9. Back to step 5.
    This process works perfectly with manually created markers. Because the Extend works if I move the play head one frame prior to the current Section marker, this tells me there is something "special" about the Section marker that disables the Extend function, unlike a manually created marker.
    BTW - If I delete the Section marker, and create a manual marker at the same frame, the Extend marker function works again. Again, indicating that Section markers are different somehow from manual Markers.
    Hopefully, this wordy explanation of my process clarifies my problem.
    Aside: The clips are supplied to me by a customer on a 500GB FW800 drive. FCP5 was used to capture the clips from the original Tapes (which I do not have access to). I am the editor for the project.
    Thanks again for the reply. It is greatly appreciated. If there is any other info that I have missed that will help figure this out, please let me know and I will post a response a quickly as possible.
    Gary

  • Help needed in writing SQL CASE or DECODE statement

    Hi experts,
    I need to write a SQL to select order_num, cntry_cde, prod_id and Qty by joining order_num on PROD_ORDER and PROD_ORDER_TXT.
    Here is my sample data
    PRODORDER_               
    order_num     cntry_cde     Prod_id     Qty
    100     US     A1     5
    101     US     A2     10
    102     AU     A3     4
    103     AU     A4     9
    104     IN     A5     3
    PRODORDER_TXT_               
    order_num     cntry_cde     Prod_id     
    100     US     A1     
    101     US     A2     
    102     NZ     A3     
    103     AU     A4     
    104          A5     
    Here is the requirement,
    1) If the cntry_cde in PROD_ORDER is same as cntry_cde in PROD_ORDER_TXT then select PROD_ORDER.cntry_cde (orders 100, 101, 103)
    2) If they are different, pick the country code from PROD_ORDER_TXT (order 102, AU <> NZ)
    3) If they are different and PROD_ORDER_TXT.cntry_cde is NULL, I cannot use it as cntry_cde in my report (order 104). It happenend just because of the bad data at source.
    I cannot avoid it. Then simply use the cntry_cde from PROD_ORDER
    Output expected
    100     US     A1     5
    101     US     A2     10
    102     NZ     A3     4 -- AU changed to NZ
    103     AU     A4     9
    104     IN     A5     3 -- IN retained as PROD_ORDER_TXT.cntry_cde is null
    sample table creation and insert statements are below
    create table prod_order
    (order_num number,
    cntry_cde CHAR(2),
    prod_id VARCHAR2(6),
    qty number)
    create table prod_order_txt
    (order_num number,
    cntry_cde CHAR(2),
    prod_id VARCHAR2(6))
    insert into prod_order values (100, 'US', 'A1',5);
    insert into prod_order values (101, 'US', 'A2',1);
    insert into prod_order values (102, 'AU', 'A3',4);
    insert into prod_order values (103, 'AU', 'A4',9);
    insert into prod_order values (104, 'IN', 'A5',3);
    insert into prod_order_txt values (100,'US','A1');
    insert into prod_order_txt values (101,'US','A2');
    insert into prod_order_txt values (102,'NZ','A3');
    insert into prod_order_txt values (103,'AU','A4');
    insert into prod_order_txt values (104,NULL,'A5');
    commit;
    Thanks for your help in advance
    Edited by: sarvan on Mar 28, 2012 1:39 PM

    Hello
    Thank you for posting all of the ddl and test data along with your expected output - very helpful!. One small point would be to remember to type {noformat}{noformat} before and after any section of code or data in your post so that formatting is retained.  Anyway, this should be a simple join and a combination of CASE and NVL...Select
    po.order_num,
    CASE
    WHEN po.cntry_cde != NVL(pot.cntry_cde,po.cntry_cde)
    THEN
    pot.cntry_cde
    ELSE
    po.cntry_cde
    END cntry_code,
    po.prod_id,
    po.qty
    FROM
    prod_order po
    JOIN
    prod_order_txt pot
    ON
    ( po.order_num = pot.order_num
    ORDER_NUM CN PROD_I QTY
    100 US A1 5
    101 US A2 1
    102 NZ A3 4
    103 AU A4 9
    104 IN A5 3
    5 rows selected.
    HTH
    David
    Edited by: Bravid on Mar 28, 2012 8:32 AM
    corrected !=                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Urgent help needed on writing errors in to windows events application logs

    Hi all,
    we have web based application. Whenever there is critical errors encounters in our application we need to write that errors in to windows
    event viewer, application logs. Please help me on how to do this.
    do we have any specific API for this ?
    thanks in advance
    Shivakumar

    You should use WinAPI to do so. Asking in JNI forum (or specialized WinAPI forum) for more details is good idea I think.

  • Help needed in writing a query

    Hi all,
    Following is the structure of my table.
    Data
    Key Number
    Id Number
    Value varchar2(100)
    activity_name varchar2(100)
    Creation_Date Date
    Eval_Point varchar2(100)
    In the above table Id is the primary key.
    The column eval_point holds only two types of entries 'activation' or 'completion'
    The activity_name column holds the name of the activity.
    The sample entries in the table are as follows
    Key Value activity_name Creation_Date Id Eval_Point
    260002 XXX assign_1 2007-09-21 16:58:41.920000 951 activation
    260002     XXX assign_1 2007-09-21 16:58:43.392000 953     completion
    260002     XXX assign_2 2007-09-21 16:59:03.732000 956     activation
    260002     XXX assign_2 2007-09-21 16:59:04.112000 954     completion
    260002     XXX assign_3 2007-09-21 16:59:24.331000     958     activation
    260002     XXX assign_3 2007-09-21 16:59:24.421000     957     completion
    i need to write a query which gives me data in the following format
    value id start_date end_date
    XXX YYY 2007-09-21 16:58:41.920000 2007-09-21 16:58:43.392000
    where start_date is the creation date of the 'activation' and end_date is the creation_date of 'completion'.
    Can somebody help?
    -thanks
    lavanya

    hello all,
    I would like to re frame my question.
    this is the output of the base query
    select id,instance_key,sensor_target,activity_sensor,creation_date,eval_point from bpel_variable_sensor_values where instance_key=260002;
    953     260002     Assign_1     952     2007-09-21 16:58:43.392000     completion
    951     260002     Assign_1     952     2007-09-21 16:58:41.920000     activation
    956     260002     Assign_2     955     2007-09-21 16:59:03.732000     activation
    954     260002     Assign_2     955     2007-09-21 16:59:04.112000     completion
    958     260002     Assign_3     959     2007-09-21 16:59:24.331000     activation
    957     260002     Assign_3     959     2007-09-21 16:59:24.421000     completion
    962     260002     Assign_4     960     2007-09-21 16:59:44.741000     completion
    961     260002     Assign_4     960     2007-09-21 16:59:44.640000     activation
    964     260002     Assign_5     965     2007-09-21 17:00:05.290000     completion
    963     260002     Assign_5     965     2007-09-21 17:00:04.950000     activation
    I am trying out this query
    select a.instance_key,a.creation_date,b.creation_date,a.id
    from bpel_variable_sensor_values a, bpel_variable_sensor_values b
    where a.instance_key=b.instance_key
    and a.instance_key=260002
    and a.eval_point='activation'
    and b.eval_point='completion'
    and i am getting 25 entries i.e a cartesian product of a.creation_date
    260002     2007-09-21 16:58:41.920000     2007-09-21 16:58:43.392000     951
    260002     2007-09-21 16:58:41.920000     2007-09-21 16:59:04.112000     951
    260002     2007-09-21 16:58:41.920000     2007-09-21 16:59:24.421000     951
    260002     2007-09-21 16:58:41.920000     2007-09-21 16:59:44.741000     951
    260002     2007-09-21 16:58:41.920000     2007-09-21 17:00:05.290000     951
    260002     2007-09-21 16:59:03.732000     2007-09-21 16:58:43.392000     956
    260002     2007-09-21 16:59:03.732000     2007-09-21 16:59:04.112000     956
    260002     2007-09-21 16:59:03.732000     2007-09-21 16:59:24.421000     956
    260002     2007-09-21 16:59:03.732000     2007-09-21 16:59:44.741000     956
    260002     2007-09-21 16:59:03.732000     2007-09-21 17:00:05.290000     956
    260002     2007-09-21 16:59:24.331000     2007-09-21 16:58:43.392000     958
    260002     2007-09-21 16:59:24.331000     2007-09-21 16:59:04.112000     958
    260002     2007-09-21 16:59:24.331000     2007-09-21 16:59:24.421000     958
    260002     2007-09-21 16:59:24.331000     2007-09-21 16:59:44.741000     958
    260002     2007-09-21 16:59:24.331000     2007-09-21 17:00:05.290000     958
    260002     2007-09-21 16:59:44.640000     2007-09-21 16:58:43.392000     961
    260002     2007-09-21 16:59:44.640000     2007-09-21 16:59:04.112000     961
    260002     2007-09-21 16:59:44.640000     2007-09-21 16:59:24.421000     961
    260002     2007-09-21 16:59:44.640000     2007-09-21 16:59:44.741000     961
    260002     2007-09-21 16:59:44.640000     2007-09-21 17:00:05.290000     961
    260002     2007-09-21 17:00:04.950000     2007-09-21 16:58:43.392000     963
    260002     2007-09-21 17:00:04.950000     2007-09-21 16:59:04.112000     963
    260002     2007-09-21 17:00:04.950000     2007-09-21 16:59:24.421000     963
    260002     2007-09-21 17:00:04.950000     2007-09-21 16:59:44.741000     963
    260002     2007-09-21 17:00:04.950000     2007-09-21 17:00:05.290000     963
    can soembody help me to reduce these to 5 rows.

  • Help needed in writing a small piece of ABAP Code

    Subject : look up in an ODS and update in a characteristic routine (BI 7.0)  
    Hi ,
    My requirement is : I have data coming from both legacy as well as SAP Systems. The user wants both legacy as well as SAP fields data in their reports.
    I have a Standard DSO ( say DSO1) with all the legacy fields with direct mappings from Legacy sytem along with couple of SAP fields which are not mapped as of now.
    I have few more DSO's which have just the legacy field and corresponding SAP field data.
    like DSO 2 with ZCOMPCODE and 0COMPCODE data.
    All i have to do is write a Routine for unmapped 0COMPCODE field in DSO1 that pulls up corrersponding 0COMPCODE values for ZCOMPCODE from DSO 2 .
    *Could someone please help me with the Coding part of the Routine.*
    Greatly appreciate your help.

    CREATE OR REPLACE FUNCTION fucntion_name(latA IN NUMBER, longA IN NUMBER, latB IN NUMBER, longB IN NUMBER) RETURN NUMBER
    IS
    pi      CONSTANT NUMBER:=3.14159;
    theta NUMBER;
    distX  NUMBER;
    distY  NUMBER;
    distZ  NUMBER;
    distP  NUMBER;
    BEGIN
    theta :=longA - longB;
    distX :=sin( latA * PI /180) * sin ( latB * PI /180) + cos ( latA * PI/180) * cos ( latB * PI/180) * cos ( theta * PI / 180);
    distY :=acos(distX); --this is arc cosine
    distZ :=distY * 180/PI;  --PI refers to the mathematical PI
    distP :=distZ * 60 * 1.1515; --this value should be returned. Of course the intermediate variable names don't matter.
    RETURN distP;
    END;Edited by: Ora on May 3, 2011 11:46 PM

  • Help needed in writing installers for swing application

    Hi ,
    I want to write an installer for one of our home grown profiler tool. I need to write the installer for different platforms such as windows,linux,solaris,HP-UX.
    Does anybody have any idea of how to go ahead in writing installations. Share if there is any good links such as tutorials as well is thr any opensource tool (similar to installsheild) to write installers . As well following is the tentative algorithm for my install sheild
    1. Create a home dir for the tool and put all the application files in tht.
    2. Installing a 3rd party jar and make a home for it.
    3. Option for user to select the features(i hv 2 features. user can either select both or select individual feature) to be installed.
    4. Select the appserver home if any. On selection i hv to update the classpath in the startup batch file for the application(This is the toughest step i beleive bcoz each appserver have different folder structures and different startup batch files).

    Tried obtaining the output using SQL and the result is as follows:
    SQL> WITH T AS
      2  (
      3  SELECT 1 COL1 FROM DUAL
      4  UNION
      5  SELECT 2 COL1 FROM DUAL
      6  UNION
      7  SELECT 3 COL1 FROM DUAL
      8  UNION
      9  SELECT 4 COL1 FROM DUAL
    10  UNION
    11  SELECT 5 COL1 FROM DUAL
    12  UNION
    13  SELECT 8 COL1 FROM DUAL
    14  UNION
    15  SELECT 9 COL1 FROM DUAL
    16  UNION
    17  SELECT 10 COL1 FROM DUAL
    18  UNION
    19  SELECT 13 COL1 FROM DUAL
    20  UNION
    21  SELECT 14 COL1 FROM DUAL
    22  UNION
    23  SELECT 15 COL1 FROM DUAL
    24  UNION
    25  SELECT 16 COL1 FROM DUAL
    26  UNION
    27  SELECT 23 COL1 FROM DUAL
    28  UNION
    29  SELECT 24 COL1 FROM DUAL
    30  )
    31  SELECT OUTPUT FROM
    32  (
    33  SELECT DECODE(COL3,NULL,COL1, COL2)  || '-' || LEAD(DECODE(COL3,NULL,COL3, COL1)) OVER (ORDER BY DECODE(COL3,NULL,COL1, COL2)) OUTPUT  FROM
    34  (
    35  SELECT COL1, LEAD(COL1) OVER (ORDER BY COL1) COL2, LAG(COL1) OVER (ORDER BY COL1) COL3 FROM T
    36  )
    37  WHERE
    38  (COL2 - COL1 > 1 OR COL2 IS NULL OR COL3 IS NULL)
    39  )
    40  WHERE OUTPUT != '-';
    OUTPUT                                                                         
    1-5                                                                            
    8-10                                                                           
    13-16                                                                          
    23-24

  • Help needed in writing a procedure

    Guys, i need some more help.
    I am selecting one value using select by passing a parameter to that select statement which are stored in a file using utl_file package.
    Now, I want to use the output of that query and use that value to update a column in the same table.
    for ex:-
    select comm from emp where empno = &empno1;
    I want to use the comm value and update the comm value.
    update emp
    set comm = comm + 10
    where empno = &empno1
    Help Appreciated
    Thanks

    SQL> desc emp
    Name Null? Type
    EMPLOYEE_ID NOT NULL NUMBER(6)
    FIRST_NAME VARCHAR2(20)
    LAST_NAME NOT NULL VARCHAR2(25)
    EMAIL NOT NULL VARCHAR2(25)
    PHONE_NUMBER VARCHAR2(20)
    HIRE_DATE NOT NULL DATE
    JOB_ID NOT NULL VARCHAR2(10)
    SALARY NUMBER(8,2)
    COMMISSION_PCT NUMBER(2,2)
    MANAGER_ID NUMBER(6)
    DEPARTMENT_ID NUMBER(4)
    NET_SALARY NUMBER(12,2)
    SQL> select salary,COMMISSION_PCT,net_salary from emp where employee_id = 198;
    SALARY COMMISSION_PCT NET_SALARY
    2600 .1
    SQL> update emp
    2 set net_salary = salary + (select COMMISSION_PCT from emp where employee_id = &&empno)*salary
    3 where employee_id = &&empno
    4 /
    Enter value for empno: 198
    old 2: set net_salary = salary + (select COMMISSION_PCT from emp where employee_id = &&empno)*salary
    new 2: set net_salary = salary + (select COMMISSION_PCT from emp where employee_id = 198)*salary
    old 3: where employee_id = &&empno
    new 3: where employee_id = 198
    1 row updated.
    SQL> select salary,COMMISSION_PCT,net_salary from emp where employee_id = 198;
    SALARY COMMISSION_PCT NET_SALARY
    2600 .1 2860
    Hope this helps;

Maybe you are looking for

  • How To Get Value PRD No TO Work Center NAME

    Hi Guru i created Zreport  the Parameter are P_AUFNR TYPE AFKO-AUFNR OBLIGATORY  ,                                                            P_ARBPL TYPE S022-ARBPL OBLIGATORY . Currently i am doing i enter any Production Order No  and Work Center a

  • I want to delete the "other" off my phone

    It has come to my attention the there is more space that is being taken up on my phone by "other" than the amount of space that I'm actually using. It is taking 6.01 GB of my space and I'm getting sick and tired of having my phone tell me I don't hav

  • Sharing files online

    Hi I have a simple requirement but all the online tutorials I have found don't seem to offer much help for Lion. I just want to use my new MacBook Pro to host a basic fileserver in order to transfer some large files over the internet. It seems that i

  • Re:  I've Lost my Catalog!

    I'm hoping someone may be able to help .... I have been backing up all my files (documents/music/photos) onto my new external hard-drive.  I moved the Lightroom Back-up folder (which took ages!) and subsequently discovered (to my horror) my entire ca

  • From an old hard drive to a new hard drive

    I am trying to put my iTunes library from a 300 gig hard drive to a 1 TB hard drive. Before I wipe out over 12000 songs from the 300 gig hard drive, is there a simple way to transfer my library to the 1 TB hard drive and have iTunes to successfully b