Error with function that returns a rowtype...

i have a function that returns a rowtype. below is a simplified version:
create or replace function "GETC"
return mytable%rowtype
is
rec mytable%rowtype;
begin
rec.rowid := 1;
return rec;
end;
eventually i'll want to call this from java. but for now i'd settle for calling it from the XE web front end (and sqlplus).
SQLPLUS: i try to call it from sqlplus by first declaring a variable where i can store the return:
var a mytable%rowtype;
it instantly stops me saying that i can only declare a var of a particular type. so what do i do?
XE interface: i tried various ways to call getc(), but they were all unsuccessful. what should i be doing?
thanks so much for your time.
marko

Given a function like this:
CREATE OR REPLACE FUNCTION get_employee
     ( p_empno emp.empno%TYPE )
     RETURN emp%ROWTYPE
AS
     v_result emp%ROWTYPE;
BEGIN
     SELECT * INTO v_result
     FROM   emp
     WHERE  empno = p_empno;
     RETURN v_result;
END get_employee;You can call it within PL/SQL like this:
DECLARE
     rec emp%ROWTYPE;
BEGIN
     rec := get_employee(7902);
     DBMS_OUTPUT.PUT_LINE(rec.ename);
END;However,
1. Unless there is a column named "ROWID" in the table (unlikely since it would conflict with the actual rowid and is therefore not allowed), the type will not have an attribute named "rowid".
2. "1" would not be a valid rowid anyway.
3. %ROWTYPE defines a PL/SQL type, which will not be recognised in other environments such as SQL and Java.

