CAST MULTISET using a recursive UDT using REF

I am trying to create a recursive object and populate it using cast and multiset. However I keep getting the following error:
ORA-00932: inconsistent datatypes: expected UDT got CHAR
00932. 00000 - "inconsistent datatypes: expected %s got %s"
*Cause:    
*Action:
Error at Line: 96 Column: 47
I have been looking on OTN, Google ... every where I can think of. I am missing somthing simple or it is not possible I have not found documentation either way. Found one reference which was close to what I am doing. However the link to the explanation was broken ( Oracle Forums link ).
I have created a simple example below.
PS. Please no comment on using system ( i know :) ) this is a scratch database.
16:53:49 SQL> CREATE OR REPLACE TYPE system.MY_TYPE;
16:54:02 2 /
Type created.
16:54:04 SQL> CREATE OR REPLACE TYPE system.MY_TYPE_LIST AS TABLE OF REF system.MY_TYPE;
16:54:11 2 /
Type created.
16:54:13 SQL> CREATE OR REPLACE TYPE system.MY_TYPE AS OBJECT
16:54:27 2 ( COLUMN1 VARCHAR2(30),
16:54:35 3 SUB_LIST system.MY_TYPE_LIST
16:54:45 4 );
16:54:52 5 /
Type created.
16:54:55 SQL>
16:54:55 SQL> select system.my_type( tc.column_name, null ) from dba_tab_columns tc where tc.owner='SYS' and tc.table_name='DBA_TABLES';
--Should be noted there are no errors occured here* 16:56:00 SQL>
16:57:57 SQL> select system.my_type(
16:59:14 2 v.view_name,
16:59:20 3 cast( multiset (
16:59:26 4 select
16:59:31 5 tc.column_name,
16:59:36 6 null
16:59:45 7 from dba_tab_columns tc
16:59:51 8 where tc.table_name=v.view_name
16:59:56 9 and tc.owner=v.owner ) as system.my_type_list ) )
17:00:01 10 from dba_views v
17:00:06 11 where v.view_name = 'DBA_TABLES';
tc.column_name,
ERROR at line 5:
ORA-00932: inconsistent datatypes: expected UDT got CHAR
17:00:14 SQL>

create or replace type t_lookuprec as object
(Select columns1,2,3,....100
FROM A, B, C, D, E
WHERE ROWNUM < 1);You are correct that you need to use CREATE TYPE to use the type in SQL.
However unless I am mistaken you appear to have invented your own syntax for CREATE TYPE, suggest you refer to Oracle documentation.

