Debugging Pipelined function in SQLDeveloper

Hi All,
I have a pipelined function and I am trying to process the rows returned from the function within a cursor. The basic layout of the PROCEDURE IS
CURSOR C1 IS
SELECT * FROM TABLE(tab_function(CURSOR(SELECT * FROM MYTAB)));
BEGIN
FOR R1 IN C1 LOOP
INSERT R1 INTO MYTAB2
END LOOP;
END;
When I run this in SQL*PLUS the procedure, works for while until it hits a genuine bug.
However, if I try to debug the procedure in SQLDeveloper, it processes the first row correcly. But when it returns to the FOR..LOOP statement for the second row it falls over.
I am inserting into a table within the loop but this is outside of the table function which should (at least in this case) behave as a normal table.
Can anybody please help?
Regards,
Leo

there is an active SQL Developer OTN forum, this may help - http://forums.oracle.com/forums/search.jspa?threadID=&q=Debugging+Pipelined+function&objID=f260&dateRange=all&userID=&numResults=15&rankBy=10001

Similar Messages

  • How to debug "pipelined parallel enable table function" ?

    Dear All,
    Normally we can retrieve output from a "pipelined parallel enable table function " by using SQL statement, such as
    select output from table(pipelined_function(arg1));
    Can anyone alight me how to call this function purely using PL/SQL statement?
    Reason for this : We have third party developer develooped a complicate "pipelined parallel enable table function" and this function is currently calling by SQL (select output from table(pipelined_function(arg1));
    ), I will like to debug this function, but unable to do so, so far I have done :
    1) compile function with debug option
    2) using Procedure Builder to debug, if I execute the above statement (select output from table(pipelined_function(arg1)); I believe, Procedure Builder will not debug a function from a SQL statement
    3) try to build up a PL/SQL block, but don't know how to it.
    basically I want to debug this "pipelined parallel enable table function " and don't know how to do it, any example will be greate!

    user2302827 wrote:
    Using dbms_output is fine but too tedious. I was looking for a PL/SQL procedure builder that can help to debug a statement like this:
    select output from table(pipelined_function(arg1));
    Any suggestion?I don't know about any procedure builders.
    There is a debugger you can use, though I'd have to think about how to invoke it to use with a pipelined function. The debugger is available in GUI tools like SQL*Developer and TOAD and can be used to walk through a program and set values

  • Interactive Report using a View with a Pipelined Function

    Hello fellow Apex people,
    I'm Using Application Express 4.1.0.00.32
    I've got an interactive report that references a view (STOCK) and a pipelined function
    The basic query is listed below.
    SELECT S.CHANGED_TIME "Changed Time"
    , S.CHANGED_BY "Changed By"
    , S.ID "Id"
    , STKST_DESCRS.STOCK_STATUS_CODES "Stock Status Codes"
    , STKST_DESCRS.STOCK_STATUS_DESCRS "Stock Status"
    , S.ORIGINAL_CONTAINER "Original Container"
    FROM STOCK S
    , table(LWS_StkstStatus (S.ID)) STKST_DESCRS
    ORDER BY S.CO_ID,
    S.SEQUENCE_NUM;
    When the page is first run all the data is displayed correctly,
    If I define a filter, sort or a blank search the data from the pipelined function (STKST_DESCRS.) becomes null and isn't displayed.
    Does anyone know what is happening?
    Many Thanks

    I'm curious why you find this dangerous. I want a report that looks like this:
    Opportunity X:
    4 - 2-apr-2008 - Closed deal
    3 - 1-mar-2008 - Called Joe again
    2 - 12-feb-2008 - Called Joe
    1 - 14-jan-2008 - Initial call with customer.
    When you enter a new note, I want it to be numbered 5. The only problem I can imagine is someone deleting a note, which will almost never happen, and if it does, it just leaves a numbering gap. I don't see how using the function in a SELECT will accomplish this.

  • How can I debug a Function Module used by smartforms

    Hello everyone,
    i have a problem with the function module /1BCDWB/SF00000040.
    It's a module executed from a smartforms form. I need to debug this
    function module while printing an invoice. While printing it should jump
    to the place of the function module.
    Would be grateful if someone could help me.
    Best regards
    F. Hoppe

    This is exactly what i have done last time.
    The problem is that the breakpoint does not stay at the same place
    when i activate it in the module itself.
    Isn't there a transaction you can put breakpoints specific to a FM?

  • List View Report with pipelined function in Mobile application and ORA-01007: variable not in select list

    Hi!
    I have a problem with List View Report in mobile application (theme 50 in apex) after updating to apex 4.2.2. I created Report -> List View. I used select from pipelined function in Region Source. Then when page is running and submited three times (or refreshed three times) I get an error:
    Error during rendering of region "LIST VIEW".
    ORA-01007: variable not in select list
    Technical Info (only visible for developers)
    is_internal_error: true
    apex_error_code: APEX.REGION.UNHANDLED_ERROR
    ora_sqlcode: -1007
    ora_sqlerrm: ORA-01007: variable not in select list
    component.type: APEX_APPLICATION_PAGE_REGIONS
    component.id: 21230833903737364557
    component.name: LIST VIEW
    error_backtrace:
         ORA-06512: at "APEX_040200.WWV_FLOW_DISP_PAGE_PLUGS", line 4613
         ORA-06512: at "APEX_040200.WWV_FLOW_DISP_PAGE_PLUGS", line 3220
    I get this error only when I use select from pipelined function in Region Source (for example: "select value1, value2 from table(some_pipelined_function(param1, param2)) ").
    You can check it on http://apex.oracle.com/pls/apex/f?p=50591 (login - demo, password - demo).
    In this application:
    - I created package TAB_TYPES_PKG:
    create or replace PACKAGE TAB_TYPES_PKG IS
    TYPE cur_rest_r IS RECORD (
        STR_NAME          VARCHAR2(128),
        INFO              VARCHAR2(128)
    TYPE cur_rest_t IS TABLE OF cur_rest_r;
    END TAB_TYPES_PKG;
    - I created pipelined function TEST_FUNC:
    create or replace
    FUNCTION TEST_FUNC
    RETURN TAB_TYPES_PKG.cur_rest_t  PIPELINED IS
    r_cur_rest TAB_TYPES_PKG.cur_rest_r;
    BEGIN
    r_cur_rest.STR_NAME := 'ROW 1';
    r_cur_rest.INFO := '10';
    PIPE ROW (r_cur_rest);
    r_cur_rest.STR_NAME := 'ROW 2';
    r_cur_rest.INFO := '20';
    PIPE ROW (r_cur_rest);
    r_cur_rest.STR_NAME := 'ROW 3';
    r_cur_rest.INFO := '30';
    PIPE ROW (r_cur_rest);
    r_cur_rest.STR_NAME := 'ROW 4';
    r_cur_rest.INFO := '40';
    PIPE ROW (r_cur_rest);
    r_cur_rest.STR_NAME := 'ROW 5';
    r_cur_rest.INFO := '50';
    PIPE ROW (r_cur_rest);
    RETURN;
    END TEST_FUNC;
    - I created List View Report on Page 1:
    Region Source:
    SELECT str_name,
           info
    FROM TABLE (TEST_FUNC)
    We can see error ORA-01007 after refresing (or submiting) Page 1 three times or more.
    How to fix it?

    Hi all
    I'm experiencing the same issue.  Predictably on every third refresh I receive:
    Error
    Error during rendering of region "Results".
    ORA-01007: variable not in select list
    Technical Info (only visible for developers)
    is_internal_error: true
    apex_error_code: APEX.REGION.UNHANDLED_ERROR
    ora_sqlcode: -1007
    ora_sqlerrm: ORA-01007: variable not in select list
    component.type: APEX_APPLICATION_PAGE_REGIONS
    component.id: 6910805644140264
    component.name: Results
    error_backtrace: ORA-06512: at "APEX_040200.WWV_FLOW_DISP_PAGE_PLUGS", line 4613 ORA-06512: at "APEX_040200.WWV_FLOW_DISP_PAGE_PLUGS", line 3220
    OK
    I am running Application Express 4.2.2.00.11 on GlassFish 4 using Apex Listener 2.0.3.221.10.13.
    Please note: this works perfectly using a classic report in my desktop application; however, no joy on the mobile side with a list view.  I will use a classic report in the interim.
    My region source is as follows:
    SELECT description AS "DESCRIPTION", reference AS "REFERENCE" FROM TABLE(AUTOCOMPLETE_LIST_VIEW_FNC('RESULTS'))
    The procedure:
      FUNCTION AUTOCOMPLETE_LIST_VIEW_FNC(
          p_collection_name IN VARCHAR2)
        RETURN list_row_table_type
      AS
        v_tab list_row_table_type := list_row_table_type();
      BEGIN
        DECLARE
          jsonarray json_list;
          jsonobj json;
          json_clob CLOB;
        BEGIN
          SELECT clob001
          INTO json_clob
          FROM apex_collections
          WHERE collection_name = p_collection_name;
          jsonobj              := json(json_clob);
          jsonarray            := json_ext.get_json_list(jsonobj, 'predictions');
          FOR i IN 1..jsonArray.count
          LOOP
            jsonobj := json(jsonArray.get(i));
            v_tab.extend;
            v_tab(v_tab.LAST) := list_row_type(json_ext.get_string(jsonobj, 'description'), json_ext.get_string(jsonobj, 'reference'));
          END LOOP;
          RETURN(v_tab);
        END;  
      END AUTOCOMPLETE_LIST_VIEW_FNC;
    Thanks!
    Tim

  • Debugging RFC function module from ECC to CRM

    Hi All,
    My requirement is to debug an RFC function module present in CRM(7.0) system from ECC(6.0) system. A report program in ECC will call CRM custom FM. I found many posts in SDN with the same issue and tried to implement suggestions provided there. But I couldn't succeed. The approach I followed is:
    I logged in to ECC report program and kept an external breakpoint just before the function module call.
    I logged in to CRM system, opened the function module and kept an external breakpoint there.
    In both the systems I provided the dialogue userid( id through which I log in to SAPGUI) in the system->settings->debugging option.
    In CRM I activated the external break point in  transaction SRDEBUG.
    Now when I execute the report program in ECC, control stops at the breakpoint. If I press F5 at the function call, control is not going to the external break point set in the CRM FM. I am getting output of FM directly.
    I tried with different settings like turning on the check box for IP matching and session breakpoint active immediate, switching to classic debugger etc. I also tried to provide the RFC user id instead of dialogue user but system throws exception saying only dialogue userids are allowed. I found that by inserting an infinite loop statement, control goes inside the RFC CRM FM but I prefer not to change the code.
    Please let me know if I missed anything.
    Thanks and Regards,
    Naren

    Hi,
    Debug RFC calls
    When an RFC function module is called it is usually not possible to debug the call, using the below techniques we can achieve the same. For this example we are calling an RFC enabled FM in ECC system from CRM system.
    Scenario 1: Calling a custom RFC FM
    STEP 1: Add an infinite loop in the remote custom Function Module (adding a u201CDO. ENDDO.u201D statement at the start of the FM would be enough).
    STEP 2: Execute your program in the CRM system. The execution stops at the RFC call, because of the infinite loop.
    STEP 3: Now login to the ECC system and go to transaction SM51 select the process which is executing the RFC and navigate to the menu: u201CProgram/Session->Program->Debuggingu201D this triggers the debugger session in a separate window.
    Scenario 2: Calling a Standard RFC FM
    When we are debugging a standard program we cannot add the infinite loop, hence we cannot go to SM51 and debug the work process. The RFC destination for the ECC system has a User specified, the RFC function module gets executed using this users credentials. Usually the basis team set up the RFC user as non Dialog user, this does not allow debugging. Contact your Basis team and get this changed to a dialog user enabling you to debug RFC function calls via the normal debugger.
    Note: User name configured in the RFC destination (transaction SM59) 
    Note: User type for the RFC User (transaction SU01D)
    Hope this will be helpful..

  • Pipelined function in reports6i....1

    Hi,
    i have a problem with using pipelined function in
    reports6i.
    can i use pipelined function in reports6i.
    The following code is used to return rows
    based on the parameter i am passing:
    my package declaration and body is as follows:
    PACKAGE P_RET_ARRAY IS
    TYPE array1 AS TABLE OF NUMBER;
    FUNCTION ret_array(str VARCHAR2)
    RETURN ARRAY1 PIPELINED;
    END;
    PACKAGE BODY P_RET_ARRAY IS
    FUNCTION ret_array(str VARCHAR2)
    RETURN ARRAY1 pipelined
    IS
    str1 VARCHAR2(100);
    num1 NUMBER(5);
    BEGIN
    str1 := str ||',';
    WHILE LENGTH(str1)>=0
    LOOP
    num1 := TO_NUMBER(SUBSTR(str1,1,INSTR(str1,',',1)-1));
    pipe (num1);
    str1 := SUBSTR(str1,INSTR(str1,',',1)+1);
    END LOOP;
    --NULL;
    RETURN ;
    END;
    END;
    I got the above piece of code from one of the oracle forums:
    now if i am trying to use this code in my reports6i it's not recognizing
    pipelined.any suggestions plz .
    it's urgent....

    Hi,
    i have a problem with using pipelined function in
    reports6i.
    can i use pipelined function in reports6i.
    The following code is used to return rows
    based on the parameter i am passing:
    my package declaration and body is as follows:
    PACKAGE P_RET_ARRAY IS
    TYPE array1 AS TABLE OF NUMBER;
    FUNCTION ret_array(str VARCHAR2)
    RETURN ARRAY1 PIPELINED;
    END;
    PACKAGE BODY P_RET_ARRAY IS
    FUNCTION ret_array(str VARCHAR2)
    RETURN ARRAY1 pipelined
    IS
    str1 VARCHAR2(100);
    num1 NUMBER(5);
    BEGIN
    str1 := str ||',';
    WHILE LENGTH(str1)>=0
    LOOP
    num1 := TO_NUMBER(SUBSTR(str1,1,INSTR(str1,',',1)-1));
    pipe (num1);
    str1 := SUBSTR(str1,INSTR(str1,',',1)+1);
    END LOOP;
    --NULL;
    RETURN ;
    END;
    END;
    I got the above piece of code from one of the oracle forums:
    now if i am trying to use this code in my reports6i it's not recognizing
    pipelined.any suggestions plz .
    it's urgent....

  • Pipelined function with lagre amount of data

    We would like to use pipelined functions as source of the select statements instead of tables. Thus we can easily switch from our tables to the structures with data from external module due to the need for integration with other systems.
    We know these functions are used in situations such as data warehousing to apply multiple transformations to data but what will be the performance in real time access.
    Does anyone have any experience using pipelined function with large amounts of data in the interface systems?

    It looks like you have already determined that the datatable object will be the best way to do this. When you are creating the object, you must enter the absolute path to your spreadsheet file. Then, you have to create some type of connection (i.e. a pushbutton or timer) that will send a true to the import data member of the datatable object. After these two things have been done, you will be able to access the data using the A3 - K133 data members.
    Regards,
    Michael Shasteen
    Applications Engineering
    National Instruments
    www.ni.com/ask
    1-866-ASK-MY-NI

  • How do you pass parameters to a Pipelined function?

    I am using Oracle 10G and the ODP .NET 32 bit client.
    I am facing an issue trying to use variable binding with a pipeline function in Oracle. I am using ODP .NET for connecting to the database.
    If you want to be familiar with PIPELINED functions, you can read [this  blog.|http://oradim.blogspot.com/2007/10/odpnet-tip-using-pipelined-functions.html]
    I have very similar code with a difference. My function takes in two parameters that I need to pass to get the table. This is working in SQLPLUS without any issues.
    In my C# code, however things change. My function no longer returns a recordset (data reader), if I use the standard method of assigning the parameters.
    The code will work if I concat the variables in a string.
    Here is the example that doesn't work.
            static OracleDataReader fetchData(OracleConnection oc, string strPONumber)
                try
                    OracleCommand od = oc.CreateCommand();
                    od.CommandType = System.Data.CommandType.Text;
                    od.CommandText = "select * from table(pkg_fetchPOInfo.getPORowsTable(:1,:2))";
                    OracleParameter op1 = new OracleParameter();
                    op1.ParameterName = "1";
                    op1.OracleDbType = OracleDbType.Varchar2;
                    op1.Direction = System.Data.ParameterDirection.Input;
                    op1.Size = 7;
                    op1.Value = strPONumber;
                    od.Parameters.Add(op1);
                    OracleParameter op2 = new OracleParameter();
                    op2.ParameterName = "2";
                    op2.OracleDbType = OracleDbType.Varchar2;
                    op2.Direction = System.Data.ParameterDirection.Input;
                    op2.Size = 3;
                    op2.Value = "US";
                    od.Parameters.Add(op2);
                    OracleDataReader or = od.ExecuteReader();
                    return or;
                catch (Exception e)
                    Console.WriteLine("Error " + e.ToString());
                    return null;
            }Here is the example that does.
          static OracleDataReader fetchData(OracleConnection oc, string strPONumber)
                try
                    OracleCommand od = oc.CreateCommand();
                    string formSQL = "Select * from table(pkg_fetchPOInfo.getPORowsTable('"+strPONumber+"','US'))";
                    od.CommandType = System.Data.CommandType.Text;
                    od.CommandText = formSQL;
                    OracleDataReader or = od.ExecuteReader();
                    return or;
                catch (Exception e)
                    Console.WriteLine("Error " + e.ToString());
                    return null;
            }

    throw it into an anonymous block and it should work for you.
    --create or replace type varcharTableType as table   of varchar2 (4000);
    create or replace
    PACKAGE TESTP AS
      function TESTPIPE(nr in number, nr2 in number) return varchartabletype pipelined;
    END TESTP;
    CREATE OR REPLACE
    PACKAGE BODY TESTP AS
      function TESTPIPE(nr in number, nr2 in number) return varchartabletype pipelined AS
          CURSOR TESTPIPE_cur
           IS
              SELECT (level + 1) datam
                FROM dual
              connect by level < nr;
         vtt varchartabletype ;
      BEGIN
             OPEN TESTPIPE_cur;
               LOOP
                  FETCH testpipe_cur
                  BULK COLLECT INTO vtt LIMIT nr2;
                  FOR indx IN 1 .. vtt.COUNT
                  LOOP
                      Pipe Row ( vtt( indx ) )  ;
                  END LOOP;
                  EXIT WHEN testpipe_cur%NOTFOUND;
               END LOOP;
      END TESTPIPE;
    END TESTP;
           public static void pipeTest()
                String conString = GetConnectionString();
                OracleConnection _conn = new OracleConnection(conString);
                _conn.Open();
                OracleCommand oCmd = new OracleCommand();
                oCmd.CommandText = "begin open :crs for Select * from table(testp.testpipe(:nr,:nr2)); end;";
                oCmd.CommandType = CommandType.Text ;
                oCmd.Connection = _conn;
                OracleParameter crs = new OracleParameter();
                crs.OracleDbType = OracleDbType.RefCursor;
                crs.Direction = ParameterDirection.Output;
                crs.ParameterName = "crs";
                oCmd.Parameters.Add(crs);
                OracleParameter nr = new OracleParameter();
                nr.OracleDbType = OracleDbType.Int64;
                nr.Direction = ParameterDirection.Input ;
                nr.ParameterName = "nr";
                nr.Value = 25;
                oCmd.Parameters.Add(nr);
                OracleParameter nr2 = new OracleParameter();
                nr2.OracleDbType = OracleDbType.Int64;
                nr2.Direction = ParameterDirection.Input;
                nr2.ParameterName = "nr2";
                nr2.Value = 10;
                oCmd.Parameters.Add(nr2);
                using (OracleDataReader MyReader = oCmd.ExecuteReader())
                    int ColumnCount = MyReader.FieldCount;
                    // get the data and add the row
                    while (MyReader.Read())
                        String s = MyReader.GetOracleValue(0).ToString();
                        Console.WriteLine(string.Format("i={0}", s));
                Console.ReadLine();
            }

  • Turning sql  string (with dynamic columns) into a pipelined function

    Hi guys,
    I was working on an apex report the other day, and wrote the sql below (for those who don't know apex well, in an apex report you can define the columns at runtime.) When I was finished, I said to myself: "It would be great to have a pipeline function with this capability." So, the idea would be to have a sql string where the columns are created dynamically, depending on input parameters - and then be able to use this sql everywhere (oracle reports, sqlplus) through a pipelined function.
    Here's the sql (simplified, of course, the data itself is actually not important - the LOOP is the key)
    declare
    v_sql varchar2(4000);
    begin
    v_sql := 'select client, ';
    for i in (select employee from company_employees_view where condition = pi_parameter order by 1) loop
    v_sql := v_sql || sum(decode(employee,''' || i.employee || ''', total)) "' || i.employee || '"';
    end loop;
    v_sql := v_sql || ', sum(total) "Total"';
    v_sql := v_sql || ' from company_employees_view group by client';
    end;
    This sql would result in a final product like:
    select client
    , sum(decode(employee,'John',total) "John"
    , sum(decode(employee,'Paul',total) "Paul"
    , sum(decode(employee,'George',total) "George"
    (and so on... this sql could have more or less columns depending on the input parameters of the function)
    from company_employees_view
    group by client;
    I have tried feeding this sql into a ref cursor and an object, but always received an "inconsistent datatypes" message.
    The object would be something like:
    create or replace object rt_employee as (total number);
    create or replace tt_employee as table of rt_employee;
    create or replace object rt_client as (
    client varchar2(100),
    employee tt_employee);
    create or replace tt_client as table of rt_client;
    (I am not paying too much attention to syntax here.)
    By the way, no hurry whatsoever, this is just for fun, take your time. I am using database XE with apex 2.1 and sql developer 1.2.
    Thanks, Roger

    This is the only solution I've ever seen to dynamic pipelined columns...
    How to pipeline a function with a dynamic number of columns?

  • Help w/MaxDB Function; also: how does the "Debug SQL" function work?

    Hi there forum folks,
    In my former life, I was a Basis guy, but I haven't had the pleasure of working directly with SAP applications in a few months.  My current project is to attempt to use MaxDB in a real estate environment.  We're tracking home listings so that we can build statistical reports... such as "what agents are in the Top 100 in postal code X?"
    Anyway, as part of this project, I have attempted to construct my very first MaxDB database function.  Unfortunately, it doesn't give me the answers I'm hoping to see.  Here's the function:
    CREATE FUNCTION COUNT_LISTINGS (AGENTID CHAR(10)) RETURNS FIXED(6,1) AS
      VAR COLISTINGAGENTID CHAR(10);
          LISTINGAGENTID   CHAR(10);
          MLSNUMBER        CHAR(7);
          UNITS            FIXED(6,1);
      SET UNITS = 0;
      DECLARE FUNCTIONRESULT CURSOR FOR
        SELECT MLSNUMBER,
               LISTINGAGENTID,
               COLISTINGAGENTID FROM FREDDIE.GLAR_SOLDS
         WHERE LISTINGAGENTID = :agentid OR COLISTINGAGENTID = :agentid;
      IF $COUNT IS NULL THEN
        BEGIN
          CLOSE FUNCTIONRESULT;
          RETURN UNITS;
        END
      ELSE
        SET $RC = 0;
      WHILE $RC = 0 DO BEGIN
        FETCH FUNCTIONRESULT INTO :mlsnumber, :listingagentid, :colistingagentid;
        IF ( LISTINGAGENTID   = AGENTID AND COLISTINGAGENTID IS NULL ) OR
           ( COLISTINGAGENTID = AGENTID AND LISTINGAGENTID   IS NULL ) THEN
          SET UNITS = UNITS + 1
        ELSE
          SET UNITS = UNITS + 0.5;
      END;
    CLOSE FUNCTIONRESULT;
    RETURN UNITS;
    I've tried to follow the official MaxDB documentation.  My first deviation from that standard was the use of the "$COUNT" variable (instead of the "$RC" variable) immediately after the DECLARE/SELECT statement above.  When I tried to use $RC, for either a successful or unsuccessful query, $RC was always set to a non-zero value.
    I believe I'm past that, but now my issue is down around that FETCH statement.  The UNITS variable doesn't end up with the value I expect.  I know that it can be terribly confusing to try to analyze someone else's logic, but here's a brief narrative that describes what I'm trying to do...
    The GLAR_SOLDS table holds one line for each home sold.  It's keyed by the MLSnumber.  Each record also stores up to four agents who've been involved in the transaction: the listing agent, the co-listing agent, the selling agent, and the co-selling agent.  The database function I've written above pertains to the listing side only.  If I can get this to work, a separate function will process the selling side.  If no co-listing agent is involved in a given sell, that agent should get credit for 1 unit sold.  If he/she has help from a co-listing agent, the agent should only get credit for 1/2 unit sold.
    Also, does anyone know how the "Debug SQL" functionality is supposed to work within Database Studio?  When I right-mouse click on my function, and follow the path thru "Debug As...", after entering the connection & function arguments, I'm presented with an empty screen.  If you could point me to some documentation somewhere, I'd gratefully read it.
    I'm using MaxDB 7.7.06.09 on Windows XP (WIN32) with MaxDB Database Studio 7.7.06.09 (build 009-123-202-944).
    Thanks everyone for your help & advice.
    ~Fred

    Fred,
    please either provide the full SQL statements for your example or stick with mine.
    I'm not going to build it up myself a second time to suit yours now.
    >  But now, my issue is how do I store the resultant data in its own table?
    So where is the problem?
    INSERT INTO <target table> (field 1, field 2, ...)  (<your query>)  UDPATE DUPLICATES-
    With my tables this looks like this:
    create table sell_result (list_agent varchar(20) primary key, SUM_CREDIT fixed (10,2))
    insert
    into sell_result (list_agent,sum_credit)
        ( select list_agent, sum (credit) as SUM_CREDIT
          from ( select sh.object_id,lag.name as list_agent, 1 as credit
                 from soldhomes sh join agents lag on lag.id = sh.list_agent_id
                union all
                 select sh.object_id, lag.name as list_coagent, 0.5 as credit
                 from soldhomes sh join agents lag on lag.id = sh.list_coagent_id
          group by list_agent
    update duplicates
    Check what we have now
    sqlcli db770=> select * from sell_result
    | LIST_AGENT           | SUM_CREDIT        |
    | -------------------- | ----------------- |
    | Lars                 |              4.50 |
    | Lisa                 |              3.00 |
    | Mona                 |              2.50 |
    | Paul                 |              2.50 |
    4 rows selected (600 usec)
    Now add some sales data...
    Insert into soldhomes values (11, 1, 2, NULL, NULL)
    Insert into soldhomes values (12, 2, NULL, NULL, NULL)
    Insert into soldhomes values (13, 2, NULL, NULL, NULL)
    Re-run the INSERT command and you're done:
    sqlcli db770=> select * from sell_result
    | LIST_AGENT           | SUM_CREDIT        |
    | -------------------- | ----------------- |
    | Lars                 |              5.50 |
    | Lisa                 |              3.00 |
    | Mona                 |              5.00 |
    | Paul                 |              2.50 |
    4 rows selected (390 usec)
    Neat, isn't it?

  • Pass multiple values as single input parameter into pipelined function

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

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

  • ORA-22905 with pipelined function

    Hi,
    I have a strange behaviour that I do not understand.
    The code below does not work. It gives me the following errors:
    ORA-22905: cannot access rows from a non-nested table item
    ORA-06512: at line 10
    ORA-06512: at line 19
    The problem comes from the line 14 in that function
    adm_usergroup.GET_GROUPIDS (userid_in)
    If I replace the variable userid_in by its values then it perfectly works.
    Can someone give me an explanation ?
    The adm_usergroup.GET_GROUPIDS (userid_in) is a pipelined function that querry a group of tables and return IDs which are number.
    A call to the function works fine as using it directly in a select statement.
    Cheers,
    Sebastien
    1 DECLARE
    2 l_groups AUTH_TYPE.GROUP_RT;
    3 l_groups_rec authgroup%ROWTYPE;
    4
    5 FUNCTION GET_GROUPS (userid_in IN AUTHUSER.USERID%TYPE)
    6 RETURN AUTH_TYPE.GROUP_RT
    7 IS
    8 l_groups_rt AUTH_TYPE.GROUP_RT;
    9 BEGIN
    10 OPEN l_groups_rt FOR
    11 SELECT ag.*
    12 FROM authgroup ag
    13 WHERE AG.GROUPID IN
    14 (SELECT * FROM table (adm_usergroup.GET_GROUPIDS (userid_in)));
    15
    16 RETURN l_groups_rt;
    17 END GET_GROUPS;
    18 BEGIN
    19 l_groups := GET_GROUPS (1);
    20
    21 LOOP
    22 FETCH l_groups INTO l_groups_rec;
    23
    24 EXIT WHEN l_groups%NOTFOUND;
    25 DBMS_OUTPUT.put_line ('ID: ' || l_groups_rec.groupid);
    26 END LOOP;
    27
    28 CLOSE l_groups;
    29 END;

    by the way here is the full code
    CREATE OR REPLACE PACKAGE AUTHDB.ADM_USERGROUP
    IS
       -- get the group and sub-group ids of a given user id
       FUNCTION get_groupids (userid_in IN AUTHUSER.USERID%TYPE)
          RETURN authgroup_set
          PIPELINED;
    END;
    CREATE OR REPLACE PACKAGE BODY AUTHDB.ADM_USERGROUP
    IS
    FUNCTION get_groupids (userid_in IN AUTHUSER.USERID%TYPE)
          RETURN authgroup_set
          PIPELINED
       IS
          CURSOR group_cur
          IS
             SELECT   mo.groupid
               FROM   memberof mo
              WHERE   MO.USERID = userid_in
             UNION
                 SELECT   gh.groupid
                   FROM   GROUPHIERARCHY gh
             CONNECT BY   PRIOR GH.GROUPID = GH.PARENTGROUP_ID
             START WITH   GH.PARENTGROUP_ID IN (SELECT   mo.groupid
                                                  FROM   memberof mo
                                                 WHERE   MO.USERID = userid_in);
       BEGIN
          FOR rec IN group_cur
          LOOP
             PIPE ROW (authgroup_type (REC.GROUPID));
          END LOOP;
       END;
    END;
    CREATE OR REPLACE
    TYPE        AUTHDB.AUTHGROUP_TYPE AS OBJECT (GROUPID NUMBER (10));
    CREATE OR REPLACE
    TYPE        AUTHGROUP_SET AS TABLE OF authgroup_type;
    DECLARE
       l_groups       AUTH_TYPE.GROUP_RT;
       l_groups_rec   authgroup%ROWTYPE;
       FUNCTION GET_GROUPS (userid_in IN AUTHUSER.USERID%TYPE)
          RETURN AUTH_TYPE.GROUP_RT
       IS
          l_groups_rt   AUTH_TYPE.GROUP_RT;
       BEGIN
          OPEN l_groups_rt FOR
             SELECT   ag.*
               FROM   authgroup ag
              WHERE   AG.GROUPID IN
                            (SELECT   * FROM table (cast(adm_usergroup.GET_GROUPIDS (userid_in) as authgroup_set)));
          RETURN l_groups_rt;
       END GET_GROUPS;
    BEGIN
       l_groups := GET_GROUPS (1);
       LOOP
          FETCH l_groups INTO   l_groups_rec;
          EXIT WHEN l_groups%NOTFOUND;
          DBMS_OUTPUT.put_line ('ID: ' || l_groups_rec.groupid);
       END LOOP;
       CLOSE l_groups;
    END;

  • How to DEBUG a function module running in background mode? Please help!

    Hi Experts,
       I am calling a function module in my ABAP code in background module using the following syntax:
      CALL FUNCTION 'YBBC2_CREATE_SNAPSHOT' IN BACKGROUND TASK
              TABLES
                itab_std_format_inv = itab_std_format_inv
                itab_snapshot_inv = itab_snapshot_inv.
            COMMIT WORK.
    If I put the breakpoint in the CALL FUNCTION line and execute the program, the debugger does not take me to the valled function module. This may be because I am running the function module as background task.
    I cannot comment this  "IN BACKGROUND TASK" statement as well since i am debugging in Quality system where I don't have change access.
    So how to DEBUG a function module running in background mode? Please help!
    Thanks
    Gopal

    Hi,
    You could try to use the following trick:
    (1) Put an endless loop into the coding of your function module where you want to start debugging, e.g.
      DATA:
        lx_exit_loop(1)     TYPE c.
      lx_exit_loop = ' '.
      DO.
        IF ( lx_exit_loop = 'X' ).
          EXIT.
        ENDIF.
      ENDDO.
    (2) Call your function module in background task
    (3) Call transaction SM50 and search for the background process.
    (3) Choose from menu Program/Mode -> Program -> Debugging
    Now you the debugger should bring you right to your endless loop. Set lx_loop_exit = 'X' in the debugger and continue (F5 or F6).
    <b>Reward points</b>
    Regards

  • Calling an  pipeline function in a Select query

    Hello gurus ,
    i have a query calling pipeline function
    WITH t AS
         (SELECT dep_code, emp_id
            FROM test1
           WHERE dep_code = 'C1' AND emp_id = '123')
    SELECT *
      FROM TABLE
              (CAST
                  ((pk_get_emp_dtls.fn_t_get_emp_dtls (t.dep_code,
                                                       t.empid,
                                                       TRUNC (SYSDATE)
                   ) AS ps_ot_emp_dtls
           t;in this above query i want to use the emp id ,dept code from the with clause as parameters in the function pk_get_emp_dtls.fn_t_get_emp_dtls
    but error occures SQL command not ended properly
    Regards,
    Friend
    Edited by: most wanted!!!! on Nov 14, 2012 6:17 AM

    I see Solomon beat me to it...
    SQL> create or replace type o_emp as object (empno number, ename varchar2(10))
      2  /
    Type created.
    SQL>
    SQL> create or replace type t_emp as table of o_emp
      2  /
    Type created.
    SQL>
    SQL> create or replace function get_emp(p_deptno in number) return t_emp pipelined as
      2    v_emp o_emp := o_emp(null,null);
      3    cursor cur_emp is
      4      select empno, ename
      5      from   emp
      6      where  deptno = p_deptno;
      7  begin
      8    for i in cur_emp
      9    loop
    10      v_emp.empno := i.empno;
    11      v_emp.ename := i.ename;
    12      pipe row (v_emp);
    13    end loop;
    14    return;
    15  end;
    16  /
    Function created.
    SQL>
    SQL>
    SQL> with t as (select deptno from dept where dname = 'SALES')
      2  select x.*
      3  from   t, table(get_emp(t.deptno)) x
      4  /
         EMPNO ENAME
          7499 ALLEN
          7521 WARD
          7654 MARTIN
          7698 BLAKE
          7844 TURNER
          7900 JAMES
    6 rows selected.
    SQL> with t as (select deptno from dept where dname = 'SALES')
      2  select x.*
      3  from   table(get_emp(t.deptno)) x, t
      4  /
    from   table(get_emp(t.deptno)) x, t
    ERROR at line 3:
    ORA-00904: "T"."DEPTNO": invalid identifier

Maybe you are looking for

  • Problem With my E72 with invalid lock code

    Hi, I just configured a new exchange mail account. Prior to that I have configured a my previous firm mail exchange. I forgot the passcode. After setting up new account it asked for the lock code and i tried many time which reulted in data loss. I lo

  • Solution Manager 7.1 SP 04 - No details in alert

    Dear experts So far, all configuration steps run well and managed systems are attatched to my Solution Manager. Also, I receive mails from it like "EarlyWatch Alert raised" or "Batch Job Errors" issued by my managed system. But when I follow the link

  • Component binding return null value

    I'm migrating a JSF 1.2 application to JSF 2.1, specificly I'm currently using mojorra 2.1.24. The application consists of request scoped beans, and in order to pass data between requests, it embeds the data inside UI components. The following behavi

  • IPhoto to MobileMe: Button Does Nothing

    I am using iPhoto 08 (version 7.1.4 371) on a MacPro with system 10.5.4. In iPhoto, if I select a group of photos and click the "MobileMe" button, or choose Share/MobileMe from the menus, nothing whatsoever happens. No dialog, no nothing. It just beh

  • Possible to create folder during batch rename?

    I use bridge to sort my photos, and store them in a file structure such as: Photos/2010-12-24-ChristmasEveParty/2010-12-24-ChristmasEveParty-001.jpg Photos/2010-12-24-ChristmasEveParty/2010-12-24-ChristmasEveParty-nnn.jpg  Using the batch rename, it'