Need help to debug a function

Hi Folks,
Can somebody please point out the mistake in the following PL/SQL function
Environment: Oracle 10g (Rel 2)
Error Message:
SQL> show errors
Errors for FUNCTION SECTIONS_TAUGHT:
*13/3 PL/SQL: Statement ignored*
*13/7 PLS-00320: the declaration of the type of this expression is incomplete or malformed*
Code:
SET SERVEROUTPUT ON;
CREATE OR REPLACE FUNCTION sections_taught
*(i_instructor_id IN section.instructor_id%TYPE)*
RETURN VARCHAR2
AS
v_sections_taught     NUMBER;
v_status              VARCHAR2(100);
BEGIN
SELECT count()*
INTO v_sections_taught
FROM section
WHERE INSTRUCTOR_ID = i_instructor_id;
IF (v_sections_taught => 3)
THEN
v_status := 'Instructor: '||i_instructor_id ||' teaches '||v_sections_taught||' sections and needs a break';
ELSE
v_status := 'Instructor: '||i_instructor_id ||' teaches '||v_sections_taught||' sections';
END IF;
RETURN v_status;
EXCEPTION
WHEN OTHERS
THEN
v_status := 'There has been an error in the function !!!';
RETURN v_status;
END;
desc SECTION;
Name                                      Null?    Type
SECTION_ID                                NOT NULL NUMBER(8)
COURSE_NO                                 NOT NULL NUMBER(8)
SECTION_NO                                NOT NULL NUMBER(3)
START_DATE_TIME                                    DATE
LOCATION                                           VARCHAR2(50)
INSTRUCTOR_ID                             NOT NULL NUMBER(8)
CAPACITY                                           NUMBER(3)
CREATED_BY                                NOT NULL VARCHAR2(30)
CREATED_DATE                              NOT NULL DATE
MODIFIED_BY                               NOT NULL VARCHAR2(30)
MODIFIED_DATE                             NOT NULL DATE
Thanks in advance
rogers42