Similar Messages

  • Help on CAST function, defining TYPE TABLE and using a REF cursor

    Hi,
    I have written a procedure (lookup) inside a package (lookup_pkg) as shown below.
    Procedure has an output variable of type PL/SQL TABLE which is defined in the package.
    I want to write a wrapper procedure lookupref to the procedure lookup to return a ref cursor.
    CREATE OR REPLACE PACKAGE lookup_pkg AS
    TYPE t_lookup_refcur IS REF CURSOR;
    CURSOR c_lookup IS
         Select columns1,2,3,....100
                   FROM A, B, C, D, E
                   WHERE ROWNUM < 1;
    TYPE t_lookup IS TABLE OF c_lookup%ROWTYPE;
    Procedure lookup(id Number, o_lookup OUT t_lookup);
    End lookup_pkg;
    CREATE OR REPLACE PACKAGE BODY lookup_pkg As
    Procedure lookup(id Number, o_lookup OUT t_lookup) IS
    BEGIN
    END lookup;
    Procedure lookupref(id Number, o_lookupref OUT t_lookup_refcur) IS
    o_lookup t_lookup;
    BEGIN
    lookup(id, o_lookup t_lookup);
    OPEN t_lookup_refcur FOR
    SELECT *
         FROM TABLE(CAST(o_lookup AS t_lookup));
    Exception
    End lookupref;
    END lookup_pkg;
    When I compile this procedure, I am getting invalid datatype Oracle error and
    cursor points the datatype t_lookup in the CAST function.
    1. Can anyone tell me what is wrong in this. Can I convert a PL/SQL collection (pl/sql table in this case) to PL/SQL datatype table or does it need to be a SQL datatype only (which is created as a type in database).
    Also, to resolve this error, I have created a SQL type and table type instead of PL/SQL table in the package as shown below.
    create or replace type t_lookuprec as object
                   (Select columns1,2,3,....100
                   FROM A, B, C, D, E
                   WHERE ROWNUM < 1);
    create or replace type t_lookup_tab AS table of t_lookuprec;
    CREATE OR REPLACE PACKAGE BODY lookup_pkg As
    Procedure lookup(id Number, o_lookup OUT t_lookup) IS
    BEGIN
    END lookup;
    Procedure lookupref(id Number, o_lookupref OUT t_lookup_refcur) IS
    o_lookup t_lookup;
    BEGIN
    lookup(id, o_lookup t_lookup);
    OPEN t_lookup_refcur FOR
    SELECT *
         FROM TABLE(CAST(o_lookup AS t_lookup_tab));
    Exception
    End lookupref;
    END lookup_pkg;
    When I compile this package, I am getting "PL/SQL: ORA-22800: invalid user-defined type" Oracle error and
    points the datatype t_lookup_tab in the CAST function.
    2. Can anyone tell me what is wrong. Can I create a type with a select statement and create a table type using type created earlier?
    I have checked the all_types view and found that
    value for Incomplete column for these two types are YES.
    3. What does that mean?
    Any suggestions and help is appreciated.
    Thanks
    Srinivas

    create or replace type t_lookuprec as object
    (Select columns1,2,3,....100
    FROM A, B, C, D, E
    WHERE ROWNUM < 1);You are correct that you need to use CREATE TYPE to use the type in SQL.
    However unless I am mistaken you appear to have invented your own syntax for CREATE TYPE, suggest you refer to Oracle documentation.

  • Question on using CAST, MULTISET and TABLE

    Hi,
    I am trying to do something that is utterly meaningless, but I am studying the use of CAST with MULTISET and TABLE.
    I have created a type: a Nested Table of Number values:
    create type numTable as table of number;
    Now I perform the following query:
    select d.dname
    , ( select avg(column_value)
    from table
    ( cast( d.salaries as numTable)
    ) Department_Avg_Salary
    from ( select cast
    ( multiset
    ( select e.sal
    from emp e
    where e.deptno = d1.deptno
    ) as numTable
    ) salaries
    , d1.dname
    from dept d1
    ) d
    I had expected to see each department name and the average salary within that department. Instead, I see the same Department_Avg_Salary value for each row - the average of the first department:
    DNAME DEPARTMENT_AVG_SALARY
    ACCOUNTING 1875
    RESEARCH 1875
    SALES 1875
    OPERATIONS 1875
    However, when I change the query to the following:
    select d.dname
    , d.salaries
    from ( select cast
    ( multiset
    ( select e.sal
    from emp e
    where e.deptno = d1.deptno
    ) as numTable
    ) salaries
    , d1.dname
    from dept d1
    ) d
    I get the following result - note that each department shows the correct list of salaries, not the list of the 1st department's salaries over and over.
    DNAME
    SALARIES
    ---------------------------------------------------------ACCOUNTING
    NUMTABLE(2450, 1300)
    RESEARCH
    NUMTABLE(800, 2975, 3000, 5000, 1100, 3000)
    SALES
    NUMTABLE(1600, 1250, 1250, 2850, 1500, 950)
    OPERATIONS
    NUMTABLE()
    Can someone explain why the
    , ( select avg(column_value)
    from table
    ( cast( d.salaries as numTable)
    ) Department_Avg_Salary
    does not give an average per department but instead only the first department's average?
    thanks for your help!
    regards
    Lucas Jellema

    scott@ORA92> select d.dname,
      2           (select avg(column_value)
      3            from   table (cast (d.salaries as numTable))
      4            where d.dname = dname) Department_Avg_Salary
      5  from   (select cast (multiset (select e.sal
      6                          from   emp e
      7                          where  e.deptno = d1.deptno) as numTable) salaries,
      8                 d1.dname
      9            from    dept d1) d
    10  /
    DNAME          DEPARTMENT_AVG_SALARY
    ACCOUNTING                2916.66667
    RESEARCH                        2175
    SALES                     1566.66667
    OPERATIONS

  • Using where clause with cast multiset

    version
    oracle 10g
    how to select values based on values in the object.
    CREATE OR REPLACE TYPE init_queue AS OBJECT (
       seq_num_q                 NUMBER,
       source_system_name        VARCHAR2 (50 BYTE),
       milestone_id              NUMBER,
       milestone_date            DATE,
       downstream_order_number   VARCHAR2 (175 BYTE),
       leg_id                    VARCHAR2 (175 BYTE),
       statuspro_captured_date   DATE,
       pon                       VARCHAR2 (26 BYTE),
       milestone_source          VARCHAR2 (26 BYTE),
       session_id                NUMBER,
       reconfirmation_flag       CHAR (1 BYTE),
       vec_flag                  CHAR (1 BYTE)
    CREATE OR REPLACE TYPE tab_init_queue AS TABLE OF init_queue;
    SET serveroutput on;
    DECLARE
       v_list       tab_init_queue := tab_init_queue ();
       v_arr_sort   tab_init_queue := tab_init_queue ();
    BEGIN
       SELECT init_queue (seq_num_q,
                          source_system_name,
                          milestone_id,
                          milestone_date,
                          downstream_order_number,
                          leg_id,
                          statuspro_captured_date,
                          pon,
                          milestone_source,
                          session_id,
                          reconfirmation_flag,
                          vec_flag
       BULK COLLECT INTO v_list
         FROM r_cust_status_init_queue;
       SELECT CAST (MULTISET (SELECT *
                                FROM TABLE (v_list)
                               WHERE v_list.milestone_id = 11  -- * How to select values based on milestone.*
                               ) AS tab_init_queue)
         INTO v_arr_sort
         FROM DUAL;
       DBMS_OUTPUT.put_line (v_arr_sort.COUNT);
    END;
    /Edited by: new learner on Aug 23, 2010 7:35 PM

    new learner wrote:
    version
    oracle 10g
    how to select values based on values in the object.
    CREATE OR REPLACE TYPE init_queue AS OBJECT (
    seq_num_q                 NUMBER,
    source_system_name        VARCHAR2 (50 BYTE),
    milestone_id              NUMBER,
    milestone_date            DATE,
    downstream_order_number   VARCHAR2 (175 BYTE),
    leg_id                    VARCHAR2 (175 BYTE),
    statuspro_captured_date   DATE,
    pon                       VARCHAR2 (26 BYTE),
    milestone_source          VARCHAR2 (26 BYTE),
    session_id                NUMBER,
    reconfirmation_flag       CHAR (1 BYTE),
    vec_flag                  CHAR (1 BYTE)
    CREATE OR REPLACE TYPE tab_init_queue AS TABLE OF init_queue;
    SET serveroutput on;
    DECLARE
    v_list       tab_init_queue := tab_init_queue ();
    v_arr_sort   tab_init_queue := tab_init_queue ();
    BEGIN
    SELECT init_queue (seq_num_q,
    source_system_name,
    milestone_id,
    milestone_date,
    downstream_order_number,
    leg_id,
    statuspro_captured_date,
    pon,
    milestone_source,
    session_id,
    reconfirmation_flag,
    vec_flag
    BULK COLLECT INTO v_list
    FROM r_cust_status_init_queue;
    SELECT CAST (MULTISET (SELECT *
    FROM TABLE (v_list)
    WHERE v_list.milestone_id = 11  -- * How to select values based on milestone.*
    ) AS tab_init_queue)
    INTO v_arr_sort
    FROM DUAL;
    DBMS_OUTPUT.put_line (v_arr_sort.COUNT);
    END;
    /Edited by: new learner on Aug 23, 2010 7:35 PMLike this.
    DECLARE
       v_list       tab_init_queue := tab_init_queue ();
       v_arr_sort   tab_init_queue := tab_init_queue ();
    BEGIN
       v_list.extend;
       v_list(v_list.count) := init_queue(1, '1', 11, sysdate, '1', '1', sysdate, '1', '1', 1, '1', '1');
      8 
       SELECT CAST (MULTISET (SELECT *
                                FROM TABLE (v_list)
                               WHERE milestone_id = 11  -- * How to select values based on milestone.*
                               ) AS tab_init_queue)
         INTO v_arr_sort
         FROM DUAL;
       DBMS_OUTPUT.put_line (v_arr_sort.COUNT);
    END;
    1
    PL/SQL procedure successfully completed.
    ME_XE?ME_XE?
    ME_XE?select * from v$version;
    BANNER
    Oracle Database 10g Express Edition Release 10.2.0.1.0 - Product
    PL/SQL Release 10.2.0.1.0 - Production
    CORE     10.2.0.1.0     Production
    TNS for Linux: Version 10.2.0.1.0 - Production
    NLSRTL Version 10.2.0.1.0 - Production
    5 rows selected.
    ME_XE?It would have been easier if you'd made a simple example so i didn't have to type out the example record (since your original code referenced a table you didn't provide DDL and INSERTS for).
    Something to keep in mind for the future (the easier you make it for us, the more likely we are to help).

  • Recursive Tree  using Web Dynpro java

    Hi
    I've been trying to create a recursive tree using java in Web Dynpro.
    Can you please suggest a good example to try with?

    Hi,
    Check the below links....
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webdynpro/wd%20java/wd%20tutorials/integration%20of%20a%20tree%20structure%20in%20a%20web%20dynpro%20table.pdf
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webdynpro/wd%20java/wd%20tutorials/constructing%20a%20recursive%20and%20loadable%20web%20dynpro%20tree.pdf
    http://help.sap.com/saphelp_nw70/helpdata/en/13/4cde139306304480e89d815ffcf891/frameset.htm
    http://help.sap.com/saphelp_nw70/helpdata/en/af/44ea406c9d3d43e10000000a155106/frameset.htm
    http://help.sap.com/saphelp_nw70/helpdata/en/21/ad884118aa1709e10000000a155106/frameset.htm
    Code Example,
    http://help.sap.com/saphelp_nw70/helpdata/en/16/1ec1814e566f4baf943c53ccf48552/frameset.htm
    null

  • Adjacency Matrix in MDS using a recursive derived hierarchy

    Hello everyone!
    I'm looking for some great examples of how to do an adjacency matrix in Master Data Services while using the recursive derived hierarchy.  Is this even possible or do I need to use an explicit hierarchy?
    I'd really like to avoid using the explicit hierarchy because I'd like to be able to define the matrix and enforce adjacency relationship with that matrix.
    I hope I'm making sense here...

    Gersh,
    It works now. I have implemented the below code (ENTITY needed to contain the variable as well). The relationship profitcenter and entity is very important as it derives the relevant profitcenters from the profit center hierarchy (e.g. all profitcenters under the legalentity node).
    //ALLOCATION PROCEDURE CONVERSION RATE
    //=====================================
    *FOR %ENT% = %ENTITY_SET%
    *RUNALLOCATION
    *FACTOR=1
    *DIM SEBACCOUNT WHAT=CONV_RATE; WHERE=<<<; USING=<<< ; TOTAL=<<<
    *DIM PROFCENT WHAT=DUMPC; WHERE=BAS(BPC_%ENT%);USING=<<<; TOTAL=<<<
    *DIM CATEGORY WHAT=FCSTCUR; WHERE=<<<; USING=<<< ; TOTAL=<<<
    *DIM ENTITY WHAT=%ENT%; WHERE=<<<; USING=<<<; TOTAL=<<<
    *ENDALLOCATION
    *NEXT
    Thanks
    Nico

  • Greetings, I'm having trouble with my iMouse continually disconnecting from my MacBook Pro in Mavericks.  The batteries are solid.  I just eliminated the bluetooth for my headphone.  I have used the mac to cast on my TV.  I use bluetooth.  ANy ideas?

    Greetings, I'm having trouble with my iMouse continually disconnecting from my MacBook Pro in Mavericks.  The batteries are solid.  I just eliminated the bluetooth for my headphone.  I have used the mac to cast on my TV.  I use bluetooth.  ANy ideas?

    Hi clemenbw,
    Welcome to the Apple Support Communities!
    In your situation, I would recommend reading over the attached article to help you troubleshoot your Magic Mouse Bluetooth connectivity issues. 
    Troubleshooting wireless mouse and keyboard issues
    Have a great day,
    Joe

  • Cast multiset help needed

    I have the following sql
    SELECT *
    FROM (SELECT updatedby, updateddate, ROWNUM,
    ent_id
    FROM (SELECT hstbe.updatedby,
    hstbe.updateddate,
    TO_CHAR
    (hstbe.entry_id
    ) ent_id
    FROM hst_rb_booking_entry hstbe
    --WHERE hstbe.entry_id = entryid
    UNION
    SELECT hstli.updatedby,
    hstli.updateddate,
    hstli.entry_id ent_id
    FROM hst_rb_line_item hstli)
    -- WHERE hstli.entry_id = be.booking_entry_id)
    ORDER BY updateddate)
    WHERE ROWNUM < 6)
    I am unable to put it in cat multiset as have to retrieve these as collection in my sql of ref cursor. please help me in putting it in cast multiset.

    Thenks for the reply.
    I have allready encounter this page in the past.
    I tryed to use "JIMI" wich is a good tool but I haven't found a function to control image resolution in it's documentation.
    If you do know how to control dpi threw "JIMI" please tell me.

  • CAST MULTISET...is it supported by BI

    In a precedent POst i explained the problems we had with multiple queries to display data as a hierarchical manner, with more than 2 levels
    We'd like to explore the way with CAST MULTISET...but before to spend time, we'd like to assure that it is supported by BI Publisher.
    As an example ( with one level):
    We prepared the Object Types as is :
    create or replace TYPE ETAG_T AS OBJECT("@S_NUME_OBJE" NUMBER,
                        S_NUME_ETAG NUMBER,
                        C_TYPE_ETAG VARCHAR2(4 CHAR),
                        L_DESC_ETAG VARCHAR2(50 CHAR),
                        N_NOMB_PIEC NUMBER,
                        N_SURF_TOTA NUMBER,
                        D_MODI DATE,
                        R_FONC CHAR(5),
                        R_UTIL CHAR(20),
                        C_CODE_LANG VARCHAR2(4 CHAR)
    create or replace TYPE etaglist_t AS TABLE OF etag_t
    create or replace TYPE obje_t as Object (
    "@S_NUME_OBJE" NUMBER,
    N_NUME_IMME VARCHAR2(5) ,
    N_NUME_OBJE VARCHAR2(5) ,
    etag_list etaglist_t
    Then the data query is (Statement is named Q1):
    SELECT
    obje_t(s_nume_obje, n_nume_obje, n_nume_imme,
    CAST (MULTISET (SELECT S_NUME_OBJE,
                        S_NUME_ETAG,
                        C_TYPE_ETAG,
                        L_DESC_ETAG,
                        N_NOMB_PIEC,
                        N_SURF_TOTA,
                        D_MODI,
                        R_FONC,
                        R_UTIL,
                        C_CODE_LANG
    FROM imm.b12_0 eta
    WHERE eta.s_nume_obje = obj.s_nume_obje)
    AS etaglist_t))
    AS "obj"
    FROM pointi.b02_v obj
    WHERE obj.s_nume_obje= :sNumeObje
    As a result , we get only the <obj> element like this :
    <LIST_Q1>
    <Q1>
    <obj/>
    </Q1>
    </LIST_Q1>
    We tried too :
    SELECT XMLElement("Object",
    obje_t(s_nume_obje, n_nume_obje, n_nume_imme,
    CAST (MULTISET (SELECT S_NUME_OBJE,
                        S_NUME_ETAG,
                        C_TYPE_ETAG,
                        L_DESC_ETAG,
                        N_NOMB_PIEC,
                        N_SURF_TOTA,
                        D_MODI,
                        R_FONC,
                        R_UTIL,
                        C_CODE_LANG
    FROM imm.b12_0 eta
    WHERE eta.s_nume_obje = obj.s_nume_obje)
    AS etaglist_t))
    AS "obj" ) as "objXML"
    FROM pointi.b02_v obj
    WHERE obj.s_nume_obje= :sNumeObje
    And we get :
    <Q1>
    <objXML/>
    </Q1>
    Seems to be not supported isn't it...
    Laurent

    Ok thanks,
    I already checked your blog before to speak about pl/sql tables ;-)
    I think , for maintenance, it will better too , than having a single query with many cast...Multiset , which could have more than 500 lines :-(
    But in our case, as we should have kind of hierarchies in the XML (with levels) and collections, i think we should have a mix :
    store pl/sql tables in a package, that will be reused from the main query, and certainly continue to use cast multiset to manage theses nested collections.
    As you said, i think we could remove the use of Object Types as we do today.

  • Cast multiset

    How does cast multiset work, I have a huge sql whcih is returning one value say p_opp_id ( on the basis of this i need few more coumns) , i was suggested to use cast multiset , what is cast multiset and how it works

    CAST(MULTISET(subquery) AS collection_type) converts the result of a subquery into a collection.
    An example I had lying around:
    CREATE TABLE master (table_name PRIMARY KEY) AS
    SELECT table_name
    FROM   user_tables;
    CREATE TABLE detail AS
    SELECT table_name, column_name, data_type
    FROM   user_tab_columns;
    CREATE OR REPLACE TYPE name_strvalue_ot AS OBJECT
    ( name VARCHAR2(30)
    , value VARCHAR2(50) );
    CREATE OR REPLACE TYPE name_strvalue_tt AS TABLE OF name_strvalue_ot;
    SELECT m.table_name
         , CAST(
           MULTISET
           ( SELECT name_strvalue_ot(d.column_name, d.data_type)
             FROM   detail d
             WHERE  d.table_name = m.table_name
           ) AS name_strvalue_tt) cols
    FROM   master m;
    BEGIN
         FOR r IN
              SELECT m.table_name
                   , CAST(
                     MULTISET
                     ( SELECT name_strvalue_ot(d.column_name, d.data_type)
                       FROM   detail d
                       WHERE  d.table_name = m.table_name
                     ) AS name_strvalue_tt) cols
              FROM   master m
         LOOP
              DBMS_OUTPUT.PUT_LINE(r.table_name || ': ' || r.cols.count || ' columns');
         END LOOP;
    END;
    /

  • SQL ENTERPRISE: The edition of Reporting Services that you are using requires that you use local SQL Server relational databases for report data sources and the report server database

    The error below makes absolutely no sense! I'm using Enterprise Core...yet I'm being told I can't use remote data sources:
    w3wp!library!8!03/05/2015-19:08:48:: i INFO: Catalog SQL Server Edition = EnterpriseCore
    w3wp!library!8!03/05/2015-19:08:48:: e ERROR: Throwing Microsoft.ReportingServices.Diagnostics.Utilities.OperationNotSupportedException: , Microsoft.ReportingServices.Diagnostics.Utilities.OperationNotSupportedException: The feature: "The edition of Reporting
    Services that you are using requires that you use local SQL Server relational databases for report data sources and the report server database." is not supported in this edition of Reporting Services.;
    Really? This totally contradicts the documentation found here:
    https://msdn.microsoft.com/en-us/library/ms157285(v=sql.110).aspx
    That article says remote connections are completely supported.
    ARGH! Why does this have to be so difficult to setup?!?

    Hi jeffoliver1000,
    According to your description, you are using Enterprise Core edition and you are prompted that you can’t use remote data sources.
    In your scenario, we neither ignore your point nor be doubt with what you say. But actually we have met the case before that even though the SQL Server engine is Enterprise but the reporting services is still standard. So I would recommend you to find the
    actual edition of reporting services you are using. You can find Reporting Services starting SKU in the Reporting Service logs ( default location: C:\Program Files\Microsoft SQL Server\<instance name>\Reporting Services\LogFiles). For more information,
    please refer to the similar thread below:
    https://social.technet.microsoft.com/Forums/en-US/f98c2f3e-1a30-4993-ab41-acbc5014f92e/data-driven-subscription-button-not-displayed?forum=sqlreportingservices
    By the way, have you installed the other SQL Server edition before?
    Best regards,
    Qiuyun Yu
    Qiuyun Yu
    TechNet Community Support

  • The feature: "The edition of Reporting Services that you are using requires that you use local SQL Server relational databases for report data sources and the report server database." is not supported in this edition of Reporting Services.

    Hello all,
    I have SQL express 2014 advance edition installed ..
    and i am connecting SQl server 2008 r2 instance which is in network 
    while creating datasource in Reportserver which has Express installed ..
    got this error ..
    please help me how to connect to remote server
    Dilip Patil..

    Error message says it all.
    With SQL Express, Data source should be local SQL DB.
    With SQL Enterprise, Standard, BI edition, you can create Data soruce which are hosted on other servers.
    Please refer similar thread:
    https://social.msdn.microsoft.com/Forums/en-US/c0468e3f-bad7-47a7-a695-75c13762280a/the-feature-the-edition-of-reporting-services-that-you-are-using-requires-that-you-use-local-sql?forum=sqlreportingservices
    Cheers,
    Vaibhav Chaudhari
    [MCTS],
    [MCP]

  • Error in cast multiset in collections

    DECLARE
    TYPE emp_dept_rec IS RECORD (
    v_sal emp.sal%TYPE,
    v_name emp.ename%TYPE,
    v_deptname dept.DEPTNAME%type
    TYPE emp_dept_tab_type IS TABLE OF emp_dept_rec;
    l_emp_dept_tab emp_dept_tab_type;
    type emp_tab is table of emp%rowtype;
    type l_emp_tab is table of emp%rowtype;
    type dept_tab is table of dept%rowtype;
    type l_dept_tab is table of dept%rowtype;
    cursor e1 is
    select * from emp;
    cursor d1 is select * from dept;
    begin
    OPEN e1;
    FETCH e1
    BULK COLLECT INTO l_emp_tab;
    open d1;
    FETCH d1
    BULK COLLECT INTO l_dept_tab;
    select cast(multiset (select em.sal,em,ename ,dep.DEPTNAME
    from table(l_emp_tab) em,table(l_dept_tab) dep
    where em.deptno=dep.deptno)
    as emp_dept_tab_type)
    into l_emp_dept_tab ;
    end;
    it is giving error as
    ORA-06550: line 43, column 25:
    PL/SQL: ORA-00923: FROM keyword not found where expected
    ORA-06550: line 39, column 5:
    PL/SQL: SQL Statement ignored

    Here is an example.
    SQL> CREATE OR REPLACE TYPE emp_rec IS OBJECT (
      2                      v_sal    NUMBER(7,2),
      3                      v_name   VARCHAR2(35),
      4                      v_empno  NUMBER(4),
      5                      v_deptno NUMBER(2)
      6                      )
      7  ;
      8  /
    Type created.
    SQL> CREATE OR REPLACE TYPE emp_tab IS TABLE OF emp_rec;
      2  /
    Type created.
    SQL> CREATE OR REPLACE TYPE dept_rec IS OBJECT (
      2                      v_deptno NUMBER,
      3                      v_dname VARCHAR2(50)
      4                      )
      5  ;
      6  /
    Type created.
    SQL> CREATE OR REPLACE TYPE dept_tab IS TABLE OF dept_rec;
      2  /
    Type created.
    SQL> CREATE OR REPLACE TYPE emp_dept_rec IS
      2                     OBJECT (
      3                      v_sal     NUMBER,
      4                      v_name     VARCHAR2(35),
      5                      v_deptname VARCHAR2(30)
      6                      );
      7  /
    Type created.
    SQL> CREATE OR REPLACE TYPE emp_dept_tab_type IS TABLE OF emp_dept_rec;
      2  /
    Type created.
    SQL> set serverout on
    SQL> DECLARE
      2    l_emp_dept_tab emp_dept_tab_type; --emp_dept_tab_type declared in database
      3    l_emp_tab      emp_tab; --emp_tab declared in database
      4    l_dept_tab     dept_tab; --dept_tab declared in database
      5 
      6    CURSOR e1 IS
      7      SELECT emp_rec(sal, ename, empno, deptno) FROM emp; --Note the type casting here
      8 
      9    CURSOR d1 IS
    10      SELECT dept_rec(deptno, dname) FROM dept; --Note the type casting here
    11  BEGIN
    12    OPEN e1;
    13 
    14    FETCH e1 BULK COLLECT
    15      INTO l_emp_tab;
    16 
    17    OPEN d1;
    18 
    19    FETCH d1 BULK COLLECT
    20      INTO l_dept_tab;
    21 
    22    SELECT CAST(MULTISET (SELECT em.v_sal, em.v_name, dep.v_dname
    23                   FROM TABLE(l_emp_tab) em, TABLE(l_dept_tab) dep
    24                  WHERE em.v_deptno = dep.v_deptno) AS emp_dept_tab_type)
    25      INTO l_emp_dept_tab
    26      FROM DUAL;
    27    FOR i IN 1 .. l_emp_dept_tab.COUNT LOOP
    28      dbms_output.put_line(l_emp_dept_tab(i)
    29                           .v_sal || '--' || l_emp_dept_tab(i)
    30                           .v_name || '--' || l_emp_dept_tab(i).v_deptname);
    31    END LOOP;
    32 
    33  END;
    34  /
    1300--MILLER--ACCOUNTING
    5000--KING--ACCOUNTING
    2450--CLARK--ACCOUNTING
    3000--FORD--RESEARCH
    1100--ADAMS--RESEARCH
    3000--SCOTT--RESEARCH
    2975--JONES--RESEARCH
    800--SMITH--RESEARCH
    950--JAMES--SALES
    1500--TURNER--SALES
    2850--BLAKE--SALES
    1250--MARTIN--SALES
    1250--WARD--SALES
    1600--ALLEN--SALES
    PL/SQL procedure successfully completed.It is just for educational purpose, because the thing you have achieved by so much programming can be done easily by simple join in the table itself.
    user10447332 Newbie
    Handle: user10447332
    Status Level: Newbie
    Registered: Oct 20, 2008
    Total Posts: 227
    Total Questions: 153 (152 unresolved) >
    What a record! and most of the time you don't care to follow/revisit the thread also!.

  • Get "Creation Script" of the existing table ( in SQL database) using C# and without using SMO dlls

    Hi All,
    I need to get the "Creation Script" of the existing table using c# and without using SMO dlls (is it possible? I don't know).
    I.e. In SQL Management Studio -> right click on any table -> Script table as -> Create To  - > open in the new query editor window. This will give you the schema of the table with the constraints of the table.
    For E.g. In Northwind database, for the table "Categories", I would like to get it as show below
    USE [Northwind]
    GO
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    CREATE TABLE [dbo].[Categories](
        [CategoryID] [int] IDENTITY(1,1) NOT NULL,
        [CategoryName] [nvarchar](15) NOT NULL,
        [Description] [ntext] NULL,
        [Picture] [image] NULL,
     CONSTRAINT [PK_Categories] PRIMARY KEY CLUSTERED
        [CategoryID] ASC
    )WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
    ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
    GO
    I would like to get the same schema using c#. Please help.
    Thanks & Regards,
    Kalai.

    SMO is the easiest way to get this. This is what Management Studio uses. If you can't use SMO, get a Profiler trace of the queries that SMO executes when generating the script and execute the same using ADO.NET.
    Regards,
    Farooq Mahmud
    Support Escalation Engineer 
    •  Microsoft Health Solutions Group

  • How do i use Facebook in china using my macbook pro?

    how do i use Facebook in china using my macbook pro?

    Have a look to the right of this page under 'More like this'.
    Facebook may not be available.

Maybe you are looking for