Pass SQL into a Function

Is it possible to pass a SQL into a Function
DECLARE
   f        sys_refcursor;
   RESULT   NUMBER;
   FUNCTION myfunction (r sys_refcursor)
      RETURN NUMBER
   IS
   BEGIN
      RETURN TO_NUMBER (TO_CHAR (r.dt, 'DD'));
   END;
BEGIN
   OPEN f FOR
      SELECT SYSDATE dt
        FROM DUAL;
   RESULT := myfunction (f);
   CLOSE f;
END;

Yes you are allowed to pass ref cursor but they have to processed the way you processur cursor i.e. OPEN, FETCH, CLOSE.
See demonostration of working code:
SQL>DECLARE
  2     f        sys_refcursor;
  3     RESULT   NUMBER;
  4
  5     FUNCTION myfunction (r sys_refcursor)
  6        RETURN NUMBER
  7     IS
  8     v_currDate DATE;
  9
10     BEGIN
11        IF r%ISOPEN THEN
12          FETCH r INTO v_currDate;
13        END IF;
14
15        RETURN TO_NUMBER (TO_CHAR (v_currDate, 'DD'));
16     END;
17  BEGIN
18     OPEN f FOR
19        SELECT SYSDATE dt
20          FROM DUAL;
21
22     RESULT := myfunction (f);
23
24     DBMS_OUTPUT.PUT_LINE('Date : ' || RESULT );
25
26     CLOSE f;
27  END;
28  /
Date : 23
PL/SQL procedure successfully completed.
{code}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

