Passing hard-coded string parameters into a FUNCTION

I created a Function that accepts two INT and two VARCHAR2 parameters. I want to access it in a SELECT statement and manually pass in parameters to it.
For example,
SELECT FN_MYFUNC(10, 20, 'string1', 'string2') FROM DUAL;
However, when I do this the hard-coded strings don't seem to be recognized by the Function. But, if I were to pass in a Fieldname from a TABLE then the above function works. Is there something extra I need to do to pass in hard-coded strings into a function?

I have pasted the function where this problem is occuring below. If I use it in a SELECT, for example....
SELECT fn_GetRegValueFromRegData(3, 3, 'REG', '119') FROM DUAL;
.....it returns blank everytime when it should return a numeric value. However, this only occurs if I hard-code the parameter values (like above). However, if I pass in fieldnames from a TABLE, for example.....
SELECT fn_GetRegValueFromRegData(RegLink, EeLink, ChqType, RegCode) FROM RegData;
......then I get data back! Any idea why data is returned when I pass in fieldnames but not when I pass in hard-coded parameter values?
=================================================
CREATE OR REPLACE FUNCTION fn_GetRegValueFromRegData
(p_RegLink INT,
p_EELink INT,
p_ChequeType VARCHAR2,
p_RegCode1 VARCHAR2,
p_RegCode2 VARCHAR2 := '-1')
RETURN NUMBER
AS
v_regvalue NUMBER(14,5);
BEGIN
BEGIN
--retrieve data using the REGCODE1 value
SELECT a.regvalue INTO v_regvalue
FROM regdata a
WHERE a.RegCode = p_RegCode1
AND a.RegLink = p_RegLink
AND a.eeLink = p_EELink
AND a.ChqType = p_ChequeType
AND a.EndDate IS NULL;
EXCEPTION
WHEN OTHERS
THEN
--retrieve data using the REGCODE2 value
SELECT a.regvalue INTO v_regvalue
FROM regdata a
WHERE a.RegCode = p_RegCode2
AND a.RegLink = p_RegLink
AND a.eeLink = p_EELink
AND a.ChqType = p_ChequeType
AND a.EndDate IS NULL;
END;
RETURN v_regvalue;
END;
/

