Select * from FUNCTION(a,b,c,...)

Hi,
Our client asked us not to use VIEW in our entire application!
After wasting one week negotiating with them, I am looking for some alternatives for views to simplify our complex queries.
Can I use functions instead of views in select statements? Could you give me a sample for SCOTT.EMP table? I am looking for something like:
SELECT * FROM UDF_FUNCTION(123)
Are functions a good alternative for views? What are my other options?
Regards,
Alan

You can select from a function if you create a "pipelined function". I would definitely use a view if I could, since a pipelined function will almost certainly not perform as well as a well-tuned view. Pipelined functions can be useful for ETL transformations, but are probably not the best choice for data access routines to deliver results to an end-user.
Anyway, here is a simple example, using the SCOTT sample schema:
SQL> create type EmpType as object
  2  (
  3  empno number(4),
  4  ename varchar2(10),
  5  sal number(7,2)
  6  );
  7  /
Type created
SQL> create type EmpTabType as table of EmpType;
  2  /
Type created
SQL> create or replace function EmpFunc(p_in_sal IN NUMBER) return EmpTabType PIPELINED IS
  2    l_emp_rec EmpType := EmpType(NULL,NULL,NULL);
  3  begin
  4    for emp_rec in (select * from emp where sal > p_in_sal) loop
  5      l_emp_rec.empno := emp_rec.empno;
  6      l_emp_rec.ename := emp_rec.ename;
  7      l_emp_rec.sal := emp_rec.sal;
  8      PIPE ROW( l_emp_rec );
  9    end loop;
10    return;
11  end EmpFunc;
12  /
Function created
SQL> select * from TABLE( EMPFUNC( 2000 ) );
     EMPNO ENAME             SAL
      7566 JONES            2975
      7698 BLAKE            2850
      7782 CLARK            2450
      7788 SCOTT            3000
      7839 KING             5000
      7902 FORD             3000
6 rows selected
SQL>