Hi,
Not that you asked, but:
All code should be formatted so that how it appears on the screen somehow reflects what is going on.
For example, in the code below, it's easy to tell
where the DECLARE, BEGIN and EXCEPTION sections start and end,
how many arguments there are,
what the datatype of each variable is
what the scope of the IF statement is
and so on.
This is especially helpful for soemone who is not familiar with your application, such as all the people on the forum who want to help you.
Beware of repetitions in your code. See if there's a better way to avoid them.
For example, depending on the value of v_sections_taught, you might assign two differnt things to v_status. Both of those things involve the same 5-way concatenation. The code below factors that common element out. If you ever want to cahnge that part of the message, you'll only have to change it in one place.
Beware of EXCEPTION WHEN OTHERS.
Normally, when a run-time error occurs, the program stops, and an error message with details about the exact error, and exactly where it occurred, is printed. If you put in you own exception handling mechanism,l you lose all of that. Think carefully about whether you really need to keep going, or if you need to know about the error and fix it.
Granted, sometimes the error messages aren't as accurate or detailed as we'd like, but they're always more informative than 'There has been an error in the function !!!'.
If you really, really must override the detfault error handling, try to make your own as informative as you can. SQLERRM is useful for that.
The code below incorporates the suggestions above:
CREATE OR REPLACE FUNCTION sections_taught
(      i_instructor_id        IN     section.instructor_id%TYPE
RETURN VARCHAR2
AS
     v_sections_taught NUMBER;
     v_status VARCHAR2(100);
BEGIN
     SELECT  count(*)
     INTO      v_sections_taught
     FROM     section
     WHERE     INSTRUCTOR_ID = i_instructor_id;
     v_status := 'Instructor: ' || i_instructor_id
                           || ' teaches '
                       || v_sections_taught
                       || ' sections';
     IF (v_sections_taught >= 3)
     THEN
          v_status := v_status || ' and needs a break';
     END IF;
     RETURN v_status;
EXCEPTION
     WHEN OTHERS
     THEN
          RETURN  'Error in sections_taught: ' || SQLERRM;
END;
/

Similar Messages

  • Need help in debugging vf03

    Hi,
    i need your help in debugging the vf03 tcode. the senariou is as follows.
    in vf03 when i enter the billing document no. and press enter and then when i click on parter push button on the application toolbar and then click on ship-to-party item then under the field tax juridiction cde which is refering to txjcd field of vbadr table im getting the value as TAXUSX instead of a 10 digit value which is present in txjcd field of kna1 table for that particular customer.
    and this is happening only for few invoice no's not for all.
    i think that some where the data is getting changed or not properly communicated for some invoice numbers.
    i need help for where to start tracing and how to debug this error out and the flow logic of debugging.
    waiting for ur reply
    regards,
    maqsood

    Hi kahan,
    frist you have check with your function consultant is there are mataing the TAX for that countary .
    and come to debug.
    easyt way is take that screen field name(patha pres F1 and technical attributes ) and program name screen name .
    then seach that field in that program screen put break-point at that level and run tranction.
    stil you facing any problem send more details i will try to help you.
    Do Reward points..if found helpful
    thaks,
    saleem

  • Need help in using sleep function in pl/sql

    Hi,
    need help:
    I have a condition where i want to validate total_pass=total_fail and
    I want to use the sleep function in a pl/sql where i want to wait for 2 minutes ie.checking
    whether total_pass=total_fail based upon class_id .
    I have the data in the table as:
    CLASS_ID TOT_PASS TOT_FAIL
    1 10 10
    2 5 4
    3 6 6
    4 7 5
    Any help will be needful for me

    I'm not quite sure what you are lookg for here, but whatever it is, your code as posted won't do it. You will never break out of the WHILE r_Class.Tot_Pass = r_Class.Tot_Fail loop, since these values will never change because you never get the next record form the cursor.
    From your original data, it looks like your cursor will return multiple rows which implies to me that you want to fetch the first row from the cursor, check if tot_pass = tot_fail, if they are equal, sleep for two minutes then get the next row. This does not make sense to me. Once the select in the cursor is executed, the data it returns will not change due to Oracle's read consistency model, so there seems to me no point in the sleep.
    The other alternative I can see is that you want to check all the returned rows, and if tot_pass = tot_fail for one of the rows (or possibly for all of the rows), then you want to sleep and try again.
    If you can explain in words what it is you are trying to accomplish, someone will be able to point you to a solution.
    John

  • Need Help in Replacement of Function Modules

    Hello all,
    I am working on Upgrade project from ECC 5.0 to ECC 6.0. I am facing problems for Replacement of two Obsolete Function Modules. Please give me a solution. FM's  are as follows.
    1) SET_AUTHORITY : This FM is obsolete in ECC 6.0 and there is not alternative FM present in help.sap.com or any other web portal.
    2) WS_QUERY : Here as per my knowledge we use class CL_GUI_FRONTEND_SERVICES and methods FILE_EXIST or DIRECTORY_EXIST as per the parameters in old FM. For parameter 'FS' we use 'FILE_EXIST' and 'DS' we use 'DIRECTORY EXIST'.
    But in our program prev. FM has parameter 'OS' i.e. Operating System.
    But there is not method called 'OS EXIST' or similar. Please suggest suitable method.
    Thanking you all in anticipation.
    Best Regards,
    Harish

    Hi Harish,
                       I too could not find any replacement for SET_AUTHORITY
    Obsolete Modules can be used in newer versions, but it is not supported by SAP in case of any technical issues.If you still need a replacement, you can replace it by the source code in the FM SET_AUTHORITY itself and modify according to your needs.
    Below is the source code of FM SET_AUTHORITY, so you can modify it according to your requirement.
      DATA: l_actvt  TYPE tact-actvt,
            l_hier   TYPE STANDARD TABLE OF sethier WITH HEADER LINE.
      CASE action.
        WHEN 'A    '.
          l_actvt = activity-add.
        WHEN 'C    '.
          l_actvt = activity-modify.
        WHEN 'D    '.
          l_actvt = activity-display.
        WHEN 'E    '.
          l_actvt = activity-delete.
        WHEN 'UD   '.
          l_actvt = activity-display.
      ENDCASE.
      CALL FUNCTION 'G_SET_TREE_IMPORT'
           EXPORTING
                no_descriptions  = 'X'
                no_rw_info       = 'X'
                setid            = set
                tabname          = table
                root_header_only = 'X'
           TABLES
                set_hierarchy    = l_hier
           EXCEPTIONS
                OTHERS           = 0.
      READ TABLE l_hier INDEX 1.
      IF sy-subrc <> 0.
        CLEAR l_hier.
        l_hier-shortname = set.
      ENDIF.
      CALL FUNCTION 'G_SET_AUTHORITY_CHECK'
           EXPORTING
                actvt  = l_actvt
                authgr = l_hier-authgr
           EXCEPTIONS
                OTHERS = 1.
      IF sy-subrc <> 0.
        CASE action.
          WHEN 'A    '.
            MESSAGE e827 WITH l_hier-shortname RAISING no_authority.
          WHEN 'C    '.
            MESSAGE e828 WITH l_hier-shortname RAISING no_authority.
          WHEN 'D    '.
            MESSAGE e829 WITH l_hier-shortname RAISING no_authority.
          WHEN 'E    '.
            MESSAGE e830 WITH l_hier-shortname RAISING no_authority.
          WHEN 'UD   '.
            MESSAGE e831 WITH l_hier-shortname RAISING no_authority.
        ENDCASE.
      ENDIF.
    If you need help in replacing in the above source code, please post your code here so that I can help you in modifying accordingly.
    Regards,
    Vasuki

  • Need help on Adhoc Request  functionality in PI

    Hi Experts ,
    Need help  on the design approach . How can PI handles  if Sender System prefers to send an  Adhoc Request(Outbound)  to PI  .
    Here is the complete requirement .
    " An Adhoc Request is send to PI from the Legacy Sender System (Whenever Legacy system has  Planned and unplanned shutdowns)  . Legacy system uses web client based request ( HTTP )  to PI . As soon as the  http request is received to  PI . PI needs provide back the information to Legacy System  "
    Note : PI needs to provide the Requested  data to Legacy system from the External Shared folders  . (Data content is stored in an .xml format in shared folders)
    I can see file adapter is one of the option which i can choose to connect to the external folders .
       How can i achieve the Adhoc Request  functionality ?  Needs advice and suggestions on this please ?
    Regards,
    Khan

    Hi Aziz - I don't think you should worry about "Ad hoc" here. It's nothing but a specific request from your sender application.
    Please refer to the scenario #8 SOAP- File and i assume it would be the same case with your interface.
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/80f96dbf-adca-3010-ffb5-daf2d1f0e276?QuickLink=index&…

  • Need help for IDOC inbound function module !

    Hi guys please help me to create a IDOC inbound function module.
    What are the parameters and tables.
    How to write the code.
    What it does.
    Please send me one inbound func module code if possuble
                                                                                  Thanks

    Hi,
    You need to create an inbound function module. Then define the process code in transaction we42 and attach the function module to this process code.
    In the function module you create you need to define tables of types EDIDC (Control record (IDoc)), EDIDD (Data record (IDoc)) and BDIDOCSTAT (ALE IDoc status (subset of all IDoc status fields)).
    Regards,
    Soumya.

  • I'm failing to get a Javascript to run in Firefox that runs great in IE...need help with debugging.

    I'm getting the error below but don't know what to do about it since I can't code Javascript. As I state before, IE runs this code just fine...I can't figure out why Firefox won't let it run. This cascading menu .js is just what I need for a charity website I'm helping to set up. The html portion is also shown below the .js
    Error: menu is undefined
    Source File: file:///C:/Documents%20and%20Settings/Ray/My%20Documents/ECCHS_Website/CascadeMenu.js
    Line: 8
    Here's the code for CascadeMenu.js
    <pre><nowiki> function InitMenu()
    var bar = menuBar.children
    for(var i=0;i < bar.length;i++)
    var menu=eval(bar[i].menu)
    menu.style.visibility = "hide"
    bar[i].onmouseover = new Function ("ShowMenu("+bar[i].id+")")
    var Items = menu.children
    for(var j=0; j<Items.length; j++)
    var menuItem = eval(Items[j].id)
    if(menuItem.menu != null)
    menuItem.innerHTML += "<Span Id="+menuItem.id+"_Arrow class='Arrow'>4</Span>"
    //var tmp = eval(menuItem.id+"_Arrow")
    // tmp.style.pixelLeft = menu.getBoundingClientRect().Right //- tmp.offsetWidth - 15
    FindSubMenu(menuItem.menu)}
    if(menuItem.cmd != null)
    menuItem.onclick = new Function("Do("+menuItem.id+")") }
    menuItem.onmouseover = new Function("highlight("+Items[j].id+")")
    function FindSubMenu(subMenu)
    var menu=eval(subMenu)
    var Items = menu.children
    for(var j=0; j<Items.length; j++)
    menu.style.visibility = "hidden"
    var menuItem = eval(Items[j].id)
    if(menuItem.menu!= null)
    menuItem.innerHTML += "<Span Id="+menuItem.id+"_Arrow class='Arrow'>4</Span>"
    // var tmp = eval(menuItem.id+"_Arrow")
    //tmp.style.pixelLeft = 35 //menuItem.getBoundingClientRect().right - tmp.offsetWidth - 15
    FindSubMenu(menuItem.menu)
    if(menuItem.cmd != null)
    menuItem.onclick = new Function("Do("+menuItem.id+")") }
    menuItem.onmouseover = new Function("highlight("+Items[j].id+")")
    function ShowMenu(obj)
    HideMenu(menuBar)
    var menu = eval(obj.menu)
    var bar = eval(obj.id)
    bar.className="barOver"
    menu.style.visibility = "visible"
    menu.style.pixelTop = obj.getBoundingClientRect().top + obj.offsetHeight + Bdy.scrollTop
    menu.style.pixelLeft = obj.getBoundingClientRect().left + Bdy.scrollLeft
    function highlight(obj)
    var PElement = eval(obj.parentElement.id)
    if(PElement.hasChildNodes() == true)
    { var Elements = PElement.children
    for(var i=0;i<Elements.length;i++)
    TE = eval(Elements[i].id)
    TE.className = "menuItem"
    obj.className="ItemMouseOver"
    window.defaultStatus = obj.title
    ShowSubMenu(obj)
    function Do(obj)
    var cmd = eval(obj).cmd
    window.navigate(cmd)
    function HideMenu(obj)
    if(obj.hasChildNodes()==true)
    var child = obj.children
    for(var j =0;j<child.length;j++)
    if (child[j].className=="barOver")
    {var bar = eval(child[j].id)
    bar.className="Bar"}
    if(child[j].menu != null)
    var childMenu = eval(child[j].menu)
    if(childMenu.hasChildNodes()==true)
    HideMenu(childMenu)
    childMenu.style.visibility = "hidden"
    function ShowSubMenu(obj)
    PMenu = eval(obj.parentElement.id)
    HideMenu(PMenu)
    if(obj.menu != null)
    var menu = eval(obj.menu)
    menu.style.visibility = "visible"
    menu.style.pixelTop = obj.getBoundingClientRect().top + Bdy.scrollTop
    menu.style.pixelLeft = obj.getBoundingClientRect().right + Bdy.scrollLeft
    if(menu.getBoundingClientRect().right > window.screen.availWidth )
    menu.style.pixelLeft = obj.getBoundingClientRect().left - menu.offsetWidth
    ///////////////////CascadedDropdown Menu/////////////////
    //Date : 08/09/2001 //
    //Version : 1.0 //
    //Author Mr.Arun N Kumar //
    //EMail: [email protected] //
    // Modifications on this code is not recomended
    // Suggestions are welcome
    <html>
    <head>
    <link href="CascadeMenu.css" rel="stylesheet">
    <script language="javascript" src="CascadeMenu.js">
    </script>
    </head>
    <body OnLoad="InitMenu()"
    Onclick="HideMenu(menuBar)" ID="Bdy"
    bgColor=aliceblue>
    <font color="#6B8174"><b> East Contra Costa
    Historical<br>Society Content Menus</b></font><div
    align="center">
    <DIV Id="menuBar" class="menuBar" >
    <DIV Id="Bar1" class="Bar" menu="menu1">Menu
    #1</DIV>
    <DIV Id="Bar2" class="Bar" menu="menu2">Menu
    #2</DIV>
    <DIV Id="Bar3" class="Bar" menu="menu3">Menu
    #3</DIV>
    <DIV Id="Bar4" class="Bar" menu="menu4">Menu
    #4</DIV></center>
    </DIV>
    <!--MenuItem Definition -->
    <div Id="menu1" class="menu" >
    <div Id="menuItem1_1" class="menuItem"
    menu="menu6">SubMenu
    #1</div>
    <div Id="menuItem1_2" class="menuItem"
    title="JavaScripts"
    cmd="http://javascript.internet.com/">JavaScript
    Source</div>
    <div Id="menuItem1_3" class="menuItem"
    title="WDVL"
    cmd="http://www.wdvl.com">WDVL</div>
    </div>
    <div Id="menu2" class="menu">
    <div Id="menuItem2_1" class="menuItem">Page
    #1</div>
    <div Id="menuItem2_2" class="menuItem">Page
    #2</div>
    <div Id="menuItem2_3" class="menuItem">Page
    #3</div>
    </div>
    <div Id="menu3" class="menu">
    <div Id="menuItem3_1" class="menuItem">Page
    #1</div>
    <div Id="menuItem3_2" class="menuItem">Page
    #2</div>
    <div Id="menuItem3_3" class="menuItem">Page
    #3</div>
    <div Id="menuItem3_4" class="menuItem"
    menu="menu5">SubMenu
    #4</div>
    </div>
    <div Id="menu4" class="menu">
    <div Id="menuItem4_1" class="menuItem">Page
    #1</div>
    <div Id="menuItem4_2" class="menuItem">Page
    #2</div>
    <div Id="menuItem4_3" class="menuItem">Page
    #3</div>
    <div Id="menuItem4_4" class="menuItem">Page
    #4</div>
    </div>
    <div id="menu5" class="menu">
    <div Id="menuItem5_1" class="menuItem">Page
    #4-1</div>
    <div Id="menuItem5_2" class="menuItem">Page
    #4-2</div>
    <div Id="menuItem5_3" class="menuItem">Page
    #4-3</div>
    </div>
    <div id="menu6" class="menu">
    <div Id="menuItem6_1" class="menuItem">Page
    #1-1</div>
    <div Id="menuItem6_2" class="menuItem">Page
    #1-2</div>
    <div Id="menuItem6_3" class="menuItem"
    menu="menu7">SubMenu
    #1-1</div>
    </div>
    <div id="menu7" class="menu">
    <div Id="menuItem7_1" class="menuItem">Page
    #1-1-1</div>
    <div Id="menuItem7_2" class="menuItem">Page
    #1-1-2</div>
    <div Id="menuItem7_3" class="menuItem">Page
    #1-1-3</div>
    </div><!-- End of Menu --><br>
    </body>
    </html></nowiki></pre>

    I found a download of Cascade Menu with files from 2001. I also found a discussion thread as of 2006 indicating problems with the script in Firefox as of that time ([http://www.webdeveloper.com/forum/archive/index.php/t-94019.html Menubar Script problem in FireFox [Archive] - WebDeveloper.com]). The web and web browsers have changed a lot during the past decade, so you might find it more efficient to get a new menu script than to fix this old one. (It might not even work in IE9 any more...)

  • Need help with user defined function

    Hello SDN,
    I need some help with a user-defined function. My source message contains multiple
    generic records (1000 char string), and my target message is 1 header record,
    then multiple generic records.  See description of source and target messages below:
    Source:
      GenericRecordTable 1..unbounded
        Row (1000 char string)
    Target:
      Field1 (char5)
      Field2 (char5)
      Field3 (char5)
      IT_Data
        GenericRecordTable 1..unbounded
          Row (1000 char string)
    Basically, what I need to do in my user defined funtion is to map the first record
    in my source record to the 3 header fields, then map all of the rest of the records
    (starting from line 2) into the GenericRecordTable.
    Can someone please help me with the code for the user defined function(s) for this
    mapping?
    Thank you.

    hi,
    Activities
    1. To create a new user-defined function, in the data-flow editor, choose Create New Function (This
    graphic is explained in the accompanying text), which is located on the lower left-hand side of the
    screen. In the menu, choose Simple Function or Advanced Function.
    2. In the window that appears, specify the attributes of the new function:
    Name
    Technical name of the function. The name is displayed in the function chooser and on the data-flow
    object.
    Description
    Description of how the function is used.
    Cache
    Function type (see above)
    Argument Count
    In this table, you specify the number of input values the function can process, and name them. All
    functions are of type String.
    3. In the window that appears, you can create Java source code:
    a. You can import Java packages to your methods from the Imports input field, by specifying them
    separated by a comma or semi-colon:
    You do not need to import the packages java.lang., java.util., java.io., and java.lang.reflect. since
    all message mappings require these packages and therefore import them. You should be able to
    access standard JDK and J2EE packages of the SAP Web Application Server by simply specifying the
    package under Import. In other words, you do not have to import it as an archive into the Integration
    Repository. You can also access classes of the SAP XML Toolkit, the SAP Java Connector, and the
    SAP Logging Service (see also: Runtime Environment (Java-Mappings)).
    In addition to the standard packages, you can also specify Java packages that you have imported as
    archives and that are located in the same, or in an underlying software component version as the
    message mapping.
    b. Create your Java source text in the editor window or copy source text from another editor.
    4. Confirm with Save and Close.
    5. User-defined functions are limited to the message mapping in which you created the function. To
    save the new function, save the message mapping.
    6. To test the function, use the test environment.
    The new function is now visible in the User-Defined function category. When you select this category,
    a corresponding button is displayed in the function chooser pushbutton bar. To edit, delete, or add the
    function to the data-flow editor, choose the arrow next to the button and select from the list box
    displayed.
    http://help.sap.com/saphelp_nw04/helpdata/en/d9/718e40496f6f1de10000000a1550b0/content.htm
    http://java.sun.com/j2se/1.5.0/docs/api/
    /people/krishna.moorthyp/blog/2006/07/29/documentation-html-editor-in-xi
    /people/sap.user72/blog/2006/02/06/xi-mapping-tool-exports
    http://help.sap.com/saphelp_nw04/helpdata/en/43/c4cdfc334824478090739c04c4a249/content.htm
    UDF -
    http://help.sap.com/saphelp_nw04/helpdata/en/22/e127f28b572243b4324879c6bf05a0/content.htm
    Regards

  • Need help in SQL (DENSE_RANK) function

    Hello All,
    I need the help in SQL.
    We have a table called status and the column are
    status_id number
    account_id number
    status_cd varchar2(10)
    created_id varchar2(10)
    created_by date
    and data is as follows
    insert into status values (1,101,'ENTER','ABC',to_date('21-JAN-2007 11:15:14','DD-MON-YYYY HH:MI:SS'));
    insert into status values (2,101,'REVIEW','DEF',to_date('21-JAN-2007 11:30:25','DD-MON-YYYY HH:MI:SS'));
    insert into status values (3,101,'APPROVE','GHI',to_date('21-JAN-2007 11:30:25','DD-MON-YYYY HH:MI:SS'));
    insert into status values (4,102,'ENTER','ABC',to_date('21-JAN-2007 11:18:14','DD-MON-YYYY HH:MI:SS'));
    insert into status values (5,102,'REVIEW','DEF',to_date('21-JAN-2007 11:33:25','DD-MON-YYYY HH:MI:SS'));
    insert into status values (6,102,'CANCEL','GHI',to_date('21-JAN-2007 11:33:25','DD-MON-YYYY HH:MI:SS'));
    insert into status values (7,103,'ENTER','ABC',to_date('21-JAN-2007 11:21:14','DD-MON-YYYY HH:MI:SS'));We have different status as follows
    1. ENTER
    2. REVIEW
    3. APPROVE
    4. CANCEL
    5. REJECT
    My requirement ..
    I need the max of created_id column for the status in ('APPROVE','CANCEL') and if there is no status in ('APPROVE','REVIEW') than it should be NULL.
    I wrote an SQL as
    select account_id,max(created_id) keep (dense_rank first order by decode(status_cd,'APPROVE',created_dt,'REVIEW',created_dt,NULL) DESC NULLS LAST,
          decode(status_cd,'APPROVE',status_id,'REVIEW',status_id,NULL) DESC NULLS LAST) last_app_rev_user
    from status
    group by account_id and gives me the output like
    ACCOUNT_ID LAST_APP_R
           101 GHI
           102 DEF
           103 ABCBut I want the Output like
    ACCOUNT_ID LAST_APP_R
           101 GHI
           102 DEF
           103 NULLAs the account 103 has no status called 'REVIEW' and 'APPROVE'
    My DB Version in 10.2.0.3.0.
    Hope I explain it properly. And if you have any other option without dense_rank still i will be happy.
    Thanks in advance for your help.
    AB
    null
    Message was edited by:
    AB

    instead of max(created_id) keep... use
    smth like max(case when status_cd in ('APPROVE','REVIEW') then created_id end) keep...

  • Need help in using replace function with special characters

    I have a column in a table where the data can contain ascii code for special characters such as an apostrophe.
    The data looks like this:
    CREEK&#39;S LANE
    ie for a street named CREEK'S LANE.
    I want to replace the ascii representation with the apostrophe and have the returned data show up as: CREEK's LANE
    When I try the query below I get prompted for substitution variable value.
    I don't seem to be able to find the right syntax to make this query work.
    SELECT REPLACE (street_name, '&#39;', '''')
    FROM
    streets WHERE street_id = 1
    Does anybody know how to do this?
    Any help would be much appreciated.
    Thanks.
    George

    george91 wrote:
    I have a column in a table where the data can contain ascii code for special characters such as an apostrophe.
    The data looks like this:
    CREEK'S LANE
    ie for a street named CREEK'S LANE.
    I want to replace the ascii representation with the apostrophe and have the returned data show up as: CREEK's LANE
    When I try the query below I get prompted for substitution variable value.
    I don't seem to be able to find the right syntax to make this query work.
    SELECT REPLACE (street_name, ''', '''')
    FROM
    streets WHERE street_id = 1
    Does anybody know how to do this?
    Any help would be much appreciated.
    Thanks.
    GeorgeHa! The codes you specified rendered in the HTML, but showed properly when I listed your original posting above. I didn't understand what you meant initially because the 5-character string represenation got rendered as the quote that you said you weren't able to get - a display problem.
    You're getting prompted for the substituon variable because of the ampersand; you appear to be doing this in SQL*PLUS. The first thing I would try is to SET DEFINE OFF when using the ampersands to see if that works. If That doesn't work check the docs to delmit the ampersand (I think its a backslash before it but can't remember offhand). Another, harder option might be to use the TRANSLATE function replacing the literal character instead of using REPLACE (though replacing a quote will be a little tricky). If you're on 10g also consider using the advanced quoting
    Good luck!
    Edited by: riedelme on May 22, 2009 12:45 PM

  • Need Help With Save As function Very Important

    i working on a project and i have to create a Save As function for it. When you click on Save As its supposed to open a dialog window where u can choose the where you would like to save the file and what you would like to name it. I know there is alot wrong with my code but i'm not sure on how to fix it so any and all help is greatly appreciated
    private void doSaveAs(){
              //display file dialog
              FileDialog fDialog2 = new FileDialog (this, "Save As...", FileDialog.SAVE);
              fDialog2.setVisible(true);
              //Set the file name chosen by user
              String name = fDialog2.getFile();
              // user canceled file selection, return without doing anything.
              if(name == null)
                   return;
              fileName = fDialog2.getDirectory() + name;
              // Try to create a file writer
              FileWriter writer = null;
              try{
                   writer = new FileWriter(fileName);
              } catch (IOException ioe){
                   MessageDialog dialog = new MessageDialog (this, "Error Message",
                             "Error writing the file: "+ioe.toString());
                   dialog.setVisible(true);
                   return;
              BufferedWriter bWriter = new BufferedWriter(writer);
              //Try to write the file
              StringBuffer textBuffer = new StringBuffer();
              try {
                   String textLine = bWriter.write(2);
                   while (textLine != null) {
                        textBuffer.append(textLine + '\n');
                        textLine = bWriter.write(name);
                   bWriter.close();
                   writer.close();
              } catch (IOException ioe){
                   MessageDialog dialog = new MessageDialog (this, "Error Message", "Error writing file: "+ioe.toString());
                   dialog.setVisible(true);
                   return;
         setTitle("JavaEdit " +name);     // reset frame title
         text.setText(textBuffer.toString());
    null

    And again with indentation
       private void doSaveAs(){
       //display file dialog
       FileDialog fDialog2 = new FileDialog (this, "Save As...",     
       FileDialog.SAVE);
          fDialog2.setVisible(true);
       //Set the file name chosen by user
       String name = fDialog2.getFile();
       // user canceled file selection, return without doing anything.
       if(name == null)
          return;
       fileName = fDialog2.getDirectory() + name;
       // Try to create a file writer
       FileWriter writer = null;
          try{
             writer = new FileWriter(fileName);
          } catch (IOException ioe){
          MessageDialog dialog = new MessageDialog (this, "Error Message", "Error writing the file: "+ioe.toString());
                dialog.setVisible(true);
                return;
       BufferedWriter bWriter = new BufferedWriter(writer);
       //Try to write the file
       StringBuffer textBuffer = new StringBuffer();
       try {
          String textLine = bWriter.write(2);
          while (textLine != null) {
             textBuffer.append(textLine + '\n');
             textLine = bWriter.write(name);
          bWriter.close();
          writer.close();
       } catch (IOException ioe){
          MessageDialog dialog = new MessageDialog (this, "Error Message", "Error writing file: "+ioe.toString());
          dialog.setVisible(true);
          return;
       setTitle("JavaEdit " +name); // reset frame title
       text.setText(textBuffer.toString());
    }

  • Need help using count over function

    I have the following query
    Select student_id, OM, TM, TP, count(rownum) over (order by OM desc) PS from
    (select
    er.student_id, sum(er.obtained_marks) OM, sum(ds.max_marks) TM,
    to_char(sum(er.obtained_marks)/sum(ds.max_marks)*100,'990.00') TP
    from
    tbl_exam_results er, tbl_date_sheet ds
    where
    ds.date_sheet_id = er.date_sheet_id and ds.class_id = 77 and ds.exam_id = 3 and ds.session_id = 1 group by er.student_id
    results in
    <div style="width: 889px"><div class="fielddata"><div>
    <div>STUDENT_ID OM TM TP PS
    1825 291 300 97.00 1
    3717 290 300 96.67 2
    2122 289 300 96.33 3
    3396 287 300 95.67{color:#ff6600} *5 &lt;--*{color}
    4554 287 300 95.67{color:#ff6600} *5 &lt;--*{color}
    1847 281 300 93.67 6
    1789 279 300 93.00 7
    5254 277 300 92.33 8
    1836 258 300 86.00 9
    4867 250 260 96.15 10
    1786 249 300 83.00 11
    4659 245 300 81.67 12
    1835 241 300 80.33 *{color:#ff6600}15 &lt;--{color}*
    1172 241 270 89.26*{color:#ff6600} 15 &lt;--{color}*
    3696 241 300 80.33 *{color:#ff6600}15 &lt;--{color}*
    3865 234 300 78.00 16
    5912 215 300 71.67 17
    5913 204 300 68.00 *{color:#ff6600}19 &lt;--{color}*
    3591 204 300 68.00 *{color:#ff6600}19 &lt;--{color}*
    1830 184 250 73.60 20
    </div>
    </div>
    </div>
    </div>
    <div style="width: 889px"><div class="fielddata"><div>
    But I want as following
    <div>STUDENT_ID OM TM TP PS
    1825 291 300 97.00 1
    3717 290 300 96.67 2
    2122 289 300 96.33 3
    3396 287 300 95.67 *{color:#ff6600}4 &lt;={color}*
    4554 287 300 95.67 *{color:#ff6600}4 &lt;={color}*
    1847 281 300 93.67 {color:#ff6600}5 the following entry{color}
    1789 279 300 93.00 6
    5254 277 300 92.33 7
    1836 258 300 86.00 8
    4867 250 260 96.15 9
    1786 249 300 83.00 10
    4659 245 300 81.67 11
    1835 241 300 80.33 {color:#ff6600}*12 &lt;=*{color}
    1172 241 270 89.26{color:#ff6600} *12 &lt;=*{color}
    3696 241 300 80.33 {color:#ff6600}*12 &lt;=*{color}
    3865 234 300 78.00{color:#ff6600} 13 the following entry{color}
    5912 215 300 71.67 14
    5913 204 300 68.00 *{color:#ff6600}15&lt;={color}*
    3591 204 300 68.00 *{color:#ff6600}15 &lt;={color}*
    1830 184 250 73.60 {color:#ff6600}16{color} {color:#ff6600}the following entry{color}
    </div>
    Thanks in advance for any help
    </div>
    </div>
    </div>
    <div style="width: 889px"></div>
    Edited by: sabir786 on Jan 14, 2009 4:13 AM
    Edited by: sabir786 on Jan 14, 2009 4:17 AM

    Since I do not understand at all what you are trying to do, I cannot correct your query, but I can explain the results.
    The analytic function is doing a running count of the number of records that have been outout so far. With no duplicates, this is somewhat clearer.
    SQL> WITH t AS (SELECT 1 om FROM dual UNION ALL
      2             SELECT 2 FROM dual UNION ALL
      3             SELECT 3 FROM dual UNION ALL
      4             SELECT 4 FROM dual UNION ALL
      5             SELECT 5 FROM dual)
      6  SELECT om, COUNT(rownum) OVER (ORDER BY om) ps
      7  FROM t;
            OM         PS
             1          1
             2          2
             3          3
             4          4
             5          5However, when you have duplicates, both duplicate values get the running count from the last of the duplicates (i.e. the highest running count). Here, I have duplicated 4 and see what I get:
    SQL> WITH t AS (SELECT 1 om FROM dual UNION ALL
      2             SELECT 2 FROM dual UNION ALL
      3             SELECT 3 FROM dual UNION ALL
      4             SELECT 4 FROM dual UNION ALL
      5             SELECT 4 FROM dual UNION ALL
      6             SELECT 5 FROM dual)
      7  SELECT om, COUNT(rownum) OVER (ORDER BY om) ps
      8  FROM t;
            OM         PS
             1          1
             2          2
             3          3
             4          5
             4          5
             5          6The "second" 4 record had a running count of 5 (i.e. it was the fifth record output), so both 4's get the same count. Changing the order by to descending shows the same effect, it just changes the running count:
    SQL> WITH t AS (SELECT 1 om FROM dual UNION ALL
      2             SELECT 2 FROM dual UNION ALL
      3             SELECT 3 FROM dual UNION ALL
      4             SELECT 4 FROM dual UNION ALL
      5             SELECT 4 FROM dual UNION ALL
      6             SELECT 5 FROM dual)
      7  SELECT om, COUNT(rownum) OVER (ORDER BY om DESC) ps
      8  FROM t;
            OM         PS
             5          1
             4          3
             4          3
             3          4
             2          5
             1          6John

  • Need help in OM.. function module

    Dear All,
    Do we have any standard function module which will give the list of persons who are all belong to the org unit...
    The input for the function module is the Org unit and the output for the function module should be the list of person belong to the org unit.
    Please help me to solve this issue...
    Thanks
    Ram

    Hi,
      Refer the theard
    https://forums.sdn.sap.com/click.jspa?searchID=13348704&messageID=3510249
    Regards
    Kiran Sure

  • Need help with an array function

    I'm using the array index function and i would like to be able to control what elements go out on it.  For example, if i wanted only the first element to go out, i don't want the second element to send out zero.  Is there any way i can control what elements leave the array index function.  I also don't understand what the index inputs do on that function either.  If anyone has any advice on the application or can modify it in any way, please help.
    Attachments:
    Array and for loop.vi ‏1190 KB

    The index inputs determine what elements are retrieved. For example of you would wire a 10 and a 20 to your two index inputs, you would bet element #10 and element #20 of your array. You can resize it to get any desired number of elements.
    If you don't wire the index inputs, you'll get the first two elements.
    If you only wire the top index input (e.g a 10), you'll get element #10 and #11.
    LabVIEW Champion . Do more with less code and in less time .

  • Need help using basic interger function

    I made a basic program to calculate the arrival of a trail, but the problem
    is that when i get the result of sum6 it comes out as 13.833333333333333.
    I just want to remove all the numbers after 13 for the printout answer?!?!!?!
    I know i have to use the "int" function to do this, but where & what do i put
    in my code to do that?
    thanks!!!!
    // DECLARE VARIABLES/DATA DICTIONARY
    double num1,num2, num3, num4 ; // Given numbers
    double sum1,sum2, sum3, sum4, sum5, sum6, sum7, sum8 ; // Intermediate, sum of num1, num2, and num3
    // READ IN GIVENS
    System.out.println ("Please enter hour value of start time: ");
    num1 = ITI1120.readDouble( );
    System.out.println ("Please enter minute value of start time: ");
    num2 = ITI1120.readDouble( );
    System.out.println ("Please enter the speed of train (in km per hour) : ");
    num3 = ITI1120.readDouble( );
    System.out.println ("Please enter travel distance (in km) : ");
    num4 = ITI1120.readDouble( );
    // BODY OF ALGORITHM
    sum1 = num1 * 60;
    sum2 = sum1 + num2;
    sum3 = num3 / 60;
    sum4 = num4 / sum3;
    sum5 = sum2 + sum4;
    sum6 = sum5 / 60;
    sum7 = sum6 * 60;
    // PRINT OUT RESULTS
    System.out.println("The hour value of the arrival time is: " + sum6);

    Which is easier to debug, your code with the generic variable names or this code:
        System.out.println ("Please enter hour value of start time: ");
        startHour = ITI1120.readDouble( );
        System.out.println ("Please enter minute value of start time: ");
        startMinutes = ITI1120.readDouble( );
        System.out.println ("Please enter the speed of train (in km per hour) : ");
        velocityKmPerHr = ITI1120.readDouble( );
        System.out.println ("Please enter travel distance (in km) : ");
        travelKm = ITI1120.readDouble( );
        startMinutesFromHours = startHour * MINUTES_PER_HOUR;
        totalMinutes = startMinutesFromHours + startMinutes;
        velocityKmPerMin = velocityKmPerHr / MINUTES_PER_HOUR;
        travelTimeMinutes = travelKm / velocityKmPerMin;
        arrivalTimeTotalMinutes = totalMinutes + travelTimeMinutes;
        arrivalTimeHours = (int)(arrivalTimeTotalMinutes / MINUTES_PER_HOUR);
        noIdeaWhyYoureCalculatingThis = arrivalTimeHours * MINUTES_PER_HOUR;?

Maybe you are looking for

  • Itunes told me to download and now i can't open itunes

    It told me to download version 7.1.1 and i did. Once i did that i restarted my computer and when i tried to open itunes it told me that the action is valid only when the product is installed. So i went back to itunes online and re-downloaded it. When

  • TS2446 How do you recover your Account after it was locked?

    I used my security Questions many times and now is locked. How do you unlock your Apple ID?

  • Front Row doesn't work on my Mac mini CoreDuo

    I can't start up FR: neither with the remote control neither with the keyboard (apple+esc). In console.log file can see this error every time I try to start up FR using the keyboard shortcut: Apr 17 10:07:04 Mac-mini loginwindow[70]: InitServerRemote

  • Bonjour printing error in console.log and cups error_log

    Hi everyone, I have a client who has been successfully printing to an HP LaserJet 4000 over his home LAN for some time now. However, this evening he was no longer able to print, with the print queue stopping immediately when he would try. iMac (Intel

  • TOP_OF_LIST

    CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'          EXPORTING               is_layout                  = WS_LAYOUT1               it_fieldcat                = INT_FIELDCAT[]               i_tabname                  = 'INT_FINAL'               it_eve