Similar Messages

  • Passing hard coded array to a method

    how to passing hard coded array to a method
    like method1("eee","eoe","eee",.....)
    which should populate a array of strings (say arr[]) for the method
    what can be done??

    or if you're using Java 5.0 declare the method aspublic void method(String... array) {
    }

  • Replacing hard-coded strings using Netbeans

    Hi
    Iam using Netbeans 4.0 to replace all the hard-coded string with resourceBundle.getString("...") and prepare the properties file. Thing is it picks all the contents within double quotes and replaces them.
    To avoid replacing all the entire strings, there is an option with name, Non-Internationalization format, using which we can specify the regular expression that can be used for filtering/ignoring the strings that falls under that regular expression.
    For example, if we use "System.out.println" in the regular expression, then the hard-coded strings within println statements are ignored and are not replaced, as one in interested only in translating user-interface strings and not debugging strings. The problem is, the utility searches for the specified word (System.out.println) and ignores the hard-coded string present in that line and replaces the strings in all the remaining lines in the println statement. I need the entire string in the println statement to be ignored and not replaced.
    Can anyone suggest me a solution to ignore the complete string in the println statement.
    Rgds
    Jagan

    Hello Tae,
    In your specific case, i'll go with your Dev Leader since the value returned by the method is not controlled inside the program. If sometime down the line the method returns '1' instead of 'X', if you use the CONSTANT you can change it in the declaration part without bothering about where it is used.
    But you should use meaningful names while defining your CONSTANTS for e.g., instead of C_X use C_TRUE.
    Also bear in mind all organisation data(e.g., Plant, Company Code, Controlling Area etc.) should be defined as CONSTANTS & not hard-coded. In these cases i prefer using the variant tables(TVARVC) to maintain the constants.
    I don't want to start a flame-war here, but imho although use of CONSTANTS increases the maintainability but too much usage of them reduces the readability. With all due respect to those "over diligent" QA reviewers AUTHORITY-OBJECT 'S_TCODE', ASSIGN COMPONENT 'MATNR' et al. are not hard-codes, please don't ask us to declare them as constants
    BR,
    Suhas
    PS: I remember there was an SDN blog on the same topic & it was definitely an interesting read.

  • Hard Coded Strings

    Hi All
    I want to eliminate the need for hard coded values in my code . for example when I set an attribute as
    setAttribute ("A", "This a good day")
    I want to eliminate "This a good day" from the code and replace it with something else more sophisticated to reduce the code maintenance in the future . Do you have any solution for that ?
    Thanks

    Hi,
    You can create your own messages in Application Developer Responsibility and then you can access those messages in OAF.
    suppose message name is XX_TEST
    so in the code use it like
    String msg = pageContext.getMessage("<application short name of message>","XX_TEST",null);
    then this variable you can use anywhere you want in the code.
    setAttribute("A",msg);
    Thanks,
    Gaurav

  • Passing a selected spry value into a function

    Should be relatively simple but i keep banging my head against the wall on this one.
    I have a Master Region that when clicked updates the detailregion below. For the 'View All' text below, is there a way to pass the current selected {name} value from the Master Region into a onlick function event for the static text 'view all'?
    <div id="current" class="currentcat" spry:detailregion="dsMainDept" spry:selected="{dsMainDept::name}">{name}</div>
    <div class="viewall" spry:detailregion="dsMainDept" onclick="FilterByDept('{name}')">view all</div>
    In this case, first div output {name} would change to match MasterRegion selected {name}. *The {name} is a selectable filter in the MasterRegion.* The 2nd div function would hold the currently selected {name} and when clicked, run the function that filters content based on that {name}.
    Can i target the 1st div id to look for this? or should use a RegionObserver? or change something in the FilterByDept function? I'm a little lost as to what best practice would be. Let me know if more code is needed.
    Thanks!

    instead of making your spry:select dynamic i suggest you use a static value instead something like
    spry:selected="selected";
    This will add the selected class to that clicked node. Now that you know what className it has, you can use SpryDOMUtls.js's CSS selector to get the right node from your list.
    For example:
    alert(Spry.$$('.selected')[0].innerHTML);
    hopes this helps

  • How to pass a Dynamic String value into a Form..???

    Hi all...,
    I'm trying to use a JSP to search "audios" stored in a "Audios" table & display the result list in another JSP. (This task was successful).
    Now I want to "Rate" these by taking the "Audio Name" as the key. My coding looks as follows...
    List myList = (List)request.getAttribute("SongList");
    Iterator itr = myList.iterator();
    while(itr.hasNext())
    String mySongName = (String)itr.next();
    out.println("<form name="SongRatingForm" action="ControllerServlet.java" method="post" >");
    out.println("<input type="What is the type here? (is there something like a LABEL)" name="MySongList" value="How can I insert 'mySongName' here">");
    out.println("</form>");
    Thanks in advance..,
    - Asela -

    Hi, please use the 'code' tags; select the text and click the code button when you're posting, it makes things easier to read.
    > out.println("<input type="What is the type here? (is
    there something like a LABEL)" name="MySongList"
    value="How can I insert 'mySongName' here">");
    Where do you want to print this? If it is to appear in a text-box, then the input type should be "text". If it is a button ( really?? ) it should be "button" or "submit" or "reset".
    If you just want the text to print, then you don't need to create and <input/> tag. Just print it out like
    <%=mySongName%>It could be the contents of a <td> of a <table>
    Or you could use a <label> tag:
    <label> <%=mySongName%></label>

  • SQL query - how to get parameters into a function within a SELECT statement

    Hi,
    I have SQL query roughly as follows
    SELECT A, B, C, MAX(CASE...) AS "D_NAME", FunctionX(B, C, "D_NAME")
    FROM...
    WHERE...
    How to get alias "D_NAME" as a valid parameter into FunctionX?

    Hi,
    user8819407 wrote:
    Hi,
    I have SQL query roughly as follows
    SELECT A, B, C, MAX(CASE...) AS "D_NAME", FunctionX(B, C, "D_NAME")
    FROM...
    WHERE...
    How to get alias "D_NAME" as a valid parameter into FunctionX?Either
    (1) repeat the calculation or
    (2) compute it in a sub-query
    Here's an example of (2)
    WITH  got_d_name  AS
        SELECT A, B, C, MAX(CASE...) AS "D_NAME"
        FROM...
        WHERE...
    SELECT  A, B, C, D_NAME, FunctionX (B, C, D_NAME)
    FROM    got_d_name
    ;A column alias (like d_name) can be referenced in the ORDER BY clause of the query where it was defined, but that's the only place in that query where it can be referenced.

  • Pass TestStand error type directly into function parameter

    Hi,
    I am using TestStand 4 and Labwindows CVI 8.5.
    I wonder if it is possible to pass Standard Step error type into CVI function parameters.
    I think it would be more simple to pass one parameter instead of passing Error code, Error occurred state and Error message into function prototype.
    I tried to use tsErrorDataType struct defined into tsutil.h into my function prototype.
    In TestStand, I pass Step error type into function parameter but it does not work.
    TestStand displays an error meaning parameters does not match function prototype.
    Thank you for your help.

    Hi Tartempion,
    In order to pass the TestStand Error Container as one parameter to a function in a CVI DLL, you must use a struct that is typedef'ed and create an .fp file that is included as a type library for the DLL. When you create a .fp file to add to a DLL, the DLL will not build unless all structs/enums are typedef'ed. Thus, I wouldn't advise using the tsutil.h because you would have to go through and typedef every single struct and enum in the header file.
    Instead, you can simply create a typedef'ed struct in your projects header file and create an .fp file with the struct specified as a data type. Then in TestStand, when you call the function you would need to ensure that the parameter is of Category "C Struct", and type "Error". The attached zip file contains a CVI 8.5 project that demonstrates this along with a TestStand 4.0 sequence file that demonstrates how to pass the parameter to the function by reference. In case you run into trouble creating the .fp file please refer to the following KnowledgeBase. The instructions are for enums but easily correspond to structs as well:
    TestStand and LabWindows/CVI Enumeration Data Types
    Hope this helps!
    Manooch H.
    National Instruments
    Attachments:
    PassTSError.zip ‏19 KB

  • Passing multiple events as parameters to functions

    I want to pass MouseEvent and a custom ComboSelectedEvent to
    a function. I really would like to do this:
    public function getPublications(event:MouseEvent,
    event:ComboSelectedEvent)
    But it doesn't work in Flex. To make it work, I ended up
    using the Event class, which includes all events:
    public function getPublications(event:Event)
    Is this the correct Flex way or is there a better way? Thanks
    for your help.

    You should be able to pass the two event objects into the
    function, but as Richard indicated, the two cannot have the same
    name within the method, and they don't need to either. Perhaps
    offer more details on your situation.

  • How can I send multiple string commands into a VISA write?

    Hi Fellow LabVIEW users
    I am very new to LabVIEW (2.5 months) so please forgive me if my lingo is not up to par.
    How can I send multiple string commands to a VISA write. For example each string command looks like this
    1) 3A00 0000 0000 FFFF FFFF FFFF 0000 0000 FF00 0000 0000 0000 0000 0033 (Scenario 1)
    2) 3A01 0000 0000 FFFF FFFF FFFF 0000 0000 FF00 0000 0000 0000 0000 0034 (Scenario 2)
    3) 3A01 0000 0000 33FF FFFF FFFF 0000 0000 FF00 0000 0000 0000 0000 0067 (Scenario 3).
    and so on and so forth. And there are a number of scenarios.
    Each String scenario will give a different string output which will be interpreted differently in the front panel.
    Right now I have to manually change the string commands on the front panel to give me the desired output. How can I do this without manually changing the commands i.e. hard coding each scenario into the block diagram?
    Thanks, any feedback will help.
    mhaque

    Please stick to your original post.

  • How can I pass a path to the FileReference upload function?

    i don't understand how can i upload a file from the browse
    function after you've selected a file. since FileReference.name
    returns
    only the filename w/extension and not the path, how can i
    work around this?
    i understand the security implications with a swf and the
    such, but what to do? and using an AIR app is not an option for me.
    i have a .net web service in place and it works with a hard
    coded string, such as in the snippet below, but how are people
    doing this by using the browse method as oppossed to a static
    string?
    i get an IO error with just the browse() returned filename,
    which makes sense when you think about it. path, path, path...ARGH!
    thanks folks...
    -fd

    i don't understand how can i upload a file from the browse
    function after you've selected a file. since FileReference.name
    returns
    only the filename w/extension and not the path, how can i
    work around this?
    i understand the security implications with a swf and the
    such, but what to do? and using an AIR app is not an option for me.
    i have a .net web service in place and it works with a hard
    coded string, such as in the snippet below, but how are people
    doing this by using the browse method as oppossed to a static
    string?
    i get an IO error with just the browse() returned filename,
    which makes sense when you think about it. path, path, path...ARGH!
    thanks folks...
    -fd

  • How to pass parameters into Function module : CLOI_PUT_SIGN_IN_FRONT

    Hello friends,
    I am displaying values ie, amounts in the screen using write statements here i have to display the
    sign left side , i am using  Function module   'CLOI_PUT_SIGN_IN_FRONT'    
    Does anybody help me - How to pass paramter into this Function module.
    Regards,
    Phaneendra

    If you look to the code of the function module, you can see it is condensing the value.
    I would make a copy of this function, and remove the condense lines to give the result you want.
      data: text1(1) type c.
      search value for '-'.
      if sy-subrc = 0 and sy-fdpos <> 0.
        split value at '-' into value text1.
        condense value.
        concatenate '-' value into value.
      else.
        condense value.
      endif.

  • Passing JSP into JavaScript function

    I have a database table containing a date for the end of an auction, I am able to successfully take the date from the database but I am having problems passing it and casting it to a date object within a javascript function. The purpose of the function is to begin a countdown to the passed in date. Any suggestions? The countdown function i have only works with a hard coded date object.
    <SCRIPT LANGUAGE="JavaScript1.2">
    mDate = new Date("October 18 2004")
    function countdown(){
    var now=new Date()
    var diff=mDate.getTime()-now.getTime()
    document.bid.days.value = Math.round(diff/(24*60*60*1000))
    document.bid.hours.value = Math.round(diff/(60*60*1000))
    document.bid.minutes.value = Math.round(diff/(60*1000))
    document.bid.seconds.value = Math.round(diff/1000)
    document.bid.mseconds.value = diff
    var id=setTimeout("millenium()",1)
    </SCRIPT>
    <body onLoad="countdown()">
    <form name="bid" method="post" action="">
    <p>Timeleft</p>
    <TABLE BORDER=0>
    <TD width="79">Days: </TD>
    <TD width="81">
    <INPUT TYPE="text" NAME="days" SIZE=15></TD> <TR>
    <TD width="79">Hours: </TD>
    <TD width="81">
    <INPUT TYPE="text" NAME="hours" SIZE=15></TD> <TR>
    <TD width="79">Minutes:</TD>
    <TD width="81">
    <INPUT TYPE="text" NAME="minutes" SIZE=15></TD> <TR>
    <TD width="79">Seconds: </TD>
    <TD width="81">
    <INPUT TYPE="text" NAME="seconds" SIZE=15></TD> <TR>
    <TD width="79">Milliseconds:</TD>
    <TD width="81">
    <INPUT TYPE="text" NAME="mseconds" SIZE=15></TD> <TR>
    </TABLE>
    </form>
    I wish to pass it as follows:
    <body onLoad="countdown(<%rsProduct.get........%>)"> and then cast within the function
    .............................................................................JSP.....................................................................................................
    <% Connection dbConn = null;
         try
              Class.forName("com.sybase.jdbc2.jdbc.SybDriver");
              dbConn = DriverManager.getConnection("jdbc:sybase:Tds:compserver:5000/syb3044","syb3044", "syb3044");
              Statement select = dbConn.createStatement();           
              int ID = Integer.parseInt(request.getParameter("carId"));
              ResultSet rsProduct = select.executeQuery("SELECT * FROM car WHERE carID =" + ID);
              if(rsProduct.next()){}
    <%
              rsProduct.close();
    catch (SQLException sqle)
              out.println(sqle.getMessage());     
    catch (ClassNotFoundException cnfe)
              out.println(cnfe.getMessage());
    catch (Exception e)
              out.println(e.getMessage());
    finally
              try
                   if(dbConn != null)
                        dbConn.close();
              catch (SQLException sqle)
                   out.println(sqle.getMessage());
         }%>
    PLEASE NOTE THAT I AM A SECOND YEAR COMPUTER SCIENCE STUDY!
    sorry if code is messy to read.
    Regards

    Looks like everyone's having a countdown problem.....
    The script in this thread is awefully like in this one:http://forum.java.sun.com/thread.jsp?forum=45&thread=514095&tstart=0&trange=15
    Anyway, there're what you can do. Write out the Date object in JSP as a Javascript Date, two ways to achieve that:
    1, mydate.getTimeStamp() is should return a long value, time in millisec, so
    var mDate = new Date(<%= myDate.getTimeStamp()%>);
    2. a lil messy, use DateFormatter to format the sql.Date, this gives you a Date in Strint form. Do remember the exact API for the DataFormater, but something like this.
    var mDate = new Date("<%= DateFormatter.format(myDate) %>");
    I'd prefer the 1st approach, why changing a Date to String then just change to Date again....Also watch out the TimeZone stuff and Daylight saving time....have fun.

  • How to pass a locale object into another function?

    Greetings,
    i like to pass a locale object into another function. These are my code below
    import java.util.*;
    public class Locales{
         public static void main(String[] args){
              Locale locale= new Locale("EN", "US");
              convert(locale);
    public void convert(Locale convert)
         String language = convert.getDisplayLanguage();
         System.out.println(language);          
    }I got this error:
    Locales.java:6: non-static method convert(java.util.Locale) cannot be referenced from a static content
                    convert(locale);
                    ^How do i correct it?
    Thanks

    Did you bother to do a search?
    Did you bother to read any of the material that the search would have linked you to?
    If you had then you would be able to understand where you are going wrong and how to fix it yourself. Instead of being spoonfed by us.

  • How to pass parameter into extract function (for XMLTYPE)

    I have a table PROBLEMXML with XMLTYPE field xml_column. In this column there are several deffinitions for the problem. There is no max amount of deffinitions and it can be no definition at all. I need to return all definitions for every problem as a string wirh definitions separated by ";".
    Query
    SELECT extract(prob.Def,'/Definitions/Definition[1]/@var') || ';'|| extract(prob.Def,'/Definitions/Definition[2]/@var')
    FROM PROBLEMXML j ,
    XMLTABLE (
    '/problem'
    PASSING j.xml_column
    COLUMNS probid VARCHAR (31) PATH '/problem/@id',
    Def XMLTYPE PATH '/problem/Definitions') prob
    where PROBLEM_ID =1;
    returns exactly what I want a;m.
    But
    declare
    my_var varchar2(2000) :=null;
    n1 number;
    n2 number;
    begin
    n1:=1;
    n2:=2;
    SELECT extract(prob.Def,'/Definitions/Definition[n1]/@var') || '|'|| extract(prob.Def,'/Definitions/Definition[n2]/@var') into my_var
    FROM ETL_PROBLEMXML_STG_T j ,
    XMLTABLE (
    '/problem'
    PASSING j.xml_column
    COLUMNS probid VARCHAR (31) PATH '/problem/@id',
    Def XMLTYPE PATH '/problem/Definitions') prob
    where PROBLEM_ID =1;
    dbms_output.put_line(my_var);
    end;
    returns NULL.
    Is there is a way to pass parameter into extract function?

    I need to return all definitions for every problem as a string wirh definitions separated by ";".In XQuery, there's the handy function "string-join" for that.
    For example :
    SQL> WITH etl_problemxml_stg_t AS (
      2   SELECT 1 problem_id,
      3  xmltype('<problem id="1">
      4   <Definitions>
      5    <Definition var="var1"></Definition>
      6    <Definition var="var2"></Definition>
      7    <Definition var="var3"></Definition>
      8   </Definitions>
      9  </problem>') xml_column
    10   FROM dual
    11  )
    12  SELECT j.problem_id,
    13         prob.probid,
    14         prob.def
    15  FROM etl_problemxml_stg_t j,
    16       XMLTable(
    17        'for $i in /problem
    18         return element r
    19         {
    20          $i/@id,
    21          element d { string-join($i/Definitions/Definition/@var, ";") }
    22         }'
    23        passing j.xml_column
    24        columns
    25         probid varchar2(30)  path '@id',
    26         def    varchar2(100) path 'd'
    27       ) prob
    28  ;
    PROBLEM_ID PROBID               DEF
             1 1                    var1;var2;var3

Maybe you are looking for