Similar Messages

  • Select from Function PIPELINED on PL/SQL Block

    Hi folks,
    I have a PL/SQL Block and I need this block to show me in a grid the rows from a variable table (Type table) that I have declared.
    I don´t want to create Database objects, that's why I haven´t created tableTest like a type object in the database.
    Example:
    Declare
    type tableTest is table of varchar2(500);
    function test(indName IN VARCHAR2) return tableTest PIPELINED as
    begin
    pipe row (indName);
    pipe row ('teste2');
    return
    end;
    begin
    -- HERE I NEED SHOW ROWS RETURNED BY FUNCTION WAS DECLARED;
    -- Select * from TABLE(test('NAME'));
    end;

    You declare a pipelined table function by specifying the PIPELINED keyword. Pipelined functions can be defined at the schema level with CREATE FUNCTION or in a package. The PIPELINED keyword indicates that the function returns rows iteratively. The return type of the pipelined table function must be a supported collection type, such as a nested table or a varray. This collection type can be declared at the schema level or inside a package. Inside the function, you return individual elements of the collection type. The elements of the collection type must be supported SQL datatypes, such as NUMBER and VARCHAR2. PL/SQL datatypes, such as PLS_INTEGER and BOOLEAN, are not supported as collection elements in a pipelined function.
    http://download-uk.oracle.com/docs/cd/B19306_01/appdev.102/b14261/tuning.htm

  • Select from function with named parameters doesn't work

    Hello,
    I'm trying to execute the next sql statement:
    SELECT mypack.getvalue(user_id => 231, status => 'closed') AS someAlias FROM DUAL;
    I'm getting the next Error:
    Error: ORA-00907: missing right parenthesis
    But the next works fine:
    SELECT mypack.getvalue(231,'closed') AS someAlias FROM DUAL;
    What I'm doing wrong?
    Is there a way to call a Function and return it's result as a single-row query?
    Thanks for any suggestions.

    Thanks for your answers.
    Just want to explain what I want to accomplish:
    I want to create PL/SQL statement which:
    1) Calls Function in named notation way;
    2) Returns a query which contains a single row - a Function result.
    I know in Transact-SQL I can accomplish this the next way:
    DECLARE @return_value INT
    EXEC[myproc]
    @id=2,
    @status='ok',
    @ret_param=@return_value OUTPUT
    SELECT @return_value AS my_return_value
    The last SELECT call returns a query with one row in it.
    How can I do the same in Oracle?
    Thanks a lot!

  • Select from function return rowtype @ db link

    Hi, I am trying to select a row from a function which return a row type @ another DB.
    First DB
    ==========
    Function: fn_something(params) return mytable@snddb%rowtype
    DB Link: snddb
    Second DB
    ==========
    Table: mytable (Column: mycol)
    I have tried to execute query
    select fn_something(params) from dual
    OR
    select mycol from table(fn_something(params))
    but I have got "invalid datatype" error.
    What would be the correct syntax for my query? Thanks.

    Hi Andy,
    Thanks for your reply.
    My function itself has no problem and has been using for a while.
    The function return a rowtype(a table row) and it is using in a stored procedure.
    It could be done in stored procedure but I would like to know if I could call it directly from a query.
    I have just read another thread
    Help - Oracle function w/RETURN VIEW_NAME%ROWTYPE
    which is quite similar to mine
    but I am trying to get a column value from the function and execute an insert statement.
    Could I do it without wrapped by begin end ?

  • SELECT from table vs. CALL FUNCTION

    Hello,
    I have always wondered what the "best practice" is in this case, so I am looking for input.  When writing custom reports etc. in SAP, is it generally regarded as better practice to write a SELECT statement to get a line from say a Txxx configuration table, or is it best to use an associated BAPI or call to function module?  I know in some cases perfomance must obvioulsy be considered, but in terms of SAP's recommendations or upgrade considerations, which is typically better? 
    Assume for example something as simple as getting company code data...  Is it best to do <b>SELECT * FROM T001...</b> or to call a BAPI like <b>BAPI_COMPANYCODE_GETDETAIL</b>?
    Any feedback would be greatly appreciated.

    Hi
    Never accusing people of regarding performance, however I emphasize safety while developing. Even if it is a T* table, I try to use a standard function or call a subroutine of a standard program doing the work. I feel safer this way. Nevertheless, when I can't find any suitable (as of its interface), I use direct SELECT statements.
    If it is a simple report program then doing direct selects may be tolerable. However, if it is a more sophisticated one, especially if it deals with database updates, I highly recommend to use standards.
    As another way, I am aware you mean simple tables, but by the way, if it has a functional relation with a business entity (e.g. pa0001 for employee), I regard it as mandatory using standard FMs where applicable (I feel myself obliged to call "HR_READ_INFOTYPE" instead of using "SELECT* FROM PA0001...").
    *--Serdar

  • How to get result of Select from stored function.

    I need to get result of select from a stored function.
    In the end of my stored function I makes final select (four columns).
    How it can be retrived from function?

    Hi,
    A function can only return one value, but it sounds like you want to return 4 values.
    The one value that you return can be a record, with many columns, such as a ROWTYPE, or a TYPE that you define.
    You can return an XMLTYPE that has whatever elements you want.
    You can write a procedure that has several OUT parameters. (You can have OUT parameters in a function, but a lot of people find that confusing.)
    In very special circumstance, you might consider returning a string that is a delimited list of values, such as '7639,SMITH,,17-DEC-1980'.
    Someoneelse has a good point.
    We could give a better answer if you ask a specific question, like:
    "I have this table ...
    I want a function such that, if I call it with these parameters ... I get ...
    but if I call it like this ... then I get ..."

  • Standard function modules for selection from vbak/vbup/ekko/ekpo

    hi experts ,
    do you know if there is an existing standard function modules for selection from vbak/vbup/ekko/ekpo.
    please help

    Hi,
    for VBAK
    ADSPCM_READ_VBAK               Read VBAK (with SPEC2KM-data)
    PRS_GET_GLOBAL_VBAK            Get global structure VBAK
    Regards,
    Jyothi CH.
    Edited by: Jyothi Chinnabathuni on Feb 23, 2009 2:46 PM

  • Select from local (tmp) Table in Function - Table not found

    Hi,
    I want to create a cursor which selects from a Table which does not exist in database.
    I create this table as local table (how is it called? nested table?).
    Not shown in the code but I want to fill this local table later.
    After filled my cursor is going to use this filled table.
    When try to run I get the error Table or View does not exist at the "FROM TempTab_var T1;" of my cursor.
    This is my simplified code:
    CREATE OR REPLACE FUNCTION PC_RL_MTA_PMT
    RETURN PC_RL_MTA_TYPE_PMT
    IS
    result_out PC_RL_MTA_TYPE_PMT;
      TYPE TempTab_record_type IS RECORD
        (ID int);
      TYPE TempTab_type IS TABLE OF TempTab_record_type
              INDEX BY BINARY_INTEGER;
      TempTab_var TempTab_type;
      CURSOR TempCursor3_var IS
        SELECT    ID AS ID_var
        FROM    TempTab_var T1;
    BEGIN
    RETURN result_out;
    END PC_RL_MTA_PMT;
    Any Ideas whats wrong?
    Thanks very much in advance.

    And a further example from my library of examples, just to help you out...
    SQL> CREATE OR REPLACE TYPE num_descript AS OBJECT(num number, descript varchar2(30))
      2  /
    Type created.
    SQL> CREATE OR REPLACE TYPE tbl_num_descript AS TABLE OF num_descript
      2  /
    Type created.
    SQL> CREATE OR REPLACE PACKAGE reftest AS
      2    FUNCTION pipedata(p_choice number) RETURN tbl_num_descript PIPELINED;
      3  END;
      4  /
    Package created.
    SQL> CREATE OR REPLACE PACKAGE BODY reftest AS
      2    FUNCTION pipedata(p_choice number) RETURN tbl_num_descript PIPELINED IS
      3      v_obj num_descript := num_descript(NULL,NULL);
      4      v_rc  sys_refcursor;
      5    BEGIN
      6      IF p_choice = 1 THEN
      7        OPEN v_rc FOR SELECT empno as num, ename as descript FROM emp;
      8      ELSIF p_choice = 2 THEN
      9        OPEN v_rc FOR SELECT deptno as num, dname as descript FROM dept;
    10      END IF;
    11      LOOP
    12        FETCH v_rc INTO v_obj.num, v_obj.descript;
    13        EXIT WHEN v_rc%NOTFOUND;
    14        PIPE ROW(v_obj);
    15      END LOOP;
    16      CLOSE v_rc;
    17      RETURN;
    18    END;
    19  END;
    20  /
    Package body created.
    SQL> select * from table(reftest.pipedata(1));
           NUM DESCRIPT
          7369 SMITH
          7499 ALLEN
          7521 WARD
          7566 JONES
          7654 MARTIN
          7698 BLAKE
          7782 CLARK
          7788 SCOTT
          7839 KING
          7844 TURNER
          7876 ADAMS
          7900 JAMES
          7902 FORD
          7934 MILLER
    14 rows selected.
    SQL> select * from table(reftest.pipedata(2));
           NUM DESCRIPT
            10 ACCOUNTING
            20 RESEARCH
            30 SALES
            40 OPERATIONS

  • Pipelined function, select from table t1 or t2 depending on user's choise

    Hi all,
    My need is to select data from table t1 or t2 depending on user's choise using pipelined function. You can find my first guess below. Maybe someone can help me to save some code, I mean getting the same result without writing "PIPE ROW" twice.
    FUNCTION fn_indicators (p_datbeg date, p_datend date, p_indicatorid number) return cl_risk_act pipelined IS
    v_obj cl_user_type;
    BEGIN
    case when p_indicatorid = 1 then
    FOR e IN (
    select trunc(sysdate-1) as adate, 0 as cid, 0 as indicatorid, '0' as code, '0' as indicatorname, 0 as value, 0 as cnt, '0' as cname from dual
    LOOP
    v_obj.adate              := e.adate;
    v_obj.cid                  := e.cid;
    v_obj.indicatorid       := e.indicatorid;
    v_obj.code               := e.code;
    v_obj.indicatorname  := e.indicatorname;
    v_obj.value              := e.value;
    v_obj.cnt                 := e.cnt;
    v_obj.cname            := e.cname;
    PIPE ROW (v_obj);
    END LOOP;
    when p_indicatorid = 2 then
    FOR e IN (
    select trunc(sysdate-2) as adate, 1 as cid, 1 as indicatorid, '1' as code, '1' as indicatorname, 1 as value, 1 as cnt, '1' as cname from dual
    LOOP
    v_obj.adate              := e.adate;
    v_obj.cid                  := e.cid;
    v_obj.indicatorid       := e.indicatorid;
    v_obj.code               := e.code;
    v_obj.indicatorname  := e.indicatorname;
    v_obj.value              := e.value;
    v_obj.cnt                 := e.cnt;
    v_obj.cname            := e.cname;
    PIPE ROW (v_obj);
    END LOOP;
    end case;
    RETURN;
    end;

    marco wrote:
    Justin,
    In my real code table real_t1 or pipelinedfn_t2 is joined to other tables, so surely real code is bigger than sample one. It is not wise to keep code twise with only one table name changed. I think about dynamic sql to choose from two tables:
    with t1 as
    (select * from real_t1
    t2 as
    (select * from pipelinedfn_t2
    t3 as (
    [dynamic selection of t1 or t2 depending on user's choise]
    select * from t3, t... where...I don't know correct syntax.
    Any ideas?
    >Justin,
    In my real code table real_t1 or pipelinedfn_t2 is joined to other tables, so surely real code is bigger than sample one. It is not wise to keep code twise with only one table name changed. I think about dynamic sql to choose from two tables:
    with t1 as
    (select * from real_t1
    t2 as
    (select * from pipelinedfn_t2
    t3 as (
    [dynamic selection of t1 or t2 depending on user's choise]
    select * from t3, t... where...I don't know correct syntax.
    Any ideas?
    Dynamic code does NOT scale.
    Making the tradeoff of smaller code size for reduced performance is not one that I would make.

  • Why a function within a SELECT FROM DUAL is faster?

    1)I have a SELECT with a function. Ex:
    "SELECT DISTINCT function(...) FROM table"
    2)I changed the SELECT and put the function inside a SUB-SELECT with FROM DUAL. Ex:
    "SELECT DISTINCT (SELECT function(...) FROM DUAL) FROM table"
    3)The second SELECT is faster than the first.
    I discovered this problem on my tables and my functions. So I did a generic example for this forum with a common function and large table. My results:
    Table has 2.196.058 records and the field is a VARCHAR2:
    SELECT DISTINCT SUBSTR(field, 2) FROM Table -> Executed in 110 seconds
    SELECT DISTINCT (SELECT SUBSTR(field, 2) FROM DUAL) FROM Table -> Executed in 39 seconds
    Why "SELECT DISTINCT (SELECT function(...) FROM DUAL) FROM table" is faster than "SELECT DISTINCT function(...) FROM table"
    thanks,
    Fernando

    Hi hoek,
    I followed your informations and, sorry, I am more confused! I did an interesting example below.
    1)I created a table:
    CREATE TABLE T
         name VARCHAR2(50)
    );     2)I inserted 10 lines:
    NAME                                              
    A                                                 
    B                                                 
    C                                                 
    D                                                 
    E                                                 
    F                                                 
    G                                                 
    H                                                 
    I                                                 
    J                                                  3)I created a function that returns the parameter concatenated with the current millisecond:
    CREATE OR REPLACE FUNCTION f (param1 IN VARCHAR2) RETURN VARCHAR IS
    BEGIN
         return param1 || '-' || to_char(CURRENT_TIMESTAMP, 'FF');
    END;     4)The query(A): SELECT f(name) AS col1, f(name) AS col2, f(name) AS col3 FROM t; gave me:
    COL1        COL2        COL3
    A-693786000 A-693887000 A-693941000
    B-693989000 B-694017000 B-694043000
    C-694071000 C-694097000 C-694124000
    D-694153000 D-694180000 D-694206000
    E-694235000 E-694261000 E-694287000
    F-694316000 F-694341000 F-694367000
    G-694396000 G-694422000 G-694448000
    H-694477000 H-694503000 H-694529000
    I-694557000 I-694583000 I-694609000
    J-694638000 J-694664000 J-694690000If I repeat the SELECT, new values are generated.
    4)The query(B): SELECT (SELECT f(name) FROM Dual) AS col1, (SELECT f(name) FROM Dual) AS col2, (SELECT f(name) FROM Dual) AS col3 FROM t; gave me:
    COL1        COL2        COL3
    A-253546000 A-253643000 A-253746000
    B-253791000 B-253821000 B-253850000
    C-253881000 C-253909000 C-253937000
    D-253969000 D-253997000 D-254026000
    E-254057000 E-254085000 E-254113000
    F-254145000 F-254173000 F-254202000
    G-254232000 G-254261000 G-254289000
    H-254320000 H-254348000 H-254376000
    I-254407000 I-254436000 I-254464000
    J-254495000 J-254523000 J-254551000The result generated new values too.
    5)I changed the function and I put the DETERMINISTIC clause:
    CREATE OR REPLACE FUNCTION f (param1 IN VARCHAR2) RETURN VARCHAR DETERMINISTIC IS
    BEGIN
         return param1 || '-' || to_char(CURRENT_TIMESTAMP, 'FF');
    END;     6)I repeated the queries(A) and (B) and the result has generated different values. Then, with the DETERMINISTIC clause, the result has not changed
    7)I changed the function and I put the RESULT_CACHE clause:
    CREATE OR REPLACE FUNCTION f (param1 IN VARCHAR2) RETURN VARCHAR RESULT_CACHE IS
    BEGIN
         return param1 || '-' || to_char(CURRENT_TIMESTAMP, 'FF');
    END;8)I repeated the query(A) and now, the result was different:
    COL1        COL2        COL3
    A-381048000 A-381048000 A-381048000
    B-381242000 B-381242000 B-381242000
    C-381322000 C-381322000 C-381322000
    D-381400000 D-381400000 D-381400000
    E-381481000 E-381481000 E-381481000
    F-381556000 F-381556000 F-381556000
    G-381634000 G-381634000 G-381634000
    H-381815000 H-381815000 H-381815000
    I-381895000 I-381895000 I-381895000
    J-381971000 J-381971000 J-381971000The line columns are equals and if I repeat the SELECT, all the result is the same too. The query(B) returned the same result like the query(A)! Now I see the cache in action!
    After the tests, I concluded that the function in the subquery doesn't use cache and it is faster than the normal function. The mistery continues...

  • Why select data from Function directly (SE37) got data , but when use funct

    why select data from Function directly (SE37) got data , but when use function in program donot found data
    i use function
    CS_BOM_EXPL_MAT_V2
    when i run function directly at SE37 .
    i found data.
    but when i use same function in program .
    system not found.
    please see my attachment.
    help me please.
    [http://www.quickfilepost.com/download.do?get=c974356a498b3a4d369aa0c50622e50b]
    http://www.quickfilepost.com/download.do?get=c974356a498b3a4d369aa0c50622e50b

    I know why U get empty data.
    In Program U should follow the rules:
    U'd better data a variant typed the function parameters's type.
    for example:
    in your program the parameter: stlal  = '1'
    U'd better like follow:
    Data l_stlal type STKO-STLAL
    l_stlal = '01'.  *Attention: '1' <> '01'.
    stlal  = l_stlal.
    in this way U may have less mistake
    and the parameter MTNRV
    U should use material convernt : "CONVERSION_EXIT_MATN1_INPUT" to change material into internal types before U put into function's parameter.
    why se37 has no problem? because In se37, the data you filled was be processed before use

  • Selecting from a function that returns a sys refcursor or an alternative

    I have a query that returns a resultset of three columns, namely SSN,PAID_YEAR and PAID_TOTAL. From this query I can:
    Create a view and then query it.
    Create a function and return resultset
    If I go the first way a simple query like the following takes more than 20 seconds:
    SELECT PAID_YEAR,PAID_TOTAL FROM VIEW_1 WHERE SSN=12345678912882;
    I know that is because when I query a view the engine first brings all the rows of the view and then it filters the rows for the criteria supplied.
    If I go the second way I can send a parameter and make the engine look only for those rows that match the condition and return the recordset. But I do not know how to then SELECT from that returned resultset. I took a look at pipelined tables but didn't quite get how to benefit them. So my ultimate question is if it's somehow possible to select from the resultset that is returned from a function like this:
    SELECT * FROM FUNCTION_1(12132323232).
    If yes, then how, if no, what would be an alternative way?

    I know that is because when I query a view the engine first brings all the rows of the view and then it filters the rows for the criteria supplied.
    No - you don't 'know that' because it isn't true. Just check the explain plan for yourself. Oracle can still use any appropriate indexes so that only the rows needed are returned.
    So my ultimate question is if it's somehow possible to select from the resultset that is returned from a function like this:
    SELECT * FROM FUNCTION_1(12132323232).
    No - you can't do it like that. You have to use the TABLE function to treat the function result set as a table:
    'SELECT * FROM TABLE(FUNCTION_1(12132323232)).
    -- type to match emp record
    create or replace type emp_scalar_type as object
      (EMPNO NUMBER(4) ,
       ENAME VARCHAR2(10),
       JOB VARCHAR2(9),
       MGR NUMBER(4),
       HIREDATE DATE,
       SAL NUMBER(7, 2),
       COMM NUMBER(7, 2),
       DEPTNO NUMBER(2)
    -- table of emp records
    create or replace type emp_table_type as table of emp_scalar_type
    -- pipelined function
    create or replace function get_emp( p_deptno in number )
      return emp_table_type
      PIPELINED
      as
       TYPE EmpCurTyp IS REF CURSOR RETURN emp%ROWTYPE;
        emp_cv EmpCurTyp;
        l_rec  emp%rowtype;
      begin
        open emp_cv for select * from emp where deptno = p_deptno;
        loop
          fetch emp_cv into l_rec;
          exit when (emp_cv%notfound);
          pipe row( emp_scalar_type( l_rec.empno, LOWER(l_rec.ename),
              l_rec.job, l_rec.mgr, l_rec.hiredate, l_rec.sal, l_rec.comm, l_rec.deptno ) );
        end loop;
        return;
      end;
    select * from table(get_emp(20))

  • Insert problem using a SELECT from table with a index by function TRUNC

    I came across this problem when trying to insert from a select statement, the select returns the correct results however when trying to insert the results into a table, the results differ. I have found a work around by forcing an order by on the select, but surely this is an Oracle bug as how can the select statements value differ from the insert?
    Platform: Windows Server 2008 R2
    Oracle 11.2.3 Enterprise edition
    (I have not tried to replicate this on other versions)
    Here are the scripts to create the two tables and source data:
    CREATE TABLE source_data
      ID                 NUMBER(2),
      COUNT_DATE       DATE
    CREATE INDEX IN_SOURCE_DATA ON SOURCE_DATA (TRUNC(count_date, 'MM'));
    INSERT INTO source_data VALUES (1, TO_DATE('20120101', 'YYYYMMDD'));
    INSERT INTO source_data VALUES (1, TO_DATE('20120102', 'YYYYMMDD'));
    INSERT INTO source_data VALUES (1, TO_DATE('20120103', 'YYYYMMDD'));
    INSERT INTO source_data VALUES (1, TO_DATE('20120201', 'YYYYMMDD'));
    INSERT INTO source_data VALUES (1, TO_DATE('20120202', 'YYYYMMDD'));
    INSERT INTO source_data VALUES (1, TO_DATE('20120203', 'YYYYMMDD'));
    INSERT INTO source_data VALUES (1, TO_DATE('20120301', 'YYYYMMDD'));
    INSERT INTO source_data VALUES (1, TO_DATE('20120302', 'YYYYMMDD'));
    INSERT INTO source_data VALUES (1, TO_DATE('20120303', 'YYYYMMDD'));
    CREATE TABLE result_data
      ID                 NUMBER(2),
      COUNT_DATE       DATE
    );Now run the select statement:
    SELECT id, TRUNC(count_date, 'MM')
    FROM source_data
    GROUP BY id, TRUNC(count_date, 'MM')You should get the following:
    1     2012/02/01
    1     2012/03/01
    1     2012/01/01Now insert into the results table:
    INSERT INTO result_data
    SELECT id, TRUNC(count_date, 'MM')
    FROM source_data
    GROUP BY id, TRUNC(count_date, 'MM');Select from that table and you get:
    1     2012/03/01
    1     2012/03/01
    1     2012/03/01The most recent month is repeated for each row.
    Truncate your table and insert with the following statement and the results should now be correct:
    INSERT INTO result_data
    SELECT id, TRUNC(count_date, 'MM')
    FROM source_data
    GROUP BY id, TRUNC(count_date, 'MM')
    ORDER BY 1, 2;If anyone has encountered this behavior before could you please let me know, I can't see that I am making a mistake as the selects results are correct they should not differ from what is being inserted.
    Edited by: user11285442 on May 13, 2013 5:16 AM
    Edited by: user11285442 on May 13, 2013 6:15 AM

    Hi,
    welcome to the forum. I cannot reproduce the same behavior.
    Could you please post the SQLPlus output while executing all commands, like it has been done by S10390?
    Also post the output of the following command:
    SELECT * FROM v$version;When you put some code or output please enclose it between two lines starting with {noformat}{noformat}
    i.e.:
    {noformat}{noformat}
    SELECT ...
    {noformat}{noformat}
    Formatted code is easier to read.
    Regards.
    Al                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • IR report value from function error

    i have ir report and one column value coming from function,when open the IR report its giving error..
    IR report code
    SELECT CS_ID ,CS_NAME, Util_func(PASS_ID) as "ALERT_DAYS"   from "CSD_MASTERS" Function code
    FUNCTION  Util_func(PASS_ID NUMBER) RETURN number
      IS
    ALERT_DAYS NUMBER:=0;
      BEGIN
       select TO_DATE(CDS_DATE,'DD-MM-YYYY') - TO_DATE(SYSDATE,'DD-MM-YYYY')  
      INTO ALERT_DAYS
       from   CDS_TABBLE
    where   CDS_ID=PASS_ID AND 
    CDS_DATE   between
       sysdate and sysdate+15
       group by  CDS_DATE  HAVING COUNT(*)  <=1  ; 
         IF RECCOUNT>0 THEN
            RETURN ALERT_DAYS;
         ELSE
           RETURN 'null';
         END IF;
      END;function calling CDS_TABBLE value
    CDS_ID -- CDS_DATE
    123 -- -- 4/23/2013
    124 -- -- 4/24/2013
    125 -- -- 4/25/2013
    Thanx,
    Ram
    Edited by: Ramani_vadakadu on Apr 11, 2013 8:56 PM

    FUNCTION  Util_func(PASS_ID NUMBER) RETURN number
    IS
        ALERT_DAYS NUMBER:=0;
        CURSOR lcsr_GetAlertDayCount IS
             select TO_DATE(CDS_DATE,'DD-MM-YYYY') - TO_DATE(SYSDATE,'DD-MM-YYYY')   
            from   CDS_TABBLE
            where   CDS_ID=PASS_ID AND 
                    CDS_DATE   between sysdate and sysdate+15
            group by  CDS_DATE  HAVING COUNT(*)  <=1;         
    BEGIN
        OPEN lcsr_GetAlertDayCount;
        FETCH lcsr_GetAlertDayCount INTO ALERT_DAYS;
        CLOSE lcsr_GetAlertDayCount;
        RETURN ALERT_DAYS;
    END;

  • Can not select from SAPTOOLS.DB6PMCF

    We use third-party tool to monitor our SAP systems. We receive an error
    Can not select from SAPTOOLS.DB6PMCF
    when we monitor DB2 database.
    Function DB6PMCF is registered in SAPSID schema. Can I register it also in SAPTOOLS schema? What is a correct procedure for this?

    Hi Milan,
    I think you have to issue the following command for the affected user.
    db2 "grant execute on function saptools.db6pmcf to <user>"
    regards, Javier Rocha

Maybe you are looking for