Similar Messages

  • 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

  • Can you pass SQL to a function?

    I have the following function:
    CREATE OR REPLACE PROCEDURE run_query(p_sql IN VARCHAR2) IS
      v_v_val     VARCHAR2(4000);
      v_n_val     NUMBER;
      v_d_val     DATE;
      v_ret       NUMBER;
      c           NUMBER;
      d           NUMBER;
      col_cnt     INTEGER;
      f           BOOLEAN;
      rec_tab     DBMS_SQL.DESC_TAB;
      col_num     NUMBER;
      v_rowcount  NUMBER := 0;
      v_csv          VARCHAR2(32000);
    BEGIN
      -- create a cursor
      c := DBMS_SQL.OPEN_CURSOR;
      -- parse the SQL statement into the cursor
      DBMS_SQL.PARSE(c, p_sql, DBMS_SQL.NATIVE);
      -- execute the cursor
      d := DBMS_SQL.EXECUTE(c);
      -- Describe the columns returned by the SQL statement
      DBMS_SQL.DESCRIBE_COLUMNS(c, col_cnt, rec_tab);
      -- Bind local return variables to the various columns based on their types
      FOR j in 1..col_cnt
      LOOP
        CASE rec_tab(j).col_type
          WHEN 1 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_v_val,2000); -- Varchar2
          WHEN 2 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_n_val);      -- Number
          WHEN 12 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_d_val);     -- Date
        ELSE
          DBMS_SQL.DEFINE_COLUMN(c,j,v_v_val,2000);  -- Any other type return as varchar2
        END CASE;
      END LOOP;
      -- This part outputs the DATA
      LOOP
        -- Fetch a row of data through the cursor
        v_ret := DBMS_SQL.FETCH_ROWS(c);
        -- Exit when no more rows
        EXIT WHEN v_ret = 0;
        v_rowcount := v_rowcount + 1;
        -- Fetch the value of each column from the row
        FOR j in 1..col_cnt  
        LOOP
          -- Fetch each column into the correct data type based on the description of the column
          CASE rec_tab(j).col_type
            WHEN 1  THEN DBMS_SQL.COLUMN_VALUE(c,j,v_v_val);
                         v_csv:= v_csv||','||v_v_val;
            WHEN 2  THEN DBMS_SQL.COLUMN_VALUE(c,j,v_n_val);
                         v_csv:= v_csv||','||v_n_val;
            WHEN 12 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_d_val);
                         v_csv:= v_csv||','||to_char(v_d_val,'DD/MM/YYYY HH24:MI:SS');
          ELSE
            DBMS_SQL.COLUMN_VALUE(c,j,v_v_val);
            DBMS_OUTPUT.PUT_LINE(v_v_val);
          END CASE;     
        END LOOP;
        dbms_output.put_line(substr(v_csv,2));
        v_csv:='';
      END LOOP;
      DBMS_SQL.CLOSE_CURSOR(c);
    END;
    It allows you to feed in an arbitrary query and have returned a comma-separated set of data. For example:
    SQL> exec run_query('select * from scott.emp where deptno = 10');
    7782,CLARK,MANAGER,7839,09/06/1981 00:00:00,2450,,10
    7839,KING,PRESIDENT,,17/11/1981 00:00:00,5000,,10
    7934,MILLER,CLERK,7782,23/01/1982 00:00:00,1300,,10
    PL/SQL procedure successfully completed.
    SQL> exec run_query('select * from (select * from scott.emp where deptno = 10 order by sal desc) where rownum < 5');
    7839,KING,PRESIDENT,,17/11/1981 00:00:00,5000,,10
    7782,CLARK,MANAGER,7839,09/06/1981 00:00:00,2450,,10
    7934,MILLER,CLERK,7782,23/01/1982 00:00:00,1300,,10
    (I'm not saying this is good practice: quite the opposite. But it's a requirement that's been set and I need to know how to meet it, not argue with it).
    My question is: the code works when the query submitted to it doesn't include single quotes. As soon as it does, it dies:
    SQL> exec run_query('select 'Example', sal from scott.emp where deptno = 10');
    BEGIN run_query('select 'Example', sal from scott.emp where deptno = 10'); END;
    ERROR at line 1:
    ORA-06550: line 1, column 26:
    PLS-00103: Encountered the symbol "EXAMPLE" when expecting one of the
    following:
    ) , * & = - + < / > at in is mod remainder not rem =>
    <an exponent (**)> <> or != or ~= >= <= <> and or like like2
    like4 likec as between from using || multiset member
    submultiset
    The symbol ", was inserted before "EXAMPLE" to continue.
    I could obviously escape the 'internal' single quotes, but the aim is for end-users to feed in their queries, not have to re-write them with tricky escape sequences!
    So the question is: is there a way I can let users feed their SQL into the procedure without having to worry about single quotes that might be in the middle of it?
    Again, I realise the risk of SQL injection... but I'd like assistance on the practicalities of quotation characters, not the management of a risk which I'm well aware of (and dealing with outside the procedural code I've shown here).
    In other words, even if you think this is the worst idea in the world, I'd still like to know how I could feed 'select 'Example', sal from scott.emp where deptno = 10'to the procedure and have it run correctly.

    Well, I'm going to say it's completely the wrong tool for the job simply because I don't know how to write it! Saying 'do it in Java' is like telling a Windows sysadmin 'do it in emacs'... might well be the right, most powerful, comprehensive and safest way of doing something, but if the skillset is foreign, it doesn't get you far!
    Well I can understand why that might be your initial reaction.
    But the fact is that ALL of your comments apply even more to use of the DBMS_SQL package. That package is not well known by most developers, is not used by most developers and, when it is used, is often misused.
    Even if you want to pursue other options why don't you at least take a look at the two concepts involved in a Java Stored Procedure solution.
    Here is a simple example from The Java Tutorials that shows how easy it is to execute a query that is contained in a string and iterate the result set.
    http://docs.oracle.com/javase/tutorial/jdbc/basics/retrieving.html
    Retrieving and Modifying Values from Result Sets
    The following method, CoffeesTable.viewTable outputs the contents of the COFFEES tables, and demonstrates the use of ResultSet objects and cursors:
    And here is an equally simple example from the Oracle Java Developer's Guide that shows how to write and execute a simple Java Stored Function.
    http://docs.oracle.com/cd/B28359_01/java.111/b31225/chfive.htm
    Java Stored Procedures Steps
    You can run Java stored procedures in the same way as PL/SQL stored procedures. Normally, a call to a Java stored procedure is a result of database manipulation, because it is usually the result of a trigger or SQL DML call. To call a Java stored procedure, you must publish it through a call specification.
    Before you can call Java stored procedures, you must load them into Oracle Database instance and publish them to SQL. Loading and publishing are separate tasks. Many Java classes, which are referenced only by other Java classes, are never published.
    To load Java stored procedures automatically, you can use the loadjava tool. It loads Java source, class, and resource files into a system-generated database table, and then uses the SQL CREATE JAVA {SOURCE | CLASS | RESOURCE} statement to load the Java files into Oracle Database instance. You can upload Java files from file systems, popular Java IDEs, intranets, or the Internet.
    The following steps are involved in creating, loading, and calling Java stored procedures:
      Step 1: Create or Reuse the Java Classes
      Step 2: Load and Resolve the Java Classes
      Step 3: Publish the Java Classes
      Step 4: Call the Stored Procedures
      Step 5: Debug the Stored Procedures, if Necessary
    You also didn't mention what you plan to do with the results.
    Sql Developer (free from Oracle - http://www.oracle.com/technetwork/developer-tools/sql-developer/downloads/index.html) can very easily query arbitrary data and produce a delimited result.
    Here is what a simple query would look like:
    SELECT /*csv*/ * from SCOTT.EMP;
    THAT'S IT!
    The data comes back in a grid and the user can save it to a file, open it in Excel or whatever. It doesn't get any simpler than that.
    Take a look at this article by Jeff Smith (a moderator of the sql developer forum) that shows what you can easily do
    http://www.thatjeffsmith.com/archive/2013/04/sql-developer-preferences-for-delimited-text-exports/
    Even if you decide not to use these other options, or decide that are not a good fit, you should always strive to learn about other techniques and where to find info about them. Who knows, one of these days you may need one of them.
    Just as important is that other forum readers understand that their are other, IMHO simpler, solutions out there for your problem.

  • Pass Boolean into a Function

    Currently, My function is :
    FUNCTION BooleanToVarChar2(p_Boolean_i Boolean)
    RETURN VARCHAR2 IS
    BEGIN
    IF p_Boolean_i THEN
    RETURN 'TRUE';
    ELSE
    RETURN 'FALSE';
    END IF;
    END;
    But I face an error whenever I try to call this function. The error message is
    The following error has occurred:
    ORA-06550: line 5, column 36:
    PLS-00382: expression is of wrong type
    ORA-06550: line 5, column 18:
    PLS-00306: wrong number or types of arguments in call to 'BOOLEANTOVARCHAR2'
    declare
    temp boolean;
    begin
    temp := true;
    select BooleanToVarChar2(Temp) from dual;
    end;
    Any Suggestion? Help!
    Message was edited by:
    iMe

    SQL does not support booleans, so you cannot use them in straight SQL. you can use them in pl/sql. so:
    declare
    answer varchar2(100);
    begin
    answer := BooleanToVarChar2( TRUE );
    end;
    also, using a select without an INTO clause in pl/sql seems rather pointless. so if the above example doesn't meet your requirements, try to give a more meaningful example

  • 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 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.

  • Query in passing value to a function module

    Hi All ,
    I have a small query in the below code about the way i have passed value into a function module :
    CALL FUNCTION 'AUTHORITY_CHECK'
      EXPORTING
      USER                      = SY-UNAME
        OBJECT                    = 'E_INVOICE'
        FIELD1                    = 'BEGRU'
      VALUE1                    = ' '
       FIELD2                    = 'BUKRS'
       VALUE2                    = '$BUKRS'
       FIELD3                    = 'ISU_ACTIVT'
       VALUE3                    = '1,2,5,6'
       FIELD4                    = 'VKTYP_KK'
      VALUE4                    = ' '
    EXCEPTIONS
       USER_DONT_EXIST           = 1
       USER_IS_AUTHORIZED        = 2
       USER_NOT_AUTHORIZED       = 3
       USER_IS_LOCKED            = 4
       OTHERS                    = 5
    IF SY-SUBRC <> 0.
    MESSAGE 'User doesnt have sufficient authorizations' TYPE 'E'.
    EXIT.
    The query is on the field  VALUE3                    = '1,2,5,6' , is the format correct. If this is not right could someone please suggest the correct approach.
    thanks

    Hi Balaji,
    as that is parameter you can use at a time only one value..
    if you check in that FM we have other parameters VALUE1 to VALUE10..
    why don't you use those...
    Thanks!

  • How to pass values from one function to another

    Hi,
    I am a middle school teacher and a newbie in Flash Actionscript. I am trying to create a countdown timer for use in my class during tests. The start and pause functions work as required, but not the pause button. When I click on the pause button, the timer is reset to 0:00:00. Please help. Here is the code I had written so far:
    var Subject1timeLeftHr;
    var Subject1timeLeftMin;
    var Subject1timeLeftSec;
    Subject1start_btn._visible = true;
    Subject1pause_btn._visible = false;
    Subject1rotor_mc.gotoAndStop(1);
    Subject1rotor_mc._visible = false;
    Subject1durationHr_txt.text = "0";
    Subject1durationMin_txt.text = "00";
    Subject1durationSec_txt.text = "00";
    Selection.setFocus(Subject1durationHr_txt);
    function SubjectdurationHr(SubjectxdurationHr_txt, SubjectxdurationMin_txt)
    if (SubjectxdurationHr_txt.length == 1)
    Selection.setFocus(SubjectxdurationMin_txt);
    function SubjectdurationMin(SubjectxdurationMin_txt, SubjectxdurationSec_txt)
    if (SubjectxdurationMin_txt.length == 2)
    Selection.setFocus(SubjectxdurationSec_txt);
    function SubjectdurationSec(SubjectxdurationSec_txt, SubjectxdurationHr_txt)
    if (SubjectxdurationSec_txt.length == 2)
    Selection.setFocus(SubjectxdurationHr_txt);
    Subject1durationHr_txt.onChanged = function()
    SubjectdurationHr(Subject1durationHr_txt,Subject1durationMin_txt);
    Subject1durationMin_txt.onChanged = function()
    SubjectdurationMin(Subject1durationMin_txt,Subject1durationSec_txt);
    Subject1durationSec_txt.onChanged = function()
    SubjectdurationSec(Subject1durationSec_txt,Subject1durationHr_txt);
    function startcountdown(SubjectxdurationLeft, SubjectxdurationHr, SubjectxdurationHr_txt, SubjectxdurationMin, SubjectxdurationMin_txt, SubjectxdurationSec, SubjectxdurationSec_txt, Subjectxduration, SubjectxstartTime, SubjectxendTime, Subjectxtimer_mc, Subjectxpause_btn, Subjectxstart_btn, Subjectxrotor_mc, SubjectxtimeLeft, SubjectxtimeLeftHr, SubjectxtimeLeftMin, SubjectxtimeLeftSec, SubjectxtimeLeftHr_txt, SubjectxtimeLeftMin_txt, SubjectxtimeLeftSec_txt)
    delete SubjectxdurationLeft;
    delete SubjectxdurationHr;
    delete SubjectxdurationMin;
    delete SubjectxdurationSec;
    delete Subjectxduration;
    delete SubjectxdurationHr_txt.text;
    delete SubjectxdurationMin_txt.text;
    delete SubjectxdurationSec_txt.text;
    SubjectxstartTime = getTimer();
    Subjectxtimer_mc.onEnterFrame = function()
    if (SubjectxdurationHr_txt.text == Nan || SubjectxdurationMin_txt.text == Nan || SubjectxdurationSec_txt.text == Nan)
    else
    SubjectxdurationHr = 60 * 60 * 1000 * Number(SubjectxdurationHr_txt.text);
    SubjectxdurationMin = 60 * 1000 * Number(SubjectxdurationMin_txt.text);
    SubjectxdurationSec = 1000 * Number(SubjectxdurationSec_txt.text);
    Subjectxduration = SubjectxdurationHr + SubjectxdurationMin + SubjectxdurationSec;
    SubjectxendTime = SubjectxstartTime + Subjectxduration;
    SubjectxdurationLeft = SubjectxendTime - getTimer();
    if (SubjectxdurationLeft > 0)
    SubjectxdurationHr_txt._visible = false;
    SubjectxdurationMin_txt._visible = false;
    SubjectxdurationSec_txt._visible = false;
    Subjectxpause_btn._visible = true;
    Subjectxstart_btn._visible = false;
    Subjectxrotor_mc._visible = true;
    Subjectxrotor_mc.play();
    SubjectxtimeLeft = SubjectxdurationLeft / (1000 * 60 * 60);
    SubjectxtimeLeftHr = Math.floor(SubjectxtimeLeft);
    SubjectxtimeLeftMin = Math.floor((SubjectxtimeLeft - SubjectxtimeLeftHr) * 60);
    SubjectxtimeLeftSec = Math.floor(((SubjectxtimeLeft - SubjectxtimeLeftHr) * 60 - SubjectxtimeLeftMin) * 60);
    SubjectxtimeLeftHr_txt.text = String(SubjectxtimeLeftHr);
    if (SubjectxtimeLeftHr_txt.length < 1)
    SubjectxtimeLeftHr_txt.text = "0" + SubjectxtimeLeftHr_txt.text;
    SubjectxtimeLeftMin_txt.text = String(SubjectxtimeLeftMin);
    if (SubjectxtimeLeftMin_txt.length < 2)
    SubjectxtimeLeftMin_txt.text = "0" + SubjectxtimeLeftMin_txt.text;
    SubjectxtimeLeftSec_txt.text = String(SubjectxtimeLeftSec);
    if (SubjectxtimeLeftSec_txt.length < 2)
    SubjectxtimeLeftSec_txt.text = "0" + SubjectxtimeLeftSec_txt.text;
    else
    delete Subjectxtimer_mc.onEnterFrame;
    SubjectxtimeLeftHr_txt.text = "";
    SubjectxtimeLeftMin_txt.text = "";
    SubjectxtimeLeftSec_txt.text = "";
    SubjectxdurationHr_txt._visible = true;
    SubjectxdurationMin_txt._visible = true;
    SubjectxdurationSec_txt._visible = true;
    Subjectxrotor_mc.gotoAndStop(1);
    Subjectxrotor_mc._visible = false;
    SubjectxdurationHr_txt.text = "0";
    SubjectxdurationMin_txt.text = "00";
    SubjectxdurationSec_txt.text = "00";
    Subjectxpause_btn._visible = false;
    Subjectxstart_btn._visible = true;
    Selection.setFocus(SubjectxdurationHr_txt);
    function pausecountdown(SubjectxdurationHr_txt, SubjectxtimeLeftHr, SubjectxdurationMin_txt, SubjectxtimeLeftMin, SubjectxdurationSec_txt, SubjectxtimeLeftSec, Subjectxstart_btn, Subjectxpause_btn, Subjectxrotor_mc)
    delete Subjectxtimer_mc.onEnterFrame;
    SubjectxdurationHr_txt.text = String(SubjectxtimeLeftHr);
    SubjectxdurationMin_txt.text = String(SubjectxtimeLeftMin);
    SubjectxdurationSec_txt.text = String(SubjectxtimeLeftSec);
    Subjectxstart_btn._visible = true;
    Subjectxpause_btn._visible = false;
    Subjectxrotor_mc.stop();
    Subject1pause_btn.onRelease = function()
    pausecountdown(Subject1durationHr_txt,Subject1timeLeftHr,Subject1durationMin_txt,Subject1t imeLeftMin,Subject1durationSec_txt,Subject1timeLeftSec,Subject1start_btn,Subject1pause_btn ,Subject1rotor_mc);
    Subject1start_btn.onRelease = function()
    startcountdown(Subject1durationLeft,Subject1durationHr,Subject1durationHr_txt,Subject1dura tionMin,Subject1durationMin_txt,Subject1durationSec,Subject1durationSec_txt,Subject1durati on,Subject1startTime,Subject1endTime,Subject1timer_mc,Subject1pause_btn,Subject1start_btn, Subject1rotor_mc,Subject1timeLeft,Subject1timeLeftHr,Subject1timeLeftMin,Subject1timeLeftS ec,Subject1timeLeftHr_txt,Subject1timeLeftMin_txt,Subject1timeLeftSec_txt);
    Subject1cancel_btn.onRelease = function()
    Subject1timeLeftHr_txt.text = "";
    Subject1timeLeftMin_txt.text = "";
    Subject1timeLeftSec_txt.text = "";
    Subject1durationHr_txt._visible = true;
    Subject1durationMin_txt._visible = true;
    Subject1durationSec_txt._visible = true;
    Subject1durationHr_txt.text = "0";
    Subject1durationMin_txt.text = "00";
    Subject1durationSec_txt.text = "00";
    Subject1timeLeftHr_txt._visible = true;
    Subject1timeLeftMin_txt._visible = true;
    Subject1timeLeftSec_txt._visible = true;
    Subject1pause_btn._visible = false;
    Subject1start_btn._visible = true;
    Subject1rotor_mc._visible = false;
    Subject1rotor_mc.gotoAndStop(1);
    delete Subject1timer_mc.onEnterFrame;
    delete Subject1durationLeft;
    delete Subject1duration;
    delete Subject1durationHr_txt.text;
    delete Subject1durationMin_txt.text;
    delete Subject1durationSec_txt.text;

    I think you need to spend some time reducing your code to practical levels.  You seem to be passing everything in the book to every function and I would guess that probably none of it is necessary.  If you declared those variables at the beginning, then you don't need to pass them into any function because they are gobally available to any of the code/functions that follows them.  Similarly, if you have textfields on the stage, you do not need to pass those into any functions for the same reason.
    I see you making overuse of "delete" (and possibly errant use as well).  Probably the only thing you might want/need to use is...
    delete Subjectxtimer_mc.onEnterFrame;
    Which stops the enterframe activity from firing off, which I will guess is being used to update the textfields that indicate the time.
    And that conditional that uses == Nan isn't likely to do anything except wonder what an Nan is.  Textfields hold strings, which are quoted.  SO unless you have a variable named Nan somewhere that has a String value assigned to it, that conditional won't be doing anything for you.  You probably won't need it at all if you get this working properly.

  • Pass multiple values as single input parameter into pipelined function

    Hi all,
    My need is to pass multiple values as single input parameter into pipelined function.
    For example - "2" and "3" are values of input parameter "t":
    with data as (
    select 1 as t from dual union all
    select 2 as t from dual union all
    select 3 as t from dual union all
    select 4 as t from dual union all
    select 5 as t from dual
    select * from data where t in (2,3)Is it possible at all?

    Not exactly sure, but usually 'multiple values'+'pipelined function' = some IN-LIST related approach?
    See:
    SQL> create table data as
      2  select 1 as t from dual union all
      3  select 2 as t from dual union all
      4  select 3 as t from dual union all
      5  select 4 as t from dual union all
      6  select 5 as t from dual;
    Table created.
    SQL> --
    SQL> CREATE OR REPLACE FUNCTION in_list (p_in_list  IN  VARCHAR2)
      2  RETURN sys.odcivarchar2list PIPELINED
      3  AS
      4    l_text  VARCHAR2(32767) := p_in_list || ',';
      5    l_idx   NUMBER;
      6  BEGIN
      7    LOOP
      8      l_idx := INSTR(l_text, ',');
      9      EXIT WHEN NVL(l_idx, 0) = 0;
    10      PIPE ROW (TRIM(SUBSTR(l_text, 1, l_idx - 1)));
    11      l_text := SUBSTR(l_text, l_idx + 1);
    12    END LOOP;
    13 
    14    RETURN;
    15  END;
    16  /
    Function created.
    SQL> --
    SQL> select *
      2  from   data
      3  where  t in ( select *
      4                from   table(in_list('1,2'))
      5              );
             T
             1
             2
    2 rows selected.http://www.oracle-base.com/articles/misc/dynamic-in-lists.php
    or
    http://tkyte.blogspot.nl/2006/06/varying-in-lists.html

  • ORA-06521: PL/SQL: Error mapping function while writting into a text file

    Hi,
    I'm getting an errror ORA-06521: PL/SQL: Error mapping function while trying to write data into a text file.
    I'm using the following code:
    --To create a new directory
    create or replace directory temp as 'C:/temp';
    declare
                    l_str varchar2(1000);
                    output_file utl_file.file_type;
                    cursor test_write_cur is
                         select EMPNO,ENAME,JOB,SAL,HIREDATE
                           from EMP
                         where DEPTNO=30;
    begin
               output_file := utl_file.fopen('TEMP','TESTFILE.txt','w');
               for test_write_rec IN test_write_cur
               loop          
                l_str :=     test_write_rec.EMPNO||'^'||test_write_rec.ENAME||'^'||test_write_rec.JOB||'^'||
                         test_write_rec.HIREDATE||'^'||test_write_rec.SAL||chr(10);
                utl_file.put_line(output_file,l_str);
                     end loop;                                                                           
               utl_file.fclose(output_file);
    end;Please suggest me if i'm wrong.
    Thanks & Regards,
    Sanket Mishra

    Dear Sanket,
    I think you are need use TO_CHAR() function
      to_char(test_write_rec.EMPNO) ,
      to_char(test_write_rec.HIREDATE,'DD.MM.YYYY')
      to_char(test_write_rec.SAL)

  • 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.

  • Passing SQL Server identity attributes values into adf entity objects

    Hi all.
    I'm using Jdeveloper 10g for developing an ADF Swing application based on MS SQL Server DB.
    Does anyone know if it is possible to pass SQL Server identity attributes values into the correspondent attrributes of adf entity objects, like we do with Oracle DB Sequence.
    The problem is that i should somhow implement cascade deleting of detail view objects, so i should use the composition association. But since i cant fill the primary key attribute with appropriate value (that is actually a ms sql server db sequence value) i always get
    the following exception: oracle.jbo.InvalidOwnerException: JBO-25030 as i try to create a new pair of master/detail objects.
    Thanks in advance.
    Alex.

    The approach is good. but i still dont understand how i can address the sql server db sequence (identity field) programmatically...
    The code offered
    SequenceImpl sequence = new SequenceImpl("PRODUCTS_SEQ",getDBTransaction());
    setProdId(sequence.getSequenceNumber());
    generates something like this:
    select deq_name.nextval from dual
    but this syntax works for oracle only... and not for sql server...
    Edited by: Timin on Mar 26, 2009 6:34 AM
    Edited by: Timin on Mar 26, 2009 10:25 AM

  • 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;
    /

  • Join diff functions into one function

    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
    PL/SQL Release 11.2.0.1.0 - Production
    CORE     11.2.0.1.0     Production
    Iam having five functions
    CREATE OR REPLACE function NEGERI.acre_hec (Vacre in number)
    return number is
    Va number;
    begin
    Va := ( (Vacre) * (0.4047) ) ;
    return (Va);
    end;
    CREATE OR REPLACE function NEGERI.depa_hec(Vdepa in number)
    return number is
    vd number;
    begin
    vd  := ( (Vdepa) * (0.0003345) ) ;
    return vd;
    end;
    CREATE OR REPLACE function NEGERI.kaki_hec(Vkaki in number)
    return number is
    vk number;
    begin
    vk := ((Vkaki) * (0.0000093));
    return vk;
    end;
    CREATE OR REPLACE function NEGERI.meter_hec(Vmeter in number)
    return number is
    vm number;
    begin
    vm := ((vmeter) * (0.0001));
    return vm;
    end;
    CREATE OR REPLACE function NEGERI.relong_hec(Vrelong in number)
    return number is
    vr number;
    begin
    vr := ((vrelong) * (0.2877719));
    return vr;
    end;
    /i was supposed to join these five functions into one function.. Can any one help me so
    select * from v$version;

    May be some thing like this?
    CREATE OR REPLACE FUNCTION NEGERI.name_you_want_hec (p_in_act IN NUMBER, p_type VARCHAR2)
       RETURN NUMBER
    IS
       retval         NUMBER;
    BEGIN
       IF p_type = 'A'
       THEN
          retval      := ( (p_in_act) * (0.4047));
       ELSIF p_type = 'D'
       THEN
          retval      := ( (p_in_act) * (0.0003345));
       ELSIF p_type = 'K'
       THEN
          retval      := ( (p_in_act) * (0.0000093));
       ELSIF p_type = 'M'
       THEN
          retval      := ( (p_in_act) * (0.0001));
       ELSIF p_type = 'R'
       THEN
          retval      := ( (p_in_act) * (0.2877719));
       END IF;
       RETURN (retval);
    END;You can handle exceptions when a null is passed or an invalid p_type is passed.
    G.

  • Adding a CM: Invalid length parameter passed to the RIGHT function. (CINF)

    We started seeing this error message a week ago when attempting to add a Credit Memo.  We only see this error message when entering Credit Memos and not any other finacial documents.  I've done some preliminary research and haven't really come up with anything to point to the issue.  Prior to reporting this to my support partner, I wanted to see if anybody here has seen this before or give me some ideas to look into the source of the issue.
    Full error message: Microsoft SQL Native Client SQL Server Invalid length parameter passed to the RIGHT function. (CINF)

    Checking the list of form ID's at [http://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/892] shows the A/R Credit Memo as 179 and the A/P Credit Memo as 181.  This also corresponds with what I see when viewing the system information on the form.

Maybe you are looking for

  • Error Message in a dialog box

    Hi, I have defined a error message in a raise application error type. Is there a way can we change this error type to message box becouse after entering data I lose data what is been entered on page. becouse of this error type. Please suggest me how

  • First address of my BP

    hi there i have some BPs that have more than one address assigned to their page it means that they have two factorys for example how can i get only the first address(only the country) from my BP;s contact card? SELECT T0.[DocNum]'A/R inv', T1.[visord

  • Can you create a family id without a credit card

    Hi I dont have a credit card and want to create a family id for my daughter, is this possible?

  • MView refresh error on 10gR2..(unique constraint error)

    Hi. all. The database is 2-node RAC 10gR2 on SunOS. Today morining, I got the following error. EXEC dbms_refresh.refresh('"ODSFAB"."CURRENTWIP"'); ORA-12008: error in materialized view refresh path ORA-00001: unique constraint (ODSFAB.CURRENTWIP_GLAS

  • EasyDMS7.1  available system

    Hi, I have installed EasyDMS version 7.1.2.0 successfully. My PC property is 32 bit  Window 7 Enterprise OS. I am able to see my Quality & Production system in the available system list but not my development & IDES system. Whereas the SAP Help says