Function return type could be sequence?

I tried to write a function return a sequence, but netbeans don't allow it. is it possible? if not, how can I solve it?

Here is an example of a function and a var as a function.
function foo():Integer[] {
        [0..9]
var bar:function():Integer[] = foo;
for ( i in bar() ) println("{i}");

Similar Messages

  • Prior, Next, Shift functions return type?

    I can not point out what is the return type of these functions? numeric value or member?
    And if they return a member would this fomula be valid (i need to take avg value of march and june):
    avgppl = @avgrange("HRsummary" -> "territory",@list(@currmbr("YearTotal"),@shift(@currmbr("YearTotal"),-3)))
    Thanks in advance!

    just use simple arithmetic combined with other functions
    e.g.
    If you want sum of base time periods underneath a summary time period, and make the formula generic to work on base time periods:
    @SUMRANGE(@CURRMBR(Account),@Relative(@CURRMBR(Period),0))/@COUNT(SKIPNONE,@Relative(@CURRMBR(Period),0))
    or, instead if you want the quarter averages at base time periods...
    @SUMRANGE(@CURRMBR(Account),@Relative(@Relative(@CURRMBR(Period),-1),0))/@COUNT(SKIPNONE,@Relative(@Relative(@CURRMBR(Period),-1),0))

  • Column Function Return Type Number is forcing to cast to Decimal

    Hi - I am using Oracle 11g Release 11.2.0.2.0 and ODP.NET 4.112.3.0.
    Whenever I am trying to execute a package query with column function and return type is number, it is throwing cast exception whenever I am trying to cast it as GetInt32.
    The workaround we have for now is to get it decimal and cast to Int32, this is going to be painful moving forward because it means that we have to check each of our packages and need to know if each package has column function and do this special casting.
    Is this a known bug?

    Oracle Number is 6.
    Run the below script to your machine and the sample code below so you can see what I am talking about.
    --drop table aninalfarm;
    --drop table birdfarm;
    --drop public synonym animalfarm;
    --drop public synonym birdfarm;
    --drop public synonym birdfarm_Pkg;
    --drop public synonym animalfarm_Pkg;
    create table animalfarm
            (code                                 NUMBER(6),
            description                        varchar2(10));
    create table birdfarm
           (code                               number(6),
           description                         varchar2(10));
    create public synonym  animalfarm for db.animalfarm;
    create public synonym  birdfarm for db.birdfarm;
    grant select, delete, insert, update on  animalfarm to public;
    grant select, delete, insert, update on  birdfarm to public;
    delete from animalfarm;
    delete from birdfarm;
    commit;
    insert into animalfarm (code, description) values(111122, 'Horse');
    insert into animalfarm (code, description) values(111133, 'Chicken');
    insert into animalfarm (code, description) values(111144, 'Cow');
    insert into animalfarm (code, description) values(111155, 'Pig');
    insert into animalfarm (code, description) values(111166, 'Sheep');
    insert into birdfarm (code, description) values(222, 'Pigeon');
    insert into birdfarm (code, description) values(333, 'Sparrow');
    insert into birdfarm (code, description) values(444, 'Chickadee');
    insert into birdfarm (code, description) values(555, 'Blue Jay');
    insert into birdfarm (code, description) values(666, 'Loon');
    commit;
    create or replace package birdfarm_Pkg is
    function get_key_from_desc(bird_name_in in birdfarm.description%type) return number;
    end birdfarm_Pkg;
    create or replace package body birdfarm_Pkg is
    function get_key_from_desc(bird_name_in in birdfarm.description%type) return number is
    RETURN_VALUE birdfarm.code%TYPE;
    BEGIN
           select code into RETURN_VALUE from birdfarm where description = bird_name_in;
           return RETURN_VALUE;
    end get_key_from_desc;
    END birdfarm_Pkg;
    create or replace package animalfarm_Pkg is
    --region Define Record Type for Strong Type REF CURSOR
    TYPE AnimalFarmRecord is
      RECORD(
                      code animalfarm.code%type,
          description animalfarm.description%type,
                      birdfarm_code birdfarm.code%type
    --endregion
    TYPE animalfarmCur is REF CURSOR RETURN AnimalFarmRecord;
    procedure get_code_two_ways(cur_OUT OUT animalfarmCur);
    end animalfarm_Pkg;
    create or replace package body animalfarm_Pkg is
    procedure get_code_two_ways(cur_OUT OUT animalfarmCur) is
    BEGIN
      open cur_OUT for
           select animalfarm.code,
                  animalfarm.description,
                  birdfarm_pkg.get_key_from_desc('Pigeon') birdfarm_code
           from animalfarm
           order by code;
    end get_code_two_ways;
    END animalfarm_Pkg;
    create public synonym birdfarm_Pkg for db.birdfarm_Pkg;
    grant execute on birdfarm_Pkg to public;
    create public synonym animalfarm_Pkg for db.animalfarm_Pkg;
    grant execute on animalfarm_Pkg to public;
    See the sample code below:
                 var conn = new OracleConnection(OraDB);
                conn.Open();
                conn.ClientId = "Sample";
                var command = new OracleCommand
                                      Connection = conn,
                                      CommandText = "DB.animalfarm_Pkg.get_code_two_ways",
                                      CommandType = CommandType.StoredProcedure
                command.Parameters.Add(new OracleParameter
                                       ParameterName = "cur_OUT",
                                       OracleDbType = OracleDbType.RefCursor,
                                       Direction = ParameterDirection.Output
                OracleDataReader dr = command.ExecuteReader(); // C#
                dr.Read();
                var code =dr.GetInt32(dr.GetOrdinal("Code")); //This is ok
                var description = dr.GetString(dr.GetOrdinal("Description"));
                var codeError = dr.GetInt32(dr.GetOrdinal("birdfarm_code"));//Throw invalid cast exception
                                                                            //because it is column function
                conn.Close();
                conn.Dispose();

  • How to PL/SQL Function returns type

    Hello,
    I need to create a function, which is returning a list of ID's, which is stored in a type T_IDs, something like:
    function search(searchstring in varchar2) return T_IDs
    I have a little problem with filling the type inside the function body using a select statement like
    select id from table where text like searchstring;
    which is selecting a list of ids matching the where-clause. Is it possible to use select into or should I go for another mechanism?
    Thanks for any ideas.

    CoBy wrote:
    Yes, no problem, this is the code I am testing on
    create table texttabelle(
    id          number(10),
    dokument    clob
    +)+
    +/+
    create sequence seq_texttabelle
    +/+
    insert into texttabelle values (seq_texttabelle.nextval, 'A-Partei gewinnt Wahl in Hansestadt');
    insert into texttabelle values (seq_texttabelle.nextval, 'Terror in Nahost: Kriminalität steigt immer weiter an');
    insert into texttabelle values (seq_texttabelle.nextval, 'Wirtschaft: Erneuter Gewinnzuwachs in diesem Jahr');
    insert into texttabelle values (seq_texttabelle.nextval, 'Olympia rückt näher: Der Fackellauf ist in vollem Gange');
    insert into texttabelle values (seq_texttabelle.nextval, 'Wer wird US-Präsident? Obama und Clinton machen Wahlkampf');
    insert into texttabelle values (seq_texttabelle.nextval, 'Papst bestürzt über jüngsten Skandal!');
    insert into texttabelle values (seq_texttabelle.nextval, 'Wahlkampf in den USA geht weiter:  Clinton und Obama LIVE zu sehen');
    insert into texttabelle values (seq_texttabelle.nextval, 'Software-Kenntnisse werden immer wichtiger');
    insert into texttabelle values (seq_texttabelle.nextval, 'Umfrage:  Alle wollen mehr Geld!');
    insert into texttabelle values (seq_texttabelle.nextval, 'Der Papst liest seine erste Messe in den USA!');
    commit
    +/+
    create index idx_text on texttabelle (dokument)
    indextype is ctxsys.context
    +/+
    CREATE OR REPLACE type T1 as object (
    numero number(2)
    +);+
    +/+
    The desired function has following specification:
    CREATE OR REPLACE FUNCTION fkt_search (search_str IN VARCHAR2) RETURN T1;
    The select statement I would like to use is:
    SELECT id
    FROM texttabelle
    WHERE contains (dokument, search_str) > 0;
    As I said, I cannot construct the correct select into - statement to fill the T1 with the result ID's from above.
    ThanksYour problem is that you are returning a single object from your function, not a collection of them.

  • Function return type

    I have a return string from function contains more than 4000 bytes.
    But VARCHAR2(4000) is only 4000 bytes.
    Is there ay way we can return more than 4000
    Thanks a lot for the help
    Prasad

    You could create a nested table within this function...this nested table can be of type varchar2(4000).
    Cut your string into various pieces as elements of this nested table..and you can reconcat yuor string when this function is returned.
    Sameer

  • How to execute a function returning type in oracle

    hi
    i want to execute a function which is returning table from oracle prompt.
    i have created type in order to return table from function.
    /*creating type
    CREATE OR REPLACE TYPE U_VOC.t_in_list_tab AS OBJECT (i_group NUMBER ,
                                  i_company number,
                                  i_estab number
    NOT FINAL ;
    CREATE OR REPLACE TYPE U_VOC.t_in_list_tab_type
    AS TABLE OF U_VOC.t_in_list_tab;
    /*function */
    CREATE OR REPLACE FUNCTION FU_VOC_S_VEHICLES(pi_group number,
                                                      pi_company number,
                                                 pi_estab number
         RETURN t_in_list_tab
    AS
    v_nb_idvehicle           U_REF.V_REF_VEHICLES.NB_IDVEHICLE%type ;
    v_vc_reference           U_REF.V_REF_VEHICLES.VC_REFERENCE%type ;
    v_vc_licenceplate      U_REF.V_REF_VEHICLES.VC_LICENCEPLATE%type ;
    l_tab t_in_list_tab := t_in_list_tab( pi_group ,pi_company, pi_estab );
    BEGIN
              SELECT      V_REF_VEHICLES.NB_IDVEHICLE,
                   V_REF_VEHICLES.VC_REFERENCE,
                   V_REF_VEHICLES.VC_LICENCEPLATE
              INTO      V_NB_IDVEHICLE,
                   V_VC_REFERENCE,
                   V_VC_LICENCEPLATE
              FROM      U_REF.V_REF_VEHICLES
              WHERE      V_REF_VEHICLES.NB_IDGROUP = pi_group
              AND      V_REF_VEHICLES.NB_IDCOMPANY = pi_company
              AND      V_REF_VEHICLES.NB_ESTABL = pi_estab;
    RETURN l_tab;
    END;
    please help
    Thank in advance
    Sandy

    Sandy,
    I have a series of examples on this issue in my demo application. See this one:
    http://htmldb.oracle.com/pls/otn/f?p=31517:146
    You will basicaly need to write it like this:
    CREATE OR REPLACE TYPE u_voc.t_in_list_tab AS OBJECT (
       i_group     NUMBER,
       i_company   NUMBER,
       i_estab     NUMBER
    CREATE OR REPLACE TYPE u_voc.t_in_list_tab_type AS TABLE OF u_voc.t_in_list_tab;
    CREATE OR REPLACE FUNCTION fu_voc_s_vehicles (
       pi_group     NUMBER,
       pi_company   NUMBER,
       pi_estab     NUMBER
       RETURN t_in_list_tab PIPELINED
    AS
       l_tab   t_in_list_tab := t_in_list_tab (NULL, NULL, NULL);
    BEGIN
       FOR c IN (SELECT v_ref_vehicles.nb_idvehicle, v_ref_vehicles.vc_reference,
                        v_ref_vehicles.vc_licenceplate
                   FROM u_ref.v_ref_vehicles
                  WHERE v_ref_vehicles.nb_idgroup = pi_group
                    AND v_ref_vehicles.nb_idcompany = pi_company
                    AND v_ref_vehicles.nb_establ = pi_estab)
       LOOP
          l_tab.i_group := c.nb_idvehicle;
          l_tab.i_company_number := c.vc_reference;
          l_tab.estab_number := vc_licenceplate;
       END LOOP;
       RETURN l_tab;
    END;
    SELECT *
      FROM TABLE (fu_voc_s_vehicles (value1, value2, value3))But looking at your code, your function will return only one record.
    Denes Kubicek
    http://deneskubicek.blogspot.com/
    http://www.opal-consulting.de/apex/f?p=107:7
    http://htmldb.oracle.com/pls/otn/f?p=31517:1
    -------------------------------------------------------------------

  • OracleDbType for function OBJECT return type

    Hi all,
    I inherited an oracle function that has an object as a return type:
    create or replace TYPE OBJECTPATH IS OBJECT (OBJECTID NUMBER);
    create or replace TYPE OBJECTPATH_TAB AS TABLE OF OBJECTPATH;
    create or replace FUNCTION GETOBJECTINPATH ( pobjectid in NUMBER, role1 varchar2, role2 varchar2 ) RETURN OBJECTPATH_TAB
    IS
    v_tmp_tab OBJECTPATH_TAB:=OBJECTPATH_TAB();
    parentid NUMBER;
    rowno INTEGER;
    BEGIN
    rowno:=0;
    parentid:=pobjectid;
    loop
    select objectid into parentid from dual left join (select ro2.objectid from relationshipobject ro1, relationshipobject ro2
    where ro1.role=role1 and ro2.role=role2 and ro1.relationshipid=ro2.relationshipid and ro1.objectid=parentid)
    on 1=1;
    if parentid is null then
    exit;
    end if;
    v_tmp_tab.extend;
    rowno:=rowno1;+
    v_tmp_tab(rowno) := OBJECTPATH(parentid);
    end loop;
    RETURN v_tmp_tab;
    END;
    On my application side, I am trying to run this function and retrieve the return value with ODP.NET as below. However, I am stumped when I need to supply an OracleDbType for the function return type.
    1. What is the OracleDbType I should use for the return type? I read that there used to be support for OracleDbType.Object, but it seems like it is now not supported. I am using ODP.NET 11g. Am I getting the situation correct?
    2. If retrieving an object return type is not as straightforward as setting the parameters (as what I have done below), what is the workaround to achieve it?
    OracleCommand runGetPObjectInPathCmd = new OracleCommand("GETOBJECTINPATH", conn);
    runGetPObjectInPathCmd.CommandType = CommandType.StoredProcedure;
    runGetPObjectInPathCmd.Parameters.Add(new OracleParameter("pobjectid", OracleDbType.Decimal)).Value = pobjectId;
    runGetPObjectInPathCmd.Parameters["pobjectid"].Direction = ParameterDirection.Input;
    runGetPObjectInPathCmd.Parameters.Add(new OracleParameter("role1", OracleDbType.Varchar2, 255)).Value = role1;
    runGetPObjectInPathCmd.Parameters["role1"].Direction = ParameterDirection.Input;
    runGetPObjectInPathCmd.Parameters.Add(new OracleParameter("role2", OracleDbType.Varchar2, 255)).Value = role2;
    runGetPObjectInPathCmd.Parameters["role2"].Direction = ParameterDirection.Input;
    runGetPObjectInPathCmd.Parameters.Add("OBJECTPATH_TAB", OracleDbType.Decimal); // this is not correct as the return type is not a NUMBER
    runGetPObjectInPathCmd.Parameters["OBJECTPATH_TAB"].Direction = ParameterDirection.ReturnValue;
    runGetPObjectInPathCmd.ExecuteNonQuery();
    Thanks in advance for any help and would greatly appreciate it.

    Hi Greg,
    Thanks for your reply. I am not exactly sure whether I am using 11.1.0.6.21. The Oracle.DataAccess.dll I see under my \ODP.NET\bin\2.x directory is of Assembly/Product Version 2.111.6.0 - is this version 11.1.0.6.21? I also do not have the samples directory. Am I working on a wrong version? Thanks for your patience as I am really new to this and appreciate your guidance.

  • Same functions with different return types in C++

    Normally the following two functions would be considered the same:
    int getdata ( char *s, int i )
    long getdata ( char *s, int i )
    Every other compiler we use would resolve both of these to the same function. In fact, it is not valid C++ code otherwise.
    We include some 3rd party source in our build which sometimes messes with our typedefs causing this to happen. We have accounted for all of the function input types but never had a problem with the return types. I just installed Sun ONE Studio 8, Compiler Collection and it is generating two symbols in our libraries every time this occurs.
    Is there a compiler flag I can use to stop it from doing this? I've got over 100 unresolved symbols and I'd rather not go and fix all of them if there is an easier way.

    Normally the following two functions would be
    considered the same:
    int getdata ( char *s, int i )
    long getdata ( char *s, int i )Not at all. Types int and long are different types, even if they are implemented the same way.
    Reference: C++ Standard, section 3.9.1 paragraph 10.
    For example, you can define two functions
    void foo(int);
    void foo(long);
    and they are distinct functions. The function that gets called depends on function overload resolution at the point of the call.
    Overloaded functions must differ in the number or the type of at least one parameter. They cannot differ only in the return type. A program that declares or defines two functions that differ only in their return types is invalid and has undefined behavior. Reference: C++ Standard section 13.1, paragraph 2.
    The usual way to implement overloaded functions is to encode the scope and the parameter types, and maybe the return type, and attach the encoding to the function name. This technique is known as "name mangling". The compiler generates the same mangled name for the declaration and definition of a given function, and different mangled names for different functions. The linker matches up the mangled names, and can tell you when no definition matches a reference.
    Some compilers choose not to include the return type in the mangled name of a function. In that case, the declaration
    int foo(char*);
    will match the definition
    long foo(char*) { ... }
    But it will also match the definitions
    myClass foo(char*) { ... }
    double foo(char*) { ... }
    You are unlikely to get good results from such a mismatch. For that reason, and because a pointer-to-function must encode the function return type, Sun C++ always encodes the function return type in the mangled name. (That is, we simplify things by not using different encodings for the same function type.)
    If you built your code for a 64-bit platform, it would presumably link using your other compilers, but would fail in mysterious ways at run time. With the Sun compiler, you can't get into that mess.
    To make your program valid, you will have to ensure your function declarations match their definitions.

  • DLL return type and parmaters

    I must access a DLL developped by VC++ via LV6i with the 'Call Library function'. Everythimg is fine, but the DLL function return type is bool, and I don't find the bool data type in the 'Call library parameter'.
    Secondly, I must pass parameters to this DLL function. Parameters type are : std::vector and GUID. How can I pass this type of parameters ??
    Function is : bool MyFunction (const GUID &guidMyGuid, std::vector &MyVector).
    Thanks in advance.

    You can't, you have to create a CIN that reshapes this parameters to something LabView understand.

  • Problem when calling a return type BOOLEAN SQL Function in a package

    Hi All,
    I am having problem when trying to call a SQL function in a package with return type BOOLEAN
    The SQL function signature is as follows
    CREATE OR REPLACE PACKAGE RMSOWNER.ORDER_ATTRIB_SQL ****
    FUNCTION GET_PO_TYPE_DESC(O_error_message IN OUT VARCHAR2,
    I_PO_TYPE       IN     VARCHAR2,
    O_PO_TYPE_DESC  IN OUT VARCHAR2)
    RETURN BOOLEAN;
    Following is my java code
    +CallableStatement cs3 = conn.prepareCall("{?=call ORDER_ATTRIB_SQL.GET_PO_TYPE_DESC(?,?,?)}");+
    +cs3.registerOutParameter(1, java.sql.Types.BOOLEAN);+
    +cs3.registerOutParameter(2, java.sql.Types.VARCHAR);+
    +cs3.registerOutParameter(4, java.sql.Types.VARCHAR);+
    +cs3.setString(2, "");+
    +cs3.setString(3, "ST");+
    +cs3.setString(4, "");+
    +ResultSet rs3 = cs3.executeQuery();+
    I get the following exception, i tried changing the sql type(registerOutParameter) from boolean to bit but i still getting this exception.
    But when i call any other functions with return type other than boolean they work perfectly fine.
    Please can anyone help me fix this issue, i am not sure if its anything to do with vendor JDBC classes?
    +java.sql.SQLException: ORA-06550: line 1, column 13:+
    +PLS-00382: expression is of wrong type+
    +ORA-06550: line 1, column 7:+
    +PL/SQL: Statement ignored+
    +     at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)+
    +     at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331)+
    +     at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288)+
    +     at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:743)+
    +     at oracle.jdbc.driver.T4CCallableStatement.doOall8(T4CCallableStatement.java:215)+
    +     at oracle.jdbc.driver.T4CCallableStatement.executeForRows(T4CCallableStatement.java:954)+
    +     at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1168)+
    +     at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3316)+
    +     at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:3422)+
    +     at oracle.jdbc.driver.OracleCallableStatement.execute(OracleCallableStatement.java:4394)+
    #####

    Hello People!
    There is another workaround!!
    See the example below:
    private String callBooleanAPi(String tableName,String apikey,String dtInicio,String dtFim,String comando) throws SQLException {
                   CallableStatement cs = null;
                   String call = "";
                   String retorno = null;
                   try {
                        if(comando.equalsIgnoreCase("INSERT")){
                             call = "declare x BOOLEAN; y varchar2(2);begin x :=PKG.INSERT(?,?,?,?,?); if x then y := 'S'; else y :='N'; end if; ? := y;end;";
                        } else if(comando.equalsIgnoreCase("UPDATE")){
                             call = "declare x BOOLEAN; y varchar2(2);begin x := PKG.UPDATE(?,?,?,?,?); if x then y := 'S'; else y :='N'; end if; ? := y;end;";
                        } else if(comando.equalsIgnoreCase("DELETE")){
                             call = "declare x BOOLEAN; y varchar2(2);begin x := PKG.DELETE(?,?,?,?,?); if x then y := 'S'; else y :='N'; end if; ? := y;end;";
                        cs = conn.prepareCall(call);
                        SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
                        SimpleDateFormat sdfToSqlDate = new SimpleDateFormat("yyyy-MM-dd");
                        java.util.Date dataInicialVigencia =null;
                        java.util.Date dataFinalVigencia = null;
                        Date dtInicialFormatada =null;
                        Date dtFinalFormatada = null;
                        if(dtInicio != null && !dtInicio.equals("")){
                             dataInicialVigencia = sdf.parse(dtInicio);
                             dtInicio =sdfToSqlDate.format(dataInicialVigencia);
                             dtInicialFormatada = Date.valueOf(dtInicio);
                        if(dtFim != null && !dtFim.equals("")){
                             dataFinalVigencia = sdf.parse(dtFim);
                             dtFim =sdfToSqlDate.format(dataFinalVigencia);
                             dtFinalFormatada = Date.valueOf(dtFim);
                        cs.setString(1, tableName);
    cs.setString(2, apikey);
    cs.setDate(3, dtInicialFormatada );
    cs.setDate(4, dtFinalFormatada );
    cs.registerOutParameter(5, java.sql.Types.VARCHAR);
    cs.registerOutParameter(6, java.sql.Types.VARCHAR );
    cs.execute();
                        retorno = cs.getString(6);
                        System.out.println( cs.getString(5));
                   } catch(SQLException e){
                   throw new SQLException("An SQL error ocurred while calling the API COR_VIGENCIA: " + e);
                   } catch(Exception e){
                   Debug.logger.error( "Error calculating order: " + id, e );
                   } finally {
                   if (cs != null) {
                   cs.close();
                   cs = null;
                   return retorno;
    As you can see the CallableStatement class acepts PL/SQl blocks.
    Best Regards.

  • How to make a function return number(10,0) data type (ORACLE 10g)?

    With 10g, how to make a function return number(10,0) data type?
    here is the function, it returns a number type :
    create or replace FUNCTION Get_portfolio_Id3 (p_HistObjTable In Varchar2,p_LHISTOBJID IN NUMBER) RETURN view_cpu_STD_Asset.LPORTFOLIOITEMID%Type IS
    v_Id view_cpu_STD_Asset.LPORTFOLIOITEMID%Type;
    BEGIN
    If p_HistObjTable ='amPortfolio'
    then v_Id:=p_LHISTOBJID ;
    elsIf p_HistObjTable = 'amComputer' then
    select litemid into v_Id from smcdba.amComputer c where c.LCOMPUTERID=p_LHISTOBJID ;
    else v_Id:=-99;
    End If;
    RETURN v_Id;
    END Get_portfolio_Id3;
    Thanks.
    Message was edited by:
    user631701

    create or replace FUNCTION Get_portfolio_Id3 (p_HistObjTable In Varchar2,p_LHISTOBJID IN NUMBER) RETURN view_cpu_STD_Asset.LPORTFOLIOITEMID%Type IS
    v_Id view_cpu_STD_Asset.LPORTFOLIOITEMID%Type;
    BEGIN
    If p_HistObjTable ='amPortfolio'
    then v_Id:=p_LHISTOBJID ;
    elsIf p_HistObjTable = 'amComputer' then
    select litemid into v_Id from smcdba.amComputer c where c.LCOMPUTERID=p_LHISTOBJID ;
    else v_Id:=-99;
    End If;
    RETURN round(v_Id);
    END Get_portfolio_Id3;

  • Function returning more than one row in type

    SQL> create or replace package types
    2 as
    3 type cursorType is ref cursor;
    4 end;
    5 /
    Package created.
    SQL> create or replace function sp_ListEmp return types.cursortype
    2 as
    3 l_cursor types.cursorType;
    4 begin
    5 open l_cursor for select rowid from emp;
    6 return l_cursor;
    7* end;
    8 /
    Function created.
    SQL> select sp_listEmp from dual;
    SP_LISTEMP
    CURSOR STATEMENT : 1
    CURSOR STATEMENT : 1
    ROWID
    AAAHW7AABAAAMUiAAB
    AAAHW7AABAAAMUiAAC
    AAAHW7AABAAAMUiAAD
    AAAHW7AABAAAMUiAAE
    AAAHW7AABAAAMUiAAF
    AAAHW7AABAAAMUiAAG
    AAAHW7AABAAAMUiAAH
    AAAHW7AABAAAMUiAAI
    AAAHW7AABAAAMUiAAJ
    when i execute select * from emp where rowid in(select sp_listEmp from dual);
    I am not getting output Please help me
    Message was edited by:
    Oracle_Friend

    Pipelined function can help you :
    SCOTT@demo102> ed
    Wrote file afiedt.buf
      1* create or replace type EmpRowid as table of varchar2(64);
    SCOTT@demo102> /
    Type created.
    SCOTT@demo102> ed
    Wrote file afiedt.buf
      1  create or replace function emp_rowid
      2    RETURN EmpRowid
      3    PIPELINED
      4  IS
      5  BEGIN
      6    FOR x IN (select rowid from emp)
      7    LOOP
      8      PIPE ROW( x.rowid );
      9    END LOOP;
    10    RETURN;
    11* END;
    SCOTT@demo102> /
    Function created.
    SCOTT@demo102> select * from table( emp_rowid );
    COLUMN_VALUE
    AAAMfPAAEAAAAAgAAA
    AAAMfPAAEAAAAAgAAB
    AAAMfPAAEAAAAAgAAC
    AAAMfPAAEAAAAAgAAD
    AAAMfPAAEAAAAAgAAE
    AAAMfPAAEAAAAAgAAF
    AAAMfPAAEAAAAAgAAG
    AAAMfPAAEAAAAAgAAH
    AAAMfPAAEAAAAAgAAI
    AAAMfPAAEAAAAAgAAJ
    AAAMfPAAEAAAAAgAAK
    AAAMfPAAEAAAAAgAAL
    AAAMfPAAEAAAAAgAAM
    AAAMfPAAEAAAAAgAAN
    14 rows selected.
    SCOTT@demo102> select *
      2  from emp
      3  where rowid in (select column_value from table( emp_rowid ));
         EMPNO ENAME      JOB              MGR HIREDATE        SAL       COMM
        DEPTNO
          7369 SMITH      CLERK           7902 17/12/80       8000
            20
          7499 ALLEN      SALESMAN        7698 20/02/81      16000        300
            30
          7521 WARD       SALESMAN        7698 22/02/81      12500        500
            30
         EMPNO ENAME      JOB              MGR HIREDATE        SAL       COMM
        DEPTNO
          7566 JONES      MANAGER         7839 02/04/81      29750
            20
          7654 MARTIN     SALESMAN        7698 28/09/81      12500       1400
            30
          7698 BLAKE      MANAGER         7839 01/05/81      28500
            30
         EMPNO ENAME      JOB              MGR HIREDATE        SAL       COMM
        DEPTNO
          7782 CLARK      MANAGER         7839 09/06/81      24500
            10
          7788 SCOTT      ANALYST         7566 19/04/87      30000
            20
          7839 KING       PRESIDENT            17/11/81      50000
            10
         EMPNO ENAME      JOB              MGR HIREDATE        SAL       COMM
        DEPTNO
          7844 TURNER     SALESMAN        7698 08/09/81      15000          0
            30
          7876 ADAMS      CLERK           7788 23/05/87      11000
            20
          7900 JAMES      CLERK           7698 03/12/81       9500
            30
         EMPNO ENAME      JOB              MGR HIREDATE        SAL       COMM
        DEPTNO
          7902 FORD       ANALYST         7566 03/12/81      30000
            20
          7934 MILLER     CLERK           7782 23/01/82      13000
            10
    14 rows selected.
    SCOTT@demo102> You can add parameters to the function for restrict the result.
    Nicolas.

  • Can Evaluate function return object type

    Hi
    Evaluate function can be used to call db functions in OBIEE. I have a function which returns an object ( pl/sql table).
    Created a simple report in Oracle Answers and added following in one of the columns
    evaluate( 'get_ccid(%1)' as t_ccid , @{p_request})
    When I try to run this in Oracle answers, getting syntax error. If same function returns varchar or number it works well.

    evaluate( 'get_ccid(%1)' as t_ccid , @{p_request})Eakta, You syntax seems to be wrong here. What type of data your presentation variable contains here ?? You are saying its working fine with Number datatype..so can you try..somthing like below with some default value..
    EVALUATE('get_ccid(%1)',@{p_request}{2})
    OR
    EVALUATE('get_ccid(%1)' as varchar(250),@{p_request}{ABC})
    Also, refer
    Syntax for Evaluate function in OBIEE
    http://108obiee.blogspot.com/2009/04/using-presentation-variable-from-first.html
    Hope its useful

  • Function with return type boolean

    I have created a function with return type boolean as:
    CREATE OR REPLACE FUNCTION fn RETURN BOOLEAN
    AS
    exp EXCEPTION;
    BEGIN
    return TRUE;
    EXCEPTION
    when OTHERS then RAISE exp;
    END;
    FUNCTION fn compiledThen I was trying to call this function into dbms_output.put_line procedure, I got this error:
    EXECUTE DBMS_OUTPUT.PUT_LINE(fn);
    ORA-06550: line 1, column 7:
    PLS-00306: wrong number or types of arguments in call to 'PUT_LINE'Can someone please help me understand, why this happened?
    Is this because of boolean return type?

    952040 wrote:
    I have created a function with return type boolean as:
    Then I was trying to call this function into dbms_output.put_line procedure, I got this error:
    EXECUTE DBMS_OUTPUT.PUT_LINE(fn);
    ORA-06550: line 1, column 7:
    PLS-00306: wrong number or types of arguments in call to 'PUT_LINE'
    What is the parameter signature for DBMS_OUTPUT.put_line() ?
    Is is string - as detailed in Oracle® Database PL/SQL Packages and Types Reference guide.
    So how can you pass a boolean data type as parameter value, when the parameter's data type is string?
    PL/SQL supports implicit data conversion. So you can for example pass a number or date value to DBMS_OUTPUT.put_line() - and the PL/SQL engine automatically (and implicitly) converts that (using the TO_CHAR() functions) to a string.
    However, the TO_CHAR() parameter signature supports number and date - not boolean. It cannot convert a boolean value into a string.
    So passing a boolean value means the implicit conversion fails - and results in the above error.
    To make it work, you need to perform an explicit conversion. As as a data type conversion function from boolean to string is not available, you need to write a user defined function. E.g.
    SQL> create or replace function BoolToChar( b boolean ) return varchar2 is
      2  begin
      3    case
      4       when b then return( 'TRUE' );
      5       when not b then return( 'FALSE' );
      6    else
      7      return( null );
      8    end case;
      9  end;
    10  /
    Function created.
    SQL>
    SQL> exec DBMS_OUTPUT.put_line( 'Flag is '||BoolToChar(true) );
    Flag is TRUE
    PL/SQL procedure successfully completed

  • Return type Boolean From Oracle Function

    1. How do I get a return type of Boolean from Oracle function in Java?
    2. I have a function fx overloaded in Oracle (8 variances) and I have trouble getting the right one in Java. Is 8 too high a figure or Java does not support calling overloaded functions or what?
    Thanks for any help.

    I am facing a similar situation, where I have defined an overloaded function in one package (2 variants) which both return a type BOOLAN value.
    I am having trouble to setting up an CallableStatemnt to call one of this functions from Java. Whenever I set the parameter with a BIT or NUMBER data type, I get an exception with java.lang.boolean during my
    callablestatement.setobject( indez, parameter, OracleTypes.BIT );
    or
    callablestatement.setobject( indez, parameter, OracleTypes.NUMBER );
    I have no problem calling the function from SQLPlus, but doing so from Java raises the exception. I have found no exact match in OracleTypes or java.sql.Types for a BOOLEAN data type.
    In your response do you mean to modify the Function to return a NUMBER instead of a BOOLEAN, or do you mean to set the parameter as Types.NUMBER in the calling java code?
    Thanks,
    Fedro

Maybe you are looking for