Return a value of date using a function

I have a function in which I'm passing a date, but given the entry as a varchar data type.

I'm the date inside the print function value and then return the value date.

When I'm passing through January 20, 2009 as the date, I make out like 20 January 09 only.
The year is get truncated in the output.

How can I get January 20, 2009 as the value of output.

Thanks in advance

Kind regards
Rambeau

Try this:

DECLARE
  MANIFEST_DT VARCHAR2(25) := '20-Jan-2009';
  V_SAMP_DT DATE;
BEGIN
  SELECT TO_DATE(MANIFEST_DT,'DD-MON-YYYY') + 4
  INTO   V_SAMP_DT
  from   dual;
  DBMS_OUTPUT.PUT_LINE('SAMPLE DATE IS: ' ||to_char(V_SAMP_DT, 'dd-Mon-yyyy'));
END;
/

When you store/work with dates in the database, it is best to convert the dates as a string in the format of date (with to_date) as soon as possible.

When you need a date in the format of a specific way when it came to the end/screen/report on the forehead, then use to_char to return a date into a string format.

Published by: Boneist on January 20, 2009 11:41

Tags: Database

Similar Questions

  • Return each value only once using cfloop query

    Hello

    I have a code that fills a cfselect list dynamically and then fills a second list based on these values. Everything seems to work fine, except that all values are taken from the database, and there are duplicates in the majority of cases. For example, the 1S1W is displayed in the dropdown value 10 times, where I'll settle it there once.

    Is it possible to have one of each value in my list?

    < isDefined ('form.select_Main_Group') cfif >

    < cfset page.select_Main_Group = form.select_Main_Group >

    < / cfif >

    < cfoutput >

    < name of the form = "DropDown" method = "post" >

    <!--> query DB for the first descent to the bottom of the list

    < CFQUERY name = "get_Main_Group" datasource = "ds" dbtype = "odbc" >

    SELECT *.

    FROM slco_sire.dbo.area_reference_plats_doc INNER JOIN slco_sire.dbo.area_reference_plats_page

    ON slco_sire.dbo.area_reference_plats_doc.doc_id = slco_sire.dbo.area_reference_plats_page.doc_id

    ORDER BY page_description

    < / CFQUERY >

    <!--> first drop-down list

    <! - VIEW the onChange event of javascript in the select tag, it's what sends the form after the first selection - >

    < select name = "select_Main_Group" required = "yes" onchange = "this.form.submit ()" >

    < option > select Township/range < / option >

    <!-dynamically populate the first drop drop down based on the get_Main_Group query->

    <!-NOTICE the CFIF in the option tag, that said, if the first selection has occurred, display the chosen option when pages are reloaded->

    < cfloop query = "get_Main_Group" >

    < option value = "" #SECTION # "< cfif isDefined ('form.select_Main_Group') > < selected cfif form.select_Main_Group eq ' #SECTION # ' > < / cfif > < / cfif > > #TOWNSHIP_RANGE # < / option >"

    < / cfloop >

    < / select >

    < p >

    <! - if the first selection has been made, see the second dropdown menu with the appropriate results - >

    < isDefined ('page.select_Main_Group') cfif >

    <! - query DB for second drop to the bottom of the list, based on the selected item in the list - >

    < cfquery name = "get_Sub_Group" datasource = "ds" dbtype = "odbc" >

    SELECT TOWNSHIP_RANGE, SECTION

    FROM slco_sire.dbo.area_reference_plats_doc INNER JOIN slco_sire.dbo.area_reference_plats_page

    ON slco_sire.dbo.area_reference_plats_doc.doc_id = slco_sire.dbo.area_reference_plats_page.doc_id

    WHERE the ARTICLE = ' #page.select_Main_Group # '.

    < / cfquery >

    <!--> the second drop down menu

    < select name = "select_Sub_Group" required = "yes" >

    Section select < option > < / option >

    <! - dynamically fill the second fall to the bottom of the list based on the get_Sub_Group query - >

    < cfloop query = "get_Sub_Group" >

    < option value = "#SECTION #" > #SECTION # < / option >

    < / cfloop >

    < / select >

    < / cfif >

    < / make >

    < / cfoutput >

    Emily,

    Easy fix.  Use the same approach you did to determine when the second menu drop-down.  Change this line:

    action = "by_TRS_results_arps_2.cfm" > ""

    to these:

  • ORA-06503: PL/SQL: function returned no value ORA-06512:

    Hi all

    SQL > set serveroutput on

    SQL > CREATE OR replace FUNCTION qty_value (p_item_id number)

    2 RETURN NUMBER

    3 EAST

    4 v_qty_arrival NUMBER;

    5 BEGIN

    6. SELECT THE CASE SENSITIVE OPTION

    7. WHAT (SUM (b.quantity) - SUM (b.quantity_received)) < = 0 THEN 0

    8 ELSE (SUM (b.quantity) - SUM (b.quantity_received))

    9 END Qty_Arrival

    10 INTO v_qty_arrival

    Po_lines_all 11 a,

    po_line_locations_all 12 b

    13 WHERE a.po_line_id = b.po_line_id

    14 AND a.item_id = p_item_id;

    15 EXCEPTION

    16 THEN THAN OTHERS THEN

    17 v_qty_arrival: = NULL;

    18 RETURN v_qty_arrival;

    19 END qty_value;

    20.

    The function is created.

    SQL >

    SQL > select xxc_qty_arrivale (214960) double

    2.

    Select xxc_qty_arrivale (214960) double

    *

    ERROR on line 1:

    ORA-06503: PL/SQL: function returned no value

    ORA-06512: at the 'APPS '. XXC_QTY_ARRIVALE', line 19

    Back AFTER using the exception block is fine as long as your code actually REACHED the exception block.

    When there are no errors, then your code will not enter the exception block, but you still NEED to return a value, since it is what functions a function wants to return a value, that's what the functions are made for.

    Spot the differences between the following 3 functions. Understand how they work.

    The first function has only a return in the exception block but runs correctly. Result: error, because the back is missing in the code block.

    The second function has a return in the exception block and one in the block of code and runs correctly. Result: no error, because the return is not missing in the code block.

    The third function has a return in the exception block and one in the block of code and is forced into an error. Result: no error, because the return of the exception handler is used (instead of retriggering of the error, which you would normally do).

    SQL > create or replace function myfunc

    2 return number

    3 as

    4 start

    5 dbms_output.put_line ('in the section of code');

    6 null;

    7 exception

    8 then than others

    9. can

    10 dbms_output.put_line (' in the exception handler ' |) SQLERRM);

    11      --

    12 return 0;

    13      --

    14 end;

    15.

    The function is created.

    SQL > select double myfunc;

    Select double myfunc

    *

    ERROR on line 1:

    ORA-06503: PL/SQL: function returned no value

    ORA-06512: at "GHPLUS. MYFUNC", line 14

    In the section of code

    SQL > create or replace function myfunc

    2 return number

    3 as

    4 start

    5 dbms_output.put_line ('in the section of code');

    6 null;

    7    --

    8 return 1;

    9    --

    10 exceptional

    11 so that others

    12. can

    13 dbms_output.put_line (' in the exception handler ' |) SQLERRM);

    14      --

    15 return 0;

    16      --

    end 17;

    18.

    The function is created.

    SQL > select double myfunc;

    MYFUNC

    ----------

    1

    1 selected line.

    In the section of code

    SQL > create or replace function myfunc

    2 return number

    3 as

    n number 4;

    5. start

    6 dbms_output.put_line ('in the section of code');

    7 n: = 1/0; -force an error (zero divisor) to join the exception handler

    8    --

    9 return 1;

    10-

    exception 11

    12 so that others

    13. can

    14 dbms_output.put_line (' in the exception handler ' |) SQLERRM);

    15      --

    16 return 0;

    17      --

    18 end;

    19.

    The function is created.

    SQL > select double myfunc;

    MYFUNC

    ----------

    0

    1 selected line.

    In the section of code

    In the handler for exception ORA-01476: divisor is equal to zero

    SQL >

  • What subprogramme should we prefer to return multiple values with OUT parameter?

    Hello

    I worked on the procedures and functions, and aware of their differences. Today I have an interview question that - suppose I don't have return multiple values through a subroutine and I want nor run any what DML within this subprogramme and I want to use this subprogramme in the SQL query. What subprogramme I would prefer - "Operating Mode" or "Function" and why?

    In my view, both can be used in this case, but want to see your views and opinions.

    Kind regards

    Sachin jerbi

    In terms of software engineering, if you claim something that you expect to "return" something (a value or values) then you use a function.  If you call something to "do" something, and then you use a procedure.

    THE settings are not good practices in many cases and should not strictly considered "return" of values.  Instead, they are assigned values in the code and generally act as pointers to the original variable/structure that was passed as a parameter (the actual internals of Oracle don't quite do it, but in principle this is what they do).

    A return value (or structure) of a function is basically push in the battery to the point that the RETURN statement is issued, and then the code calling the stack appears to assign it to a variable or placeholder, it should go in.

    If it seems a little difference between procedures and functions to some people, it is recommended to use functions for obtaining values and procedures to do things, in most cases.  It is not just "syntactic sugar", as mentioned above.

  • How to run VB of JSX and return a value?

    Someone knows how to do this?

    $.writeln('result:\r' + app.doScript('wsh.echo "test"', ScriptLanguage.VISUAL_BASIC));

    WSH and wscript give an error 'object required '. Same script works very well as a vbs file.

    It seems that these objects are simply not available when executing doScript, but y at - it another way to return a value?

    Justin Putney says:

    Substances. wrote:

    FWIW, to return a value from VB using doScript, you need returnValue = SomeValue at the end of your VB script.

    I know that this is the case with a Sub or Function... is that his operation at the end of a script as well?

    To answer your questions, here is an excerpt of work I have that gets the file in Excel:

    var vbs = 'Set MyXL = GetObject(, "Excel.Application")\r' +
    'Set ActiveXL = MyXL.activeworkbook\r'+
    'returnValue = ActiveXL.Path';
    var path = app.doScript(vbs,ScriptLanguage.VISUAL_BASIC);
    
  • Return a value of a DispatchEvent

    I have a class of the custom event that looks like this:

    package com.ascentify.components.eduspeak.events
    {
         import flash.events.Event;
         
         public class EduSpeakEvent extends Event
         {
              //Build Path Events
              public static const BUILD_PATH:String = "EduSpeakEvent.BuildPath";
              
              public var param:Object;
              
              public function EduSpeakEvent(type:String, pParam:Object=null, bubbles:Boolean=false, cancelable:Boolean=false)
              {
                   param = pParam;
                   
                   super(type, bubbles, cancelable);
              }
              
              public override function clone():Event
              {
                   return new EduSpeakEvent( type, param );
              }
              
              public override function toString():String
              {
                   return formatToString( "EduSpeakEvent", "param", "type", "bubbles", "cancelable" );
              }
         }
    }
    

    This is so I can pass a value with my function.

    In a class of event dispatcher, I have a function that is implemented to ship this event:

    public function buildPath(relativePath:String):Object{
         return dispatchEvent(new EduSpeakEvent(EduSpeakEvent.BUILD_PATH, {relativePath:relativePath}));
    }
    

    It contains lines the problem. I can send a value to the event handler, but I need to return a value as well:

    public function buildPath(e:EduSpeakEvent):String
    {
         var path:String = e.param.relativePath;
                   
         try {
              // If input  is an absolute path or URL, return it.
              if (isAbsolutePath(e.param.relativePath)) {
              return e.param.relativePath;
              }
                        
              // get the current location
              var baseDir:String = ExternalInterface.call("ES_getBaseDirectory");
              displayLoader._trace("baseDir = "+baseDir, true, true);
                        
              // currently, always returns a concatenated path.
              if (e.param.relativePath.charAt(0) != "/" && e.param.relativePath.charAt(0) != "\\")
              {
                   e.param.relativePath = "/" + e.param.relativePath;
              }
              path = baseDir + e.param.relativePath;
              }
         catch (e:Error) {
              var errMsg:String = "[Exception occurred during 'buildPath']: " + e.message;
              displayLoader._trace(errMsg,true,true);
         }
                   
         return path;
    }
    

    Can I get a return on my eventdispatch function value?

    The event system is not designed to return values and you really shouldn't use events to do. Event are for the notification, not function calls. Events can have several listeners, so how could they all return a value? However, if you really want to, your listener could define a field of the event (say event.result) object that you can then interview after the return of dispatchEvent (event).

    BTW, why you go your way as an object rather than a string or anything actually?

    Gordon Smith

    Adobe Flex SDK team

  • How to return the value 0 for no data using the County?

    Hi all
    I used this query to count the number of records for each month of the year:

    SELECT DISTINCT COUNT (I.information_sid) COUNT, TO_DATE (TO_CHAR (INSERT_DATE, 'MM'), 'MM') MONTH

    INFORMATION I

    TO_DATE GROUP (TO_CHAR (INSERT_DATE, 'MM'), 'MM')

    ORDER BY TO_DATE (TO_CHAR (INSERT_DATE, 'MM'), 'MM')

    But this code returns no value for months without data
    I want to return the value '0' for any month of data. How, please?

    Note: I use reports 6i.

    Maybe this?

    SELECT SUM(CNT_REC) CNT_REC, MONTH
    FROM
    (
    SELECT COUNT(I.information_sid) CNT_REC, TO_DATE(TO_CHAR(INSERT_DATE,'MM'),'MM') MONTH
    FROM INFORMATIONS I
    GROUP BY TO_DATE(TO_CHAR(INSERT_DATE,'MM'),'MM')
    UNION ALL
    SELECT 0, LPAD(ROWNUM,2,0)
    FROM ALL_OBJECTS
    WHERE ROWNUM <= 12
    )
    GROUP BY MONTH
    ORDER BY MONTH
    

    No need to SEPARATE during the use of GROUP BY.

    -Clément

  • Return multiple values from a function in a SELECT statement

    I hope I've provided enough information here. If not, let me know what I'm missing.

    I create a view that will combine the information from several tables. Most are pretty simple, but there are a couple of columns in the view that I need to get by running a function within a package. Even if this is quite simple (I have a function named action_date in a package called rp, for example, that I can use to return the date that I need through SOME rp.action_date (sequence_number).

    Here is the question: I really need to return several bits of information of the same record (not only action_date, but also action_office, action_value, etc.)-a join of the tables will work not here, as I will explain below. I can, of course, perform a function separate for each statement, but this is obviously inefficient. Within the select statement of the view, however, I don't know how each of the values that I need to get back.

    For example, right now, I have:

    Table 1:
    sequence_number NUMBER (10),
    name varchar (30),
    ...

    Table2:
    Table1_seq NUMBER (10),
    action_seq NUMBER (10),
    action_date DATE,
    action_office VARCHAR (3),
    action_value VARCHAR (60),
    ...

    I can't just simply join Table1 and Table2 because I have to perform processing in order to determine the rows returned matching, I really need to select. If the package opens a cursor and treats each line until it finds the one I need.

    The following works but is ineffective since all calls to the package returns the columns of the same record. I don't know how to put all the values that I need in the SELECT statement.
    CREATE VIEW all_this_stuff AS
    SELECT sequence_number, name,
    RP.action_date (sequence_number) action_date,
    RP.action_office (sequence_number) action_office,
    RP.action_value (sequence_number) action_value
    FROM table1

    Is there a way to return multiple values in my SELECT statement or I'm going about this all wrong?

    Any suggestions?

    Thank you very much!

    Hello

    What you want is a Query of Top - N , what you can do using the ROW_NUMBER analytic function in a subquery, like this:

    WITH     got_rnum     AS
    (
         SELECT     action_seq, action_dt, action_office, action_type, action_value
         ,     ROW_NUMBER () OVER ( ORDER BY  action_date
                                   ,            action_seq
                             ,            action_serial
                           ) AS rnum
         FROM     table2
         WHERE     action_code     = 'AB'
         AND     action_office     LIKE 'E'     -- Is this right?
    )
    SELECT     action_seq, action_dt, action_office, action_type, action_value
    FROM     got_rnum
    WHERE     rnum     = 1
    ;
    

    As written, this returns a single line (at most).
    I suspect you'll actually get a rank for each group , where a group is defined by a value in a table in which you join.
    In this case, add a PARTITION BY clause to the ROW_NUMBER function.
    If post you a small example of data (CREATE TABLE and INSERT statements), I could show you exactly how.
    As I don't have your tables, I'll show you the use of the tables in the scott schema.
    This is a view containing data in the scott.dept table and also to scott.emp, but only for the highest employee in each Department (in other words, the employee whose oldest hire date). If there be a tie for the first hire date, while the candidate with the lowest empno is selected.

    CREATE OR REPLACE VIEW     senior_emp
    AS
    WITH     got_rnum     AS
    (
         SELECT     d.deptno
         ,     d.dname
         ,     e.empno
         ,     e.ename
         ,     e.hiredate
         ,     ROW_NUMBER () OVER ( PARTITION BY  d.deptno
                                   ORDER BY          e.hiredate
                             ,                e.empno
                           ) AS rnum
         FROM     scott.dept     d
         JOIN     scott.emp     e     ON     d.deptno     = e.deptno
    )
    SELECT     deptno
    ,     dname
    ,     empno
    ,     ename
    ,     hiredate
    FROM     got_rnum
    WHERE     rnum     = 1
    ;
    
    SELECT     *
    FROM     senior_emp
    ;
    

    Output:

    .    DEPTNO DNAME               EMPNO ENAME      HIREDATE
    ---------- -------------- ---------- ---------- ---------
            10 ACCOUNTING           7782 CLARK      09-JUN-81
            20 RESEARCH             7369 SMITH      17-DEC-80
            30 SALES                7499 ALLEN      20-FEB-81
    

    Moreover, one of the conditions to the query you posted has been

    action_office     LIKE 'E'
    

    which equals

    action_office     = 'E'
    

    (AS is always equivalent to = if the string that follows AS does not contain the winning cards.)
    Did you mean say that or did you mean something like this:

    action_office     LIKE 'E%'
    

    Instead?

  • Create the view and by using the function that returns a type oracle

    Following is possible?

    A function returns an ORACLE object Type, and I want to use this feature, in my opinion, it is possible to access each field of the type once the function is executed and make a column in the view?
    create or replace TYPE SOME_INFO AS OBJECT
    ( 
      CHARGE FLOAT,
      SOME_DATE DATE,
      SOME_VAL VARCHAR(50)
    );
    
    CREATE OR REPLACE
      FUNCTION CALCULATE_INFO
        (
          p_chargeId NUMBER)
        RETURN SOME_INFO 
      AS 
      v_some_info SOME_INFO := new SOME_INFO(0, null, null);
    BEGIN
     
    -- function body populates the v_some_info
    return v_some_info;
     
    END calculate_info;
    Now, I want to use the function according to me - if the underlying query of the view follows-
     select c.*, calculate_info(c.charge_id) as someInfo from some_charge;
    How to recover someInfo.CHARGE, someInfo.some_date, someInfo.some_val? I can put them as columns in the view?

    If you use only functions that return a single value in a view?

    Thank you
    Mustapha

    Published by: Tina Giri on April 16, 2009 05:47

    How to recover someInfo.CHARGE, someInfo.some_date, someInfo.some_val?

    SQL>  create or replace type some_info
    as
       object (charge float, some_date date, some_val varchar (50));
    /
    Type created.
    
    SQL>  create or replace function calculate_info (p_chargeid number)
       return some_info
    as
       v_some_info   some_info := new some_info (0, null, null);
    begin
       -- function body populates the v_some_info
       return v_some_info;
    end calculate_info;
    /
    Function created.
    
    SQL>  select your_view.someinfo.charge,
           your_view.someinfo.some_date,
           your_view.someinfo.some_val
      from (select c.*, calculate_info (c.empno) as someinfo
              from emp c) your_view where rownum <= 3
    
    SOMEINFO.CHARGE SOMEINFO SOMEINFO.SOME_VAL
    --------------- -------- --------------------------------------------------
                  0
                  0
                  0                                                            
    
    3 rows selected.
    
  • Function return undefined values

    My function returns undefined values. It seems that the return of the function statement is executed before the database is queried and values are assigned to variables. If I do an alert within the loop for () I get the correct values from the database, but these values are not affected before excecuting the return statement function. How can I do this differently?

    function getColumnNames(table){
        var rs1, rs2, rs3, rs4, rs5;
        db.transaction(function (tx) {
            tx.executeSql("SELECT * FROM schema WHERE table_name=?",[table], function(ax, results){
                var size = results.rows.length, i;
                var item;
                for (i = 0; i < size; i++){
                    item = results.rows.item(i);
                    rs1 = item.col1;
                    rs2 = item.col2;
                    rs3 = item.col3;
                    rs4 = item.col4;
                    rs5 = item.col5;
                                    alert(rs1); //correct value is returned here
                }
            });
        });
        return [rs1, rs2, rs3, rs4, rs5];
    }
    

    Hey Fabian,.

    You are quite correct that the return statement is executed before the database returns the results. There are ongoing asynchronous calls. You can set breakpoints in JavaScript code to see what is happening. You can correct the problem by using function callbacks. I edited your code below to use the callback functions - there might be a few typos, but the general approach should be wooded.

    function getColumnNames(table, callback){
        var rs1, rs2, rs3, rs4, rs5;
        db.transaction(function (tx) {
            tx.executeSql("SELECT * FROM schema WHERE table_name=?",[table], function(ax, results){
                var size = results.rows.length, i;
                var item;
                for (i = 0; i < size; i++){
                    item = results.rows.item(i);
                    rs1 = item.col1;
                    rs2 = item.col2;
                    rs3 = item.col3;
                    rs4 = item.col4;
                    rs5 = item.col5;
                        alert(rs5); //correct values are being returned
                    callback([rs1, rs2, rs3, rs4, rs5]);
                }
            });
        });
    }
    
    // example of how to call getColumnNames with callback
    getColumnNames('importantTable', function (result)
    {
        console.log(result);
    });
    
    // alternative version
    function onCallback(result)
    {
        console.log(result);
    }
    
    getColumnNames('importantTable', onCallback);
    

    I hope this helps.

    See you soon,.

    James

  • Using the function PLSQL return Record Type Index of Tables in ADF

    I have a PLSQL function, a return type. My ultimate goal is to take this binary integer index Table and print it on the screen...

    CREATE OR REPLACE PACKAGE my_pkg IS
     
    TYPE t_col IS RECORD(
     
    i NUMBER,
     
    n VARCHAR2(30));
     
    TYPE t_nested_table IS TABLE OF t_col;
     
      FUNCTION return_table RETURN t_nested_table ;
    END my_pkg;


    OPTION 1:

    1) has anyone got best practices to accept plsql RECORDS returned by a function?

    Here is an example.

    http://adfpractice-Fedor.blogspot.SG/2013/01/working-with-PLSQL-procedures-in-ADF-BC.html

    But it will be a lot of work... first of all accept the results in a loop... then store in a temporary storage can be a few VO or global temporary table and then display them on the page


    OPTION 2:

    Using the functions PIPLELINED and use in the select statement.  While I can use this select statement in the SQL query to create VO... and drag and drop the VO...

    CREATE OR REPLACE PACKAGE my_pkg IS
     
    TYPE t_col IS RECORD(
     
    i NUMBER,
     
    n VARCHAR2(30));
     
    TYPE t_nested_table IS TABLE OF t_col;
     
      FUNCTION return_table RETURN t_nested_table PIPELINED;
    END my_pkg;


    select * from table(my_pkg.return_table);


    Wow... I'm so smart! .. really possible?  who is the best/possible/recommended option?

    I'm sure that will be the question most read by many who wants to use PLSQL instead of JAVA to the treatment and CHOSEN to use only to display the output of the PLSQL functions or procedures.


    Thank you

    Rahul


    Dario

    Do you mean the scope of the defined Type pkg will be finished?

    I created guy outside the pkg as 'Create Type' if it works in this case?

    Yes, level objects schema (created with "create or replace type...") can be used in java and this can work.

    I think that then the scope of this TYPE will remain until the user session passes.

    Object definitions is not worn, but have their bodies.

    So, if you instantiate the data level object type schema in a plsql function, scope of this object is this function.

    Of course, if you instantiate the object as a variable package, then life of this object is equal to the lifetime of the package (which usually equals life of session db).

    Dario

  • Using the function to retrieve several data

    using the function recover data of the hre_date and name of entry where are employee_id = 100. kindly give a query in PLSQL

    Padma... wrote:
    Hello

    create or replace function f1 (a number, b out varchar2) return date
    is
    c the date;
    Start
    Select last_name, hire_date b, c of the employees where employee_id = a;
    return c;
    end;
    /
    declare
    name varchar2 (30);
    Start
    dbms_output.put_line (f1(100, name));
    dbms_output.put_line (Name);
    end;

    Thank you
    Padma...

    Agree with Marwim, using OUT parameters is very bad practice.

    Something would be more appropriate...

    SQL> create or replace function get_emp(empno in number) return sys_refcursor is
      2    rc sys_refcursor;
      3  begin
      4    open rc for 'select hiredate, ename from emp where empno = :1' using empno;
      5    return rc;
      6  end;
      7  /
    
    Function created.
    
    SQL> var rc refcursor;
    SQL> exec :rc := get_emp(7788);
    
    PL/SQL procedure successfully completed.
    
    SQL> print rc
    
    HIREDATE             ENAME
    -------------------- ----------
    19-APR-1987 00:00:00 SCOTT
    
    SQL>
    

    If the customer requires a Ref cursor returned with data, otherwise a registration type / adapted collection could be returned and the integrated data to the that, although in general the collection of data in memory and the passage on the procedures is not the most ideal because it takes up resources such as memory of the PGA.
    Without special requirements, it is impossible to give a precise answer.

  • Mathmatical function to return the value in injectors

    Hello
    I have obliged. If value for ex Lake 4400000, he should return as 4.4millions even for billions.
    is there an oracle function to return the value in this format. ???

    Hello

    When I want to have a "readable" released in large numbers, I use to do the following:

    Scott@my11g SQL>with t as (
      2  select 3456123456 n from dual
      3  union all select 4567123 from dual
      4  union all select 123465 from dual
      5  )
      6  select n, case when n>1000000000 then trunc(n/1000000000,1)||' Billions'
      7  when n>1000000 then trunc(n/1000000,1)||' Millions'
      8  else to_char(n) end fmtn
      9  from t ;
    
             N FMTN
    ---------- -------------------------------------------------
    3456123456 3.4 Billions
       4567123 4.5 Millions
        123465 123465
    

    ------
    * + [change] + *.
    Moreover, lakh [url http://en.wikipedia.org/wiki/Lakh] has no meaning outside of South Asia.
    Especially for a French man like me, grown with [url http://en.wikipedia.org/wiki/International_System_of_Units] International system of units that is fighting against what I call "funky" measures empirical such miles, yards, feet, inches, just not multiple of 10³
    Same billion mean differ depending on the country (see [url http://en.wikipedia.org/wiki/Long_and_short_scales] long and short scales)

    Just for "fun": [url http://articles.cnn.com/1999-09-30/tech/9909_30_mars.metric.02_1_climate-orbiter-spacecraft-team-metric-system?_s=PM:TECH] this is what can happen when we do not use the same system of units.

  • I can't insert a line using the function to return?

    Hello

    This doen't work code, do you know why?

    declare
    function my_func (a number)
    number of repetition
    is
    Start
    return number * number;
    end;
    Start

    insert into my_tab values (my_func (4));

    end;


    Moreover, there is not any constraint on my_tab, I'm just wondering, can we use back function in the SQL inset? or is there a problem?
    Thank you 1 million.

    Cant insert statement I use directly in function?

    Not recommended but also a possible way:

    SQL> create table my_tab (i int)
    /
    Table created.
    
    SQL> declare
      function my_func (a number)
        return number
      is
      begin
        return a * a;
      end;
    begin
      execute immediate 'insert into my_tab values (:1)' using my_func(4);
    end;
    /
    PL/SQL procedure successfully completed.
    
    SQL> select * from my_tab
    /
             I
    ----------
            16
    1 row selected.
    
  • Return a value to a field of text using personalization in the OPS

    Hi all

    I work in the OPS 12.1.1.

    Using customization,.
    My requirement is to perform a function or deteriorated by clicking a button.
    Or it will return a value.
    The value must be within a text field.

    Using the customization, I created a button in a seeded page.
    Additional using customization I could meet my requirement.

    By clicking the custom button, a value must be place in a sown field.

    Please advice.


    Thanks in advance,
    Roselyne

    Roselyne,

    You need to extend the CO to your needs.

    Call the procedure in section extended controller PFR, catch the event & & set the value in the bean.

    Kind regards
    GYAN

Maybe you are looking for