Similar Messages

  • SOLVED: How can I use or call a function that returns %ROWTYPE?

    Hi
    edit: you can probably skip all this guff and go straight to the bottom...In the end this is probably just a question of how to use a function that returns a %rowtype.  Thanks.
    Currently reading Feuerstein's tome, 5th ed. I've downloaded and run the file genaa.sp, which is a code generator. Specifically, you feed it a table name and it generates code (package header and package body) that will create a cache of the specified table's contents.
    So, I ran:
    HR@XE> @"C:\Documents and Settings\Jason\My Documents\Work\SQL\OPP5.WEB.CODE\OPP5.WEB.CODE\genaa.sp"
    749  /
    Procedure created.
    HR@XE> exec genaa('EMPLOYEES');which generated a nice bunch of code, viz:
    create or replace package EMPLOYEES_cache is
        function onerow ( EMPLOYEE_ID_in IN HR.EMPLOYEES.EMPLOYEE_ID%TYPE) return HR.EMPLOYEES%ROWTYPE;
        function onerow_by_EMP_EMAIL_UK (EMAIL_in IN HR.EMPLOYEES.EMAIL%TYPE) return HR.EMPLOYEES%ROWTYPE;
        procedure test;
    end EMPLOYEES_cache;
    create or replace package body EMPLOYEES_cache is
        TYPE EMPLOYEES_aat IS TABLE OF HR.EMPLOYEES%ROWTYPE INDEX BY PLS_INTEGER;
        EMP_EMP_ID_PK_aa EMPLOYEES_aat;
        TYPE EMP_EMAIL_UK_aat IS TABLE OF HR.EMPLOYEES.EMPLOYEE_ID%TYPE INDEX BY HR.EMPLOYEES.EMAIL%TYPE;
        EMP_EMAIL_UK_aa EMP_EMAIL_UK_aat;
        function onerow ( EMPLOYEE_ID_in IN HR.EMPLOYEES.EMPLOYEE_ID%TYPE)
            return HR.EMPLOYEES%ROWTYPE is
            begin
                return EMP_EMP_ID_PK_aa (EMPLOYEE_ID_in);
            end;
        function onerow_by_EMP_EMAIL_UK (EMAIL_in IN HR.EMPLOYEES.EMAIL%TYPE)
            return HR.EMPLOYEES%ROWTYPE is
            begin
                return EMP_EMP_ID_PK_aa (EMP_EMAIL_UK_aa (EMAIL_in));
            end;
        procedure load_arrays is
            begin
                FOR rec IN (SELECT * FROM HR.EMPLOYEES)
                LOOP
                    EMP_EMP_ID_PK_aa(rec.EMPLOYEE_ID) := rec;
                    EMP_EMAIL_UK_aa(rec.EMAIL) := rec.EMPLOYEE_ID;
                end loop;
            END load_arrays;
        procedure test is
            pky_rec HR.EMPLOYEES%ROWTYPE;
            EMP_EMAIL_UK_aa_rec HR.EMPLOYEES%ROWTYPE;
            begin
                for rec in (select * from HR.EMPLOYEES) loop
                    pky_rec := onerow (rec.EMPLOYEE_ID);
                    EMP_EMAIL_UK_aa_rec := onerow_by_EMP_EMAIL_UK (rec.EMAIL);
                    if rec.EMPLOYEE_ID = EMP_EMAIL_UK_aa_rec.EMPLOYEE_ID then
                        dbms_output.put_line ('EMP_EMAIL_UK  lookup OK');
                    else
                        dbms_output.put_line ('EMP_EMAIL_UK  lookup NOT OK');
                    end if;
                end loop;
            end test;
        BEGIN
            load_arrays;
        end EMPLOYEES_cache;
    /which I have run successfully:
    HR@XE> @"C:\Documents and Settings\Jason\My Documents\Work\SQL\EMPLOYEES_CACHE.sql"
    Package created.
    Package body created.I am now trying to use the functionality within the package.
    I have figured out that the section
        BEGIN
            load_arrays;
        end EMPLOYEES_cache;
    /is the initialization section, and my understanding is that this is supposed to run when any of the package variables or functions are referenced. Is that correct?
    With that in mind, I'm trying to call the onerow() function, but it's not working:
    HR@XE> select onerow(100) from dual;
    select onerow(100) from dual
    ERROR at line 1:
    ORA-00904: "ONEROW": invalid identifier
    HR@XE> select employees_cache.onerow(100) from dual;
    select employees_cache.onerow(100) from dual
    ERROR at line 1:
    ORA-06553: PLS-801: internal error [55018]
    HR@XE> select table(employees_cache.onerow(100)) from dual;
    select table(employees_cache.onerow(100)) from dual
    ERROR at line 1:
    ORA-00936: missing expressionHe provides the code genaa.sp, and a very brief description of what it does, but doesn't tell us how to run the generated code!
    Now, I have just done some googling, and it seems that what I am trying to do isn't possible. Apparently %ROWTYPE is PL/SQL, and not understood by SQL, so you can't call onerow() from sql. Correct?
    So I try wrapping the call in an exec:
    HR@XE> exec select employees_cache.onerow(100) from dual;
    BEGIN select employees_cache.onerow(100) from dual; END;
    ERROR at line 1:
    ORA-06550: line 1, column 30:
    PLS-00382: expression is of wrong type
    ORA-06550: line 1, column 7:
    PLS-00428: an INTO clause is expected in this SELECT statement
    HR@XE> exec select table(employees_cache.onerow(100)) from dual;
    BEGIN select table(employees_cache.onerow(100)) from dual; END;
    ERROR at line 1:
    ORA-06550: line 1, column 14:
    PL/SQL: ORA-00936: missing expression
    ORA-06550: line 1, column 7:
    PL/SQL: SQL Statement ignored
    HR@XE> exec employees_cache.onerow(100)
    BEGIN employees_cache.onerow(100); END;
    ERROR at line 1:
    ORA-06550: line 1, column 7:
    PLS-00221: 'ONEROW' is not a procedure or is undefined
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignoredNo joy.
    Of course, now that I'm looking at it again, it seems that the way to go is indicated by the first error:
    PLS-00428: an INTO clause is expected in this SELECT statement
    So am I supposed to create a type of EMPLOYEES%ROWTYPE in a PL/SQL procedure, and the idea of this code, is that the first call to onerow() runs the initialiation code, which populates the cache, and all subsequent calls to onerow() (whether by my session or any other) will use the cache?
    I've had a stab at this, but still, no joy:
    create or replace procedure testcache is
        emp employees%rowtype;
        begin
            select employees_cache.onerow(100) from dual into emp;
            dbms_output.put_line('Emp id: ' || emp.employee_id);
        end testcache;
    show errors
    HR@XE> @testcache.sql
    Warning: Procedure created with compilation errors.
    Errors for PROCEDURE TESTCACHE:
    LINE/COL ERROR
    4/9      PL/SQL: SQL Statement ignored
    4/54     PL/SQL: ORA-00933: SQL command not properly ended
    HR@XE>Have a feeling this should be really easy. Can anybody help?
    Many thanks in advance.
    Jason
    Edited by: 942375 on 08-Feb-2013 11:45

    >
    Ha, figured it out
    >
    Hopefully you also figured out that the example is just that: a technical example of how to use certain Oracle functionality. Unfortunately it is also an example of what you should NOT do in an actual application.
    That code isn't scaleable, uses expensive PGA memory, has no limit on the amount of memory that might be used and, contrary to your belief will result in EVERY SESSION HAVING ITS OWN CACHE of exactly the same data if the session even touches that package.
    Mr. Feuerstein is an expert in SQL and PL/SQL and his books cover virtually all of the functionality available. He also does an excellent job of providing examples to illustrate how that functionality can be combined and used. But the bulk of those examples are intended solely to illustrate the 'technical' aspects of the technology. They do not necessarily reflect best practices and they often do not address performance or other issues that need to be considered when actually using those techniques in a particular application. The examples show WHAT can be done but not necessarily WHEN or even IF a given technique should be used.
    It is up to the reader to learn the advantages and disadvantages of each technicalogical piece and determine when and how to use them.
    >
    Now, I have just done some googling, and it seems that what I am trying to do isn't possible. Apparently %ROWTYPE is PL/SQL, and not understood by SQL, so you can't call onerow() from sql. Correct?
    >
    That is correct. To be used by SQL you would need to create SQL types using the CREATE TYPE syntax. Currently that syntax does not support anything similar to %ROWTYPE.
    >
    So am I supposed to create a type of EMPLOYEES%ROWTYPE in a PL/SQL procedure, and the idea of this code, is that the first call to onerow() runs the initialiation code, which populates the cache, and all subsequent calls to onerow() (whether by my session or any other) will use the cache?
    >
    NO! That is a common misconception. Each session has its own set of package variables. Any session that touches that package will cause the entire EMPLOYEES table to be queried and stored in a new associative array specifically for that session.
    That duplicates the cache for each session using the package. So while there might be some marginal benefit for a single session to cache data like that the benefit usually disappears if multiple sessions are involved.
    The main use case that I am aware of where such caching has benefit is during ETL processing of staged data when the processing of each record is too complex to be done in SQL and the records need to be BULK loaded and the data manipulated in a loop. Then using an associative array as a lookup table to quickly get a small amount of data can be effective. And if the ETL procedure is being processed in parallel (meaning different sessions) then for a small lookup array the additional memory use is tolerable.
    Mitigating against that is the fact that:
    1. Such frequently used data that you might store in the array is likely to be cached by Oracle in the buffer cache anyway
    2. Newer versions of Oracle now have more than one cache
    3. The SQL query needed to get the data from the table will use a bind variable that eliminates repeated hard parsing.
    4. The cursor and the buffer caches ARE SHARED by multiple sessions globally.
    So the short story is that there would rarely be a use case where ARRAYs like that would be preferred over accessing the data from the table.

  • Error 136 Functions that can be compossed must declare a return type

    Hello,
    I have downloaded the EF Final Release driver and Im working with Oracle 11g express.
    I have the following Procedure:
    PROCEDURE ProductosPedido(
    Datos Out SYS_RefCursor) IS
    BEGIN
    OPEN Datos FOR
    SELECT Nombre,
    TO_NUMBER(Precio * (SELECT SUM(unidades)
    FROM DETALLES_PEDIDO
    WHERE PRODUCTO = PRODUCTO.ID)) Importe
    FROM PRODUCTO;
    END;
    And the following config section:
    <oracle.dataaccess.client>
    <settings>
    <add name="System.Productospedido.RefCursor.Datos" value="implicitRefCursor bindinfo='mode=Output'"/>
    <add name="System.Productospedido.RefCursorMetaData.Datos.Column.0" value="implicitRefCursor metadata='ColumnName=Nombre;BaseColumnName=Nombre;BaseSchemaName=System;BaseTableName=Producto;NativeDataType=nvarchar2;ProviderType=NVarchar2;DataType=System.String;ColumnSize=50;AllowDBNull=true;IsKey=false'" />
    <add name="System.Productospedido.RefCursorMetaData.Datos.Column.1" value="implicitRefCursor metadata='ColumnName=Importe;NativeDataType=number;ProviderType=Decimal;DataType=System.Decimal;AllowDBNull=false;IsKey=false;ColumnSize=8'" />
    </settings>
    </oracle.dataaccess.client>
    I have imported succesfully in my EF Model, but when I try to consume the Procedure it gives me Error 136 Functions that can be compossed must declare a return type
    Any solutions?
    Thanks and best regards!

    A stored procedure does not have a ReturnType, therefore IsComposable="false" and it cannot be used in LINQ queries.
    This limitation is imposed by EF and not by ODP.
    You may want to create a stored function which has a ReturnType ref cursor, and include this stored function into your model. Then, under the same namespace, you create a class with a "stub" method/function and use EdmFunction() to map this stub to the stored function. For example,
    class myFuncClass
    [EdmFunction("Model.Store", "MY_STORED_FUNC_1")]
    public static <your_complex_type_or_DbDataRecord> MyFunc_1(int? column1, ...)
    throw new NotSupportedException("Direct calls are not supported");
    You should be able to call myFuncClass.MyFunc_1(x) in your LINQ query. Your stored function MY_STORED_FUNC_1 will be called in the generated query.

  • Problem with a simple function that return a number

    Hi,
    I'm writing a function that return a number. I receive always an error (invalid number) but I don't understand why.
    The function is this:
    >
    FUNCTION COUNT_OBJECT(workflow_name_p IN NUMBER, object_type_p IN VARCHAR2) RETURN NUMBER
    IS
    object_inserted NUMBER;
    BEGIN
    object_inserted := 0;
    IF workflow_name_p = 'AIMDailyIngestorWorkflow'
    THEN
    object_inserted := 1;
    else
    object_inserted := 100;
    END IF;
    RETURN object_inserted;
    END COUNT_OBJECT;
    I have left only an if and an assignment because I do not find the error.
    When I execute the function I receive always this error:
    ORA-01722: invalid number
    01722. 00000 - "invalid number"
    *Cause:   
    *Action:
    There are not operation, only assignment I cannot understand.
    Could someone help me?
    Thanks bye bye.

    I changed in this way:
    FUNCTION COUNT_OBJECT(workflow_name_p IN VARCHAR2, object_type_p IN VARCHAR2) RETURN NUMBER
    IS
    object_present NUMBER;
    object_inserted NUMBER;
    table_name_p VARCHAR2(4000);
    query_stmt VARCHAR2(4000);
    BEGIN
    IF workflow_name_p = 'AIMDailyIngestorWorkflow'
    THEN
    SELECT SUM(B.STOREDOBJS) INTO object_present
    FROM DPCTJOBTYPESTATS B
    WHERE B.WORKFLOW_NAME = workflow_name_p AND B.OBJTYPE=object_type_p;
    SELECT 'AIM.'||B.TABLE_NAME INTO table_name_p
    FROM DPCTSWOBJTYPE B
    WHERE B.OBJTYPE=object_type_p AND SOFTWARE='AIM';
    EXECUTE IMMEDIATE 'SELECT COUNT(*) FROM ' || table_name_p || ';' INTO object_inserted;
    object_inserted := object_inserted - object_present;
    END IF;
    RETURN object_inserted;
    END COUNT_OBJECT;and now the error is:
    ORA-00911: invalid character
    ORA-06512: at "INFRA.WORKFLOW_STATISTICS", line 504
    00911. 00000 - "invalid character"
    *Cause:    identifiers may not start with any ASCII character other than
    letters and numbers. $#_ are also allowed after the first
    character. Identifiers enclosed by doublequotes may contain
    any character other than a doublequote. Alternative quotes
    (q'#...#') cannot use spaces, tabs, or carriage returns as
    delimiters. For all other contexts, consult the SQL Language
    Reference Manual.
    but the line 504 is the blank line higlighted with the ***.
    Why this error? The code seems correct.
    Thanks, bye bye.

  • I get an error when i try to execute a function that returns a date value

    Hi,
    I'm new in ODP.NET, i'm make a package that contains a function that returns a date i.e.
    Package Body General_pkg is
    Function Get_Day Return Date is
    vd_day date;
    Begin
    select sysdate into vd_day from dual;
    return vd_day;
    end Get_Day;
    End General_pkg;
    i use the next code to execute the function:
    OracleCommand cmdData = new OracleCommand("General_pkg.Get_Day", cnx);
    cmdData.CommandType = Commandtype.StoredProcedure;
    OracleParameter PRM;
    PRM = new OracleParameter();
    PRM.ParameterName = "VDATE";
    PRM.OracleDbType = OracleDbType.Date;
    PRM.Direction = ParameterDirection.ReturnValue;
    cmdData.Parameters.Add(PRM);
    try
    cmdData.ExecuteNonQuery();
    catch(OracleException e);
    When i execute this code, i have and exception, which say "identifier GENERAL_PKG.Get_Day must be declare..."
    Obviously the package is correctly created in ORACLE i tested first in sql plus and it works but in ODP.NET they don't recognize the package or the function i don't know... please help!!!

    OOOOOPSS.... i forgot that i change the user in my conecction string that's why it didn't work...
    i guess i had to much beer last night.;. :)
    thanks.

  • Help - Oracle function w/RETURN VIEW_NAME%ROWTYPE

    I have a fairly complex Oracle function with a signature like this:
    FUNCTION get_some_data
    in_param_one VARCHAR2
    , in_param_two VARCHAR2
    )RETURN VIEW_NAME%ROWTYPE
    (The internal logic of the function is such that it will return at most one row.)
    I have sample code from MSDN that outlines calling functions in .Net, like this:
    // create the command for the function
    OracleCommand cmd = new OracleCommand();
    cmd.Connection = conn;
    cmd.CommandText = "GET_EMPLOYEE_EMAIL";
    cmd.CommandType = CommandType.StoredProcedure;
    // add the parameters, including the return parameter to retrieve
    // the return value
    cmd.Parameters.Add("p_employee_id", OracleType.Number).Value = 101;
    cmd.Parameters.Add("p_email", OracleType.VarChar, 25).Direction =
    ParameterDirection.ReturnValue;
    // execute the function
    conn.Open();
    cmd.ExecuteNonQuery();
    conn.Close();
    // output the result
    Console.WriteLine("Email address is: " + cmd.Parameters["p_email"].Value);
    I don't see an available OracleType to fit the '...%ROWTYPE' return value.
    I think the Oracle code is doing inferred 'table inlining' but it may, instead, be using an inferred refcursor (clearly I'm no DBA). Everything I've been able to find online when googling for how to handle this in .Net doesn't seem to match this situation.
    How can I call this function and get the data back in C#? Please note that I don't have the authority to modify the package to make it explicitly return a refcursor.
    Thank you for any light you can shed!
    MarFarMa

    Here's a "quick and dirty" example using the HR sample schema that I think might be enough to get you going...
    Pl/SQL (used to mimic your function that returns %rowtype):
    create or replace function get_country_row (p_id in varchar2) return countries%rowtype as
      cursor emp_cur is select * from countries where country_id = p_id;
      emp_rec emp_cur%rowtype;
    begin
      open emp_cur;
      fetch emp_cur into emp_rec;
      close emp_cur;
      return emp_rec;
    end;C# Code:
    using System;
    using System.Data;
    using System.Text;
    using Oracle.DataAccess.Client;
    using Oracle.DataAccess.Types;
    namespace RowTypeTest
      /// <summary>
      /// Summary description for Class1.
      /// </summary>
      class Class1
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main(string[] args)
          // create and open connection
          string constr = "User Id=hr; Password=hr; Data Source=oranet; Pooling=false";
          OracleConnection con = new OracleConnection(constr);
          con.Open();
          // build anonymous pl/sql block to get the data
          StringBuilder sbSQL = new StringBuilder();
          sbSQL.Append("declare ");
          sbSQL.Append("  l_country_row countries%rowtype; ");
          sbSQL.Append("begin ");
          sbSQL.Append("  l_country_row   := get_country_row(:p_id); ");
          sbSQL.Append("  :p_country_id   := l_country_row.country_id; ");
          sbSQL.Append("  :p_country_name := l_country_row.country_name; ");
          sbSQL.Append("  :p_region_id    := l_country_row.region_id; ");
          sbSQL.Append("end;");
          // input parameter for country id
          OracleParameter p_id = new OracleParameter();
          p_id.OracleDbType = OracleDbType.Varchar2;
          p_id.Size = 2;
          p_id.Value = "UK";
          p_id.Direction = ParameterDirection.Input;
          // input/output parameter for country id
          // this is redundant but we are selecting * from the table...
          OracleParameter p_country_id = new OracleParameter();
          p_country_id.OracleDbType = OracleDbType.Varchar2;
          p_country_id.Size = 2;
          p_country_id.Direction = ParameterDirection.InputOutput;
          // input/output parameter for country name
          OracleParameter p_country_name = new OracleParameter();
          p_country_name.OracleDbType = OracleDbType.Varchar2;
          p_country_name.Size = 40;
          p_country_name.Direction = ParameterDirection.InputOutput;
          // input/output parameter for region id
          OracleParameter p_region_id = new OracleParameter();
          p_region_id.OracleDbType = OracleDbType.Decimal;
          p_region_id.Direction = ParameterDirection.InputOutput;
          // create command object
          OracleCommand cmd = con.CreateCommand();
          cmd.CommandText = sbSQL.ToString();
          // add parameters to command
          cmd.Parameters.Add(p_id);
          cmd.Parameters.Add(p_country_id);
          cmd.Parameters.Add(p_country_name);
          cmd.Parameters.Add(p_region_id);
          // get the data
          cmd.ExecuteNonQuery();
          // display data retrieved
          Console.WriteLine("{0}, {1}, {2}", p_country_id.Value, p_country_name.Value, p_region_id.Value);
          // clean up objects
          p_region_id.Dispose();
          p_country_name.Dispose();
          p_country_id.Dispose();
          p_id.Dispose();
          cmd.Dispose();
          con.Dispose();
    }Output:
    UK, United Kingdom, 1This only works if the stored function returns a single row and obviously has no error handling, etc. but I hope it helps a bit...
    - Mark

  • Deploy resulset of PL\SQL function, that returns ANYTABLE%TYPE

    How can deploy resulset of PL\SQL function, that returns ANYTABLE%TYPE in SQL?

    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by angelrip:
    Hello everyone,
    I've come through the following problem:
    1.- I created an PL/SQL stored procedure which returns a REF CURSOR element, definition looks like this:
    PACKAGE PKG_LISTADOS AS
    TYPE tuplas IS REF CURSOR;
    /* Procedimientos exportados por el paquete */
    PROCEDURE inicializarModuloListados;
    FUNCTION recaudacionUltimoMes(medioPago DEF_MEDIO_PAGO.MEDIO_PAGO%TYPE)
    RETURN tuplas;
    2.- Now I would like to call the stored procedure and retrieve the PL/SQL cursor as a ResultSet Java Object. The code I wrote is this:
    Connection conn;
    XmlDocument paramDef;
    conn=poolMgr.getConnection str_poolDBConnection);
    try
    CallableStatement cstmt=conn.prepareCall("{?=call PKG_LISTADOS.recaudacionUltimoMes(?)}");
    cstmt.registerOutParameter(1, java.sql.Types.OTHER);
    cstmt.setString(2, "MONEDA");
    cstmt.executeQuery();
    ResultSet rs=(ResultSet)cstmt.getObject(1);
    catch(SQLException sqlE)
    3.- However, I can't make it OK, all the time I get the following error:
    SQL Error(17004), java.sql.SQLException: Non valid column type
    May anyone help me with this, thanks in advance:
    Miguel-Angel<HR></BLOCKQUOTE>
    Do something like the following:
    cstmt = conn.prepareCall("{call customer_proc(?, ?)}");
    //Set the first parameter
    cstmt.setInt(1, 40);
    //Register to get the Cursor parameter back from the procedure
    cstmt.registerOutParameter(2, OracleTypes.CURSOR);
    cstmt.execute();
    ResultSet cursor = ((OracleCallableStatement)cstmt).getCursor(2);
    while(cursor.next())
    System.out.println("CUSTOMER NAME: " + cursor.getString(1));
    System.out.println("CUSTOMER AGE: " + cursor.getInt(2));
    cursor.close();
    null

  • NCo 3 crashes when invoking functions that return a time field

    I'm using NCo 3 (.NET 2 target framework) with Visual Studio 2010. When I invoke a function that returns time fields (like BAPI_ALM_ORDER_GET_DETAIL) NCo crashes with the following message:
    SAP.Middleware.Connector.RfcTypeConversionException: Cannot convert 240000 into TIME (HHmmss)
    I'm currently using NCo version 3.0.0.42. Is there a newer version? Obviously this is a bug inside the NCo library which I can't fix from the outside rendering the connector almost useless.
    Is this a known problem? Does anyone know if it is already fixed in newer revisions of NCo?

    I'm using NCo 3.02 (.NET 4 target framework) with Visual Studio 2010.
    When I invoke a function that returns date fields (like BAPI_SALESORDER_GETLIST) NCo crashes with the following message:
    SAP.Middleware.Connector.RfcTypeConversionException: Cannot convert DOCDATE....
    Below is the code I'm using:
                  Dim customer_orderAPI As IRfcFunction = ecc.Repository.CreateFunction("BAPISALESORDER_GETLIST")
                    customer_orderAPI.SetValue("CUSTOMER_NUMBER", "0000020000")
                    customer_orderAPI.SetValue("SALES_ORGANIZATION", "ARCO")
                    customer_orderAPI.SetParameterActive("MATERIAL", False)
                    customer_orderAPI.SetParameterActive("DOCUMENT_DATE", False)
                    customer_orderAPI.SetParameterActive("DOCUMENT_DATE_TO", False)
                    customer_orderAPI.SetParameterActive("PURCHASE_ORDER", False)
                    customer_orderAPI.SetParameterActive("TRANSACTION_GROUP", False)
                    customer_orderAPI.SetParameterActive("PURCHASE_ORDER_NUMBER", False)
                    customer_orderAPI.SetParameterActive("MATERIAL_EVG", False)
                    customer_orderAPI.Invoke(_ecc)   'I receive the error in this line
                    Dim table As IRfcTable = customer_orderAPI.GetTable("SALES_ORDERS")
                    Dim returnCode As String = customer_orderAPI.GetStructure("RETURN").GetString("TYPE")
                    If (returnCode.Equals("E") Or returnCode.Equals("A")) Then
                        Console.WriteLine(customer_orderAPI.GetStructure("RETURN").GetString("MESSAGE"))
                    Else
                        Console.WriteLine("*********** SUCCESS **********")
                        Console.WriteLine("Number of orders is .", table.RowCount)
                    End If
    Does anyone know what is the issue and how to fix it?

  • NCo 3.02 crashes when invoking functions that return a date field

    I'm using NCo 3.02 (.NET 4 target framework) with Visual Studio 2010.
    When I invoke a function that returns date fields (like BAPI_SALESORDER_GETLIST) NCo crashes with the following message:
    SAP.Middleware.Connector.RfcTypeConversionException: Cannot convert DOCDATE....
    Below is the code I'm using:
    Dim customer_orderAPI As IRfcFunction = ecc.Repository.CreateFunction("BAPISALESORDER_GETLIST")
    customer_orderAPI.SetValue("CUSTOMER_NUMBER", "0000020000")
    customer_orderAPI.SetValue("SALES_ORGANIZATION", "ARCO")
    customer_orderAPI.SetParameterActive("MATERIAL", False)
    customer_orderAPI.SetParameterActive("DOCUMENT_DATE", False)
    customer_orderAPI.SetParameterActive("DOCUMENT_DATE_TO", False)
    customer_orderAPI.SetParameterActive("PURCHASE_ORDER", False)
    customer_orderAPI.SetParameterActive("TRANSACTION_GROUP", False)
    customer_orderAPI.SetParameterActive("PURCHASE_ORDER_NUMBER", False)
    customer_orderAPI.SetParameterActive("MATERIAL_EVG", False)
    customer_orderAPI.Invoke(_ecc)                ' >>>>  I receive the error in this line
    Dim table As IRfcTable = customer_orderAPI.GetTable("SALES_ORDERS")
    Dim returnCode As String = customer_orderAPI.GetStructure("RETURN").GetString("TYPE")
    If (returnCode.Equals("E") Or returnCode.Equals("A")) Then
    Console.WriteLine(customer_orderAPI.GetStructure("RETURN").GetString("MESSAGE"))
    Else
    Console.WriteLine("*********** SUCCESS **********")
    Console.WriteLine("Number of orders is .", table.RowCount)
    End If
    Does anyone know what is the issue and how to fix it?

    I'm using NCo 3.02 (.NET 4 target framework) with Visual Studio 2010.
    When I invoke a function that returns date fields (like BAPI_SALESORDER_GETLIST) NCo crashes with the following message:
    SAP.Middleware.Connector.RfcTypeConversionException: Cannot convert DOCDATE....
    Below is the code I'm using:
    Dim customer_orderAPI As IRfcFunction = ecc.Repository.CreateFunction("BAPISALESORDER_GETLIST")
    customer_orderAPI.SetValue("CUSTOMER_NUMBER", "0000020000")
    customer_orderAPI.SetValue("SALES_ORGANIZATION", "ARCO")
    customer_orderAPI.SetParameterActive("MATERIAL", False)
    customer_orderAPI.SetParameterActive("DOCUMENT_DATE", False)
    customer_orderAPI.SetParameterActive("DOCUMENT_DATE_TO", False)
    customer_orderAPI.SetParameterActive("PURCHASE_ORDER", False)
    customer_orderAPI.SetParameterActive("TRANSACTION_GROUP", False)
    customer_orderAPI.SetParameterActive("PURCHASE_ORDER_NUMBER", False)
    customer_orderAPI.SetParameterActive("MATERIAL_EVG", False)
    customer_orderAPI.Invoke(_ecc)                ' >>>>  I receive the error in this line
    Dim table As IRfcTable = customer_orderAPI.GetTable("SALES_ORDERS")
    Dim returnCode As String = customer_orderAPI.GetStructure("RETURN").GetString("TYPE")
    If (returnCode.Equals("E") Or returnCode.Equals("A")) Then
    Console.WriteLine(customer_orderAPI.GetStructure("RETURN").GetString("MESSAGE"))
    Else
    Console.WriteLine("*********** SUCCESS **********")
    Console.WriteLine("Number of orders is .", table.RowCount)
    End If
    Does anyone know what is the issue and how to fix it?

  • Function that returns currently selected cell address or column

    Is there a function that returns the address (or just the column) of the currently selected cell? Simply put, something like =selectedcolumn.
    Background: I want to display help text in a cell, and I want that help text to change according to which cell (actually, which column) the user has selected. I have put the help texts in a hidden row. They take up too much space to be displayed all the time. I want one cell to contain the help text of the column of the currently selected cell.
    Trying to not use Filemaker for this project if possible
    Thanks for any help /Matt

    The Numbers method, using comments as Barry showed, is probably the best method.  An alternate method which is more complex would be to use an Applescript running in the background.  The Applescript can scan in the background for which cell/column is currently selected and write that cell/column address into a cell in your table. A formula in your table (most likely a lookup formula) can use that address to serve up the correct help text in a diffrerent cell in the table or in another table.
    Some problems with this methodare
    The script is not part of the document. It is a separate entity.
    The script must be started manually. It will not automatically start when the Numbers document is opened.
    If the Numbers document is to be used on other Macs, each would also need the script installed.

  • Is there any function that returns the latest DDL statement

    can anyone tell me if there is any FUNCTION that returns latest DDL statement performed in a schema.
    OR
    if there is any TABLE that will be populated with latest
    DDL statement in schema.
    THANK YOU.

    The table all_objects (and/or dba_objects) contains a column called last_ddl_time. Thus, a query like
    scott@jcave > SELECT max(last_ddl_time)
      2  FROM all_objects
      3 WHERE owner = 'SCOTT';
    MAX(LAST_DDL_TI
    28-NOV-03will tell you the last time any object owned by SCOTT had DDL issued against it.
    Justin
    Distributed Database Consulting, Inc.
    www.ddbcinc.com/askDDBC

  • Function that returns the date/time ?

    We would like to make a validation in the Activity status based on the activity End Time.
    Pls... is there a function that returns something that I could compare with: "8/6/2009 01:00 PM" ?
    I know of Today but I understand that today() returns just the day (no time).
    Txs.
    Antonio

    Hi Antonio,
    You can try using the function -: Timestamp()
    To quote the CRM On Demand help files...
    "+The Timestamp function in Expression Builder returns the server date and time converted to the current user's time zone setting. For example, if the current user's time zone setting is set to Eastern Daylight Time (EDT) -0400 UTC, the Timestamp function converts the server time to EDT. The TimeStamp function performs UTC (universal time code) conversion. NOTE: Arithmetic operations (for example, add or subtract) are not supported with the Timestamp() function.+"
    Hope this helps.
    Regards,
    Cameron

  • Function that returns N values, without using a string

    Hi, how can i make a function that returns several valures (that hasn't a exact number of returned values, it could return 3 values, or 7) without using a string?
    When i need to return several values from a function, i put the values inside a varchar like thus 'XXX,YYY,ZZZ' and so on. Don't know if this has a poor performance.
    If you can supply simple examples for what im asking, i would be nice.
    (without using a string)

    Can i create the type objects inside a package? If i
    can, they will be local to the package, right?Yes, you're right.
    Pipeline returns a row or several?You can use pipelined function in the same way you use table:
    SELECT * FROM TABLE(pipelined_funct(agr1, agr2));
    It returns results as separate rows.

  • How to define a function that returns a void?

    Hi all,
    How can I define a custom function that returns a void?
    My understanding is simple UDF can only return a string.
    Is there any way around this limitation?
    Thanks.
    Ron

    > Hi,
    > User Defined Function in XI always return a String.
    >
    > If you requirement is that you want to perfrom some
    > operation in an user defined function, one option is
    > to move it to the Java Section in your mapping and do
    > it in the intialization / clean up section.
    >
    > Else, wite a UDF that will return a Blank string as
    > the output, and map it to the root node of the
    > target.
    >
    Hi all,
    Thank you all for your kind responses.
    The scenario I have is I need to insert the value of a particular field into a database table. E.g. MessageId, to keep track of the messages going through XI.
    Naturally, such operations return void. These operations are already encapsulated in a custom jar file.
    My purpose of using a UDF is solely to invoke the operation.
    But I realized I each UDF has to have a return type, and the output of this UDF must be mapped to a node in the outgoing message.
    Currently, my UDF returns an empty string, by using the implementation as below, I manage to perform my desired operation without affecting the result:
    MessageId -- UDF -- CONCAT -
    InstitutionCD_Transformed
    InstitutionCode_____
    But as you can see, this is not an elegant way of doing things.
    That's why I'm seeking alternative solutions for this problem.
    Bhavesh, you mentioned something about doing the operation in the initialization/cleanup section.
    Can you please explain more?
    Thanks.
    Ron

  • Error with function returning "multiple" values

    Hi
    i am trying to write a function to return "multiple" values
    however, it returned the following error during compilation
    Compilation errors for FUNCTION sch1.myfn
    Error: PLS-00382: expression is of wrong type
    Line: 19
    Text: RETURN V_res;
    Error: PL/SQL: Statement ignored
    Line: 19
    Text: RETURN V_res;
    ques :
    1 - is there a need to always declare a table ? as it'll only return a single record with multiple columns
    CREATE OR REPLACE TYPE result as table of result_t;
    CREATE OR REPLACE TYPE result_t as object
    (user varchar2(100), comments varchar2(4000));
    CREATE OR REPLACE FUNCTION myfn (IN_ID IN VARCHAR2, IN_BEGIN IN DATE) RETURN result IS
    type V_res_t is RECORD (user varchar2(100), comments varchar2(4000));
    V_res V_res_t;
    BEGIN
    select a.user, a.comment
    into V_res.user, V_res.comments
    from view1     A,
    (select distinct id,
    begin_time,
    max(time) over(order by time desc) max_time from view2 b
    where id = IN_LOTID
    and begin_time = IN_BEGIN) b
    where a.id = b.id
    and a.begin_time = b.begin_time
    and a.time = max_time
    and a.id = IN_ID
    and a.begin_time = IN_BEGIN;
    RETURN V_res; --> this is the line that the system keep complaining
    END;
    Note : pls ignore whether the return results is correct but i am expecting it to always return a single row
    pls advise
    tks & rgds

    And if you really want to return a type as a table of, work with PIPELINED function :
    SQL> CREATE OR REPLACE TYPE result_t as object
      2  (user# varchar2(100), comments varchar2(4000));
      3  /
    Type created.
    SQL> CREATE OR REPLACE TYPE result as table of result_t;
      2  /
    Type created.
    SQL>
    SQL> CREATE OR REPLACE FUNCTION myfn (IN_ID IN VARCHAR2, IN_BEGIN IN DATE) RETURN result
      2  pipelined is
      3  user# varchar2(100);
      4  comments varchar2(4000);
      5  BEGIN
      6  pipe row (result_t(user#,comments));
      7  return;
      8  END;
      9  /
    Function created.
    SQL>PS: there is non sense to use pipelined function in my example, it is just an example to return a type as table.
    Nicolas.

Maybe you are looking for

  • JDBC Connection

    I have a Java Stored Procedure which I deploy to Oracle 9i database. In one of the method I am performing the following operations: Quering a table and storing the values in varibales, befrore inserting I am truncating the table and then inserting th

  • 'Email' address not shown in mail form (file export)

    Hi Gurus, I am working with Campaigns in SAP CRM EHP3. The problem appears when I execute Campaign through communication method "File Export" , because of  'Email' address doesn't appears in the file (although Business partners have them informed). T

  • Enable report view for anonymous acess in sharepoint 2013

    Hi everyone, I hava a problem with rendered reports in .rdlx files from power gallery in sharepoint 2013. My site is enabled for anonymous access but when I try to see a report in anonymous mode ,I have to specify the credentials to see that report.

  • Mac Mini and FinalCut Pro ? OK or ?

    Hi Mac Mini with x2 HD (2.66GHz) suggests to me to be a possibly FCP workstation. Am I right and able to recommend this OR am I missing something IMPORTANT ? Yours very interested Bengt W

  • Java Collections Framework Architectural Flaw

    Here is this flaw (or miss) on design level: public interface Set<E> extends Collection<E>My opinion is that Set<E> should extend List<E> because a List, can BE also (or have the semantics of) a Set. (After all a list CAN have distinct elements) I.e.