Query Column List convert to CLOB

Hi,
we need to print the data by using UTL_FILE from the dynamically constructing sql query with pivot column (It is having more than 1000 column).
But this query contains 1008 columns but it throwing error maxmimum number of columns in a table or views 1000.
Query
Select col1,col2,col3,clo4,col5,col6,col7,col8 ,Pivot columns 1 to 1000 from tab1
Each and every column data having more than 3500.
Please share your idea ?
1.is it possoble to concatenate all the columns and write into file using utl_file.
2.How to convert the rows as clob column
3.Each and every row should contains more than 32767.
Regards,
Sudhakar P.

Sudhakar P wrote:
Hi,
we need to print the data by using UTL_FILE from the dynamically constructing sql query with pivot column (It is having more than 1000 column).
But this query contains 1008 columns but it throwing error maxmimum number of columns in a table or views 1000.Can't overcome Oracle's internal limits.
Each and every column data having more than 3500.More than 3500 what?
1.is it possoble to concatenate all the columns and write into file using utl_file.Yes.
2.How to convert the rows as clob columnUse built in LOB functionality, such as provided in the DBMS_LOB package for example.
3.Each and every row should contains more than 32767.You would have to use CLOB's to store more than 4000 characters in SQL. 32767 is the limit in PL/SQL for VARCHAR2.
If it's dynamic, then you're going to have to pretty much use the DBMS_SQL package to construct things (11g allows the use of CLOB with EXECUTE IMMEDIATE for dynamic statements but it's still not ideal to get the data back if you don't know the output structure).
Here's an example from my standard library for writing out dynamic SQL output to a CSV file, which would probably be a good starting point...
As sys user:
CREATE OR REPLACE DIRECTORY TEST_DIR AS '\tmp\myfiles'
GRANT READ, WRITE ON DIRECTORY TEST_DIR TO myuser
/As myuser:
CREATE OR REPLACE PROCEDURE run_query(p_sql IN VARCHAR2
                                     ,p_dir IN VARCHAR2
                                     ,p_header_file IN VARCHAR2
                                     ,p_data_file IN VARCHAR2 := NULL) IS
  v_finaltxt  VARCHAR2(4000);
  v_v_val     VARCHAR2(4000);
  v_n_val     NUMBER;
  v_d_val     DATE;
  v_ret       NUMBER;
  c           NUMBER;
  d           NUMBER;
  col_cnt     INTEGER;
  f           BOOLEAN;
  rec_tab     DBMS_SQL.DESC_TAB;
  col_num     NUMBER;
  v_fh        UTL_FILE.FILE_TYPE;
  v_samefile  BOOLEAN := (NVL(p_data_file,p_header_file) = p_header_file);
BEGIN
  c := DBMS_SQL.OPEN_CURSOR;
  DBMS_SQL.PARSE(c, p_sql, DBMS_SQL.NATIVE);
  d := DBMS_SQL.EXECUTE(c);
  DBMS_SQL.DESCRIBE_COLUMNS(c, col_cnt, rec_tab);
  FOR j in 1..col_cnt
  LOOP
    CASE rec_tab(j).col_type
      WHEN 1 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_v_val,2000);
      WHEN 2 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_n_val);
      WHEN 12 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_d_val);
    ELSE
      DBMS_SQL.DEFINE_COLUMN(c,j,v_v_val,2000);
    END CASE;
  END LOOP;
  -- This part outputs the HEADER
  v_fh := UTL_FILE.FOPEN(upper(p_dir),p_header_file,'w',32767);
  FOR j in 1..col_cnt
  LOOP
    v_finaltxt := ltrim(v_finaltxt||','||lower(rec_tab(j).col_name),',');
  END LOOP;
  --  DBMS_OUTPUT.PUT_LINE(v_finaltxt);
  UTL_FILE.PUT_LINE(v_fh, v_finaltxt);
  IF NOT v_samefile THEN
    UTL_FILE.FCLOSE(v_fh);
  END IF;
  -- This part outputs the DATA
  IF NOT v_samefile THEN
    v_fh := UTL_FILE.FOPEN(upper(p_dir),p_data_file,'w',32767);
  END IF;
  LOOP
    v_ret := DBMS_SQL.FETCH_ROWS(c);
    EXIT WHEN v_ret = 0;
    v_finaltxt := NULL;
    FOR j in 1..col_cnt
    LOOP
      CASE rec_tab(j).col_type
        WHEN 1 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_v_val);
                    v_finaltxt := ltrim(v_finaltxt||',"'||v_v_val||'"',',');
        WHEN 2 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_n_val);
                    v_finaltxt := ltrim(v_finaltxt||','||v_n_val,',');
        WHEN 12 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_d_val);
                    v_finaltxt := ltrim(v_finaltxt||','||to_char(v_d_val,'DD/MM/YYYY HH24:MI:SS'),',');
      ELSE
        v_finaltxt := ltrim(v_finaltxt||',"'||v_v_val||'"',',');
      END CASE;
    END LOOP;
  --  DBMS_OUTPUT.PUT_LINE(v_finaltxt);
    UTL_FILE.PUT_LINE(v_fh, v_finaltxt);
  END LOOP;
  UTL_FILE.FCLOSE(v_fh);
  DBMS_SQL.CLOSE_CURSOR(c);
END;This allows for the header row and the data to be written to seperate files if required.
e.g.
SQL> exec run_query('select * from emp','TEST_DIR','output.txt');
PL/SQL procedure successfully completed.Output.txt file contains:
empno,ename,job,mgr,hiredate,sal,comm,deptno
7369,"SMITH","CLERK",7902,17/12/1980 00:00:00,800,,20
7499,"ALLEN","SALESMAN",7698,20/02/1981 00:00:00,1600,300,30
7521,"WARD","SALESMAN",7698,22/02/1981 00:00:00,1250,500,30
7566,"JONES","MANAGER",7839,02/04/1981 00:00:00,2975,,20
7654,"MARTIN","SALESMAN",7698,28/09/1981 00:00:00,1250,1400,30
7698,"BLAKE","MANAGER",7839,01/05/1981 00:00:00,2850,,30
7782,"CLARK","MANAGER",7839,09/06/1981 00:00:00,2450,,10
7788,"SCOTT","ANALYST",7566,19/04/1987 00:00:00,3000,,20
7839,"KING","PRESIDENT",,17/11/1981 00:00:00,5000,,10
7844,"TURNER","SALESMAN",7698,08/09/1981 00:00:00,1500,0,30
7876,"ADAMS","CLERK",7788,23/05/1987 00:00:00,1100,,20
7900,"JAMES","CLERK",7698,03/12/1981 00:00:00,950,,30
7902,"FORD","ANALYST",7566,03/12/1981 00:00:00,3000,,20
7934,"MILLER","CLERK",7782,23/01/1982 00:00:00,1300,,10The procedure allows for the header and data to go to seperate files if required. Just specifying the "header" filename will put the header and data in the one file.
Adapt to output different datatypes and styles are required.

Similar Messages

  • Items in project report(query) are listed under the "not assigned" (column)

    Hi All,
    Items in project reports (query) are listed under the "not assigned" (column name) Why it is so ?
    Start query : project reports & ask for period April 2008 (Period from/to). .
    You will see items listed under  Not assigned WBS Element (column name)
    If you choose for a period of April until June 2008 then you see more items under u201Cnot assignedu201D .
    Items should be under Assigned (column name) & not under the Not assigned (column name )
    Any suggestions highly appreciable.
    Thanks.

    Hi,
    How are you displaying the ITEM field in the BEx query designer? Is it displayed with "Key and Text"? If so and if the text is not loaded for this master, this may happen.
    Regards,
    Yogesh.

  • SSRS Reports level how to find out All tables names & columns list to display dynamically SQL Query????

    Hi Team,
    I Have one requirement,In SSRS Reporsitory 3000 reports are available.
    My end user requirement All 3000 reports are used Table names & columns list of each wise to display single table or single result set.
    I find out all 3000 reports details are diplayed single results set like
    Report Id,Path,Dataset,Source Query Text,Datasource
    In Source Query Text  column level All reports Queries are available but I want Each Report wise Table name & columns List.If any solution Please share me.
    Regards
    Rama

    Hi Ramakoteswara,
    According your description, you want to show used tables and columns of each report, and display is into a single result set. Right?
    In this scenario, we don't know where to find a column contains the Source Query Text. With my understanding, in Reporting Services, we have Catalog table in ReportServer DataBase, it has a column called Content stores the report code (.xml). In the
    code we can find the Query and Fields. Then you need to use VB/C# code to parse each .xml code of each report and fetch out the table name and columns. We do not support writing any queries against SSRS DataBase or parsing data records in any
    table.
    If you have any question, please feel free to ask.
    Best Regards,
    Simon Hou

  • An EUL query to list out All the Columns  (Fileds) for each Workbook

    Hi,
    I'm using Discoverer 10.1.2.2 on an Oracle 9.2.0.6.
    Does anyone have the EUL query that lists out all the names of Workbook/Worksheets and the names of their fields/columns. I would greatly appreciate it.
    Thanks

    Hi
    While it is not possible to read the workbook itself, whenever Discoverer runs a worksheet so long as you have enabled the gathering of statistics then a row is written to the EUL5_QPP_STATS table. In that table the column called DOC_NAME is the workbook, the column called DOC_DETAILS is the worksheet, with the CREATED_DATE being the date the worksheet was run. There are other encrypted columns in that table that contain the EUL items that were queried.
    Look at this code:
    SELECT
    QS.QS_DOC_OWNER    USER_NAME,
    QS.QS_DOC_NAME     WORKBOOK,
    QS.QS_DOC_DETAILS  WORKSHEET,
    TRUNC(QS.QS_CREATED_DATE) DOC_DATE,
    *(LENGTH(TO_CHAR(EUL5_GET_ITEM_NAME(QS.QS_ID)))+1)/9 ITEMS,*
    EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),1,  6)) ITEM1,
    EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),10, 6)) ITEM2,
    EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),19, 6)) ITEM3,
    EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),28, 6)) ITEM4,
    EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),37, 6)) ITEM5,
    EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),46, 6)) ITEM6,
    EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),55, 6)) ITEM7,
    EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),64, 6)) ITEM8,
    EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),73, 6)) ITEM9,
    EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),82, 6)) ITEM10,
    EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),91, 6)) ITEM11,
    EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),100,6)) ITEM12,
    EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),109,6)) ITEM13,
    EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),118,6)) ITEM14,
    EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),127,6)) ITEM15,
    EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),136,6)) ITEM16,
    EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),145,6)) ITEM17,
    EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),154,6)) ITEM18,
    EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),163,6)) ITEM19,
    EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),172,6)) ITEM20
    FROM
    EUL5_QPP_STATS QS--,
    --   APPS.FND_USER          USR
    WHERE
    --   QS.QS_DOC_OWNER = '#' || USR.USER_ID AND
    *(LENGTH(TO_CHAR(EUL5_GET_ITEM_NAME(QS.QS_ID)))+1)/9 < 21*
    AND QS.QS_CREATED_DATE > '01-JAN-2009';
    In order to run this you must have run the EUL5.SQL when connected as the owner of the EUL. This script can be found in the $ORACLE_HOME\Discoverer\Util folder of the machine where the Discoverer Administrator tool is installed.
    Try it out for yourself and you will see how it works.
    Best wishes
    Michael

  • MII 12.1 Workbench - Empty Column List in Query editor

    Hi all,
    In my CE 7.2 I have deployed via JSPM MII 12.1
    Everything seems ok on the overall installation side.
    I have defined a DataServer (connector IDBC, Type SQL) connected to the local MaxDB instance.
    The status is "Running" and everything seems ok.
    I want to access tables created as result of DDic DC deploy.
    The tables are actually there as I can see from NWA SQL console.
    The error happens when I start the Workbench->new SQL Query->Fixed Query Details
    The table is there in the list, but when I click on any table the column list stays empty (even for system tables)
    I get the following errors in trace
    Enter a table name
    [EXCEPTION]
    com.sap.xmii.Illuminator.logging.LHException: Enter a table name
    at com.sap.xmii.Illuminator.logging.ErrorHandler.handleError(ErrorHandler.java:47)
    at com.sap.xmii.Illuminator.connectors.IDBC.ColumnList.getData(ColumnList.java:33)
    at com.sap.xmii.Illuminator.connectors.IDBC.DBMetaDataProcessor.getListData(DBMetaDataProcessor.java:115)
    at com.sap.xmii.Illuminator.connectors.IDBC.DBMetaDataProcessor.processRequest(DBMetaDataProcessor.java:25)
    at com.sap.xmii.Illuminator.connectors.IDBC.DataSource.doProcessRequest(DataSource.java:67)
    at com.sap.xmii.Illuminator.connectors.AbstractConnector.processRequest(AbstractConnector.java:97)
    at com.sap.xmii.Illuminator.server.QueryEngine.run(QueryEngine.java:39)
    and several like
    com.sap.security.api.NoSuchRoleException: Role with uniqueName super_admin_role not found!
    Can anyone please help?
    Thanks, regards
    Vincenzo

    Hi Diana,
    thanks again for your support, I have only tried to connect to local MaxDB no Oracle, No MSSql
    I am using the IDBC connection to local MaxDB instance, I have deployed the corresponding jdbc archive version.
    The connection seems to be ok if the test query is something like "CURDATE()", but if I use a real query involving the table I'm interested in, it cannot be accessed and I get the "Enter table name" error again.
    I believe you are right in that no SQL-enabled user exists after installation, only admin users exist
    I am now trying to create an SQL-enabled user to perform queries, but it seems a bit awkward from command line.
    If you have any suggestion other than looking at manuals (which I am already doing) feel free to suggest
    The datasource method did not work, even though it would be the best one IMHO.
    I tried to use the SAP/JPA_DEFAULT datasource with a different DataServer, but when loading the Table list in workbench I get: UnsupportedOperationException: unimplemented method isNull, which should be somehow related to jdbc driver
    Maybe this second error could be somehow related to the CE 7.2 version Michael was correctly pointing at, since the driver used is the builtin SAP driver.
    thanks for any suggestion
    Thanks, regards
    Vincenzo

  • Query 3 Lists having lookup column

    I have 3 Lists and I have to fetch the data from them. The scenario is:
    ListA,    ListsMapping,                                                    
      ListB
    IdA       IdA(Lookup
    from ListA),IdB(Lookup
    from ListB)       IdB
    I need to query ListsMapping List using IdA and then find all the rows for IdB in the list ListsMapping and then go to the list ListB and fetch all the records/rows for IdB
    This is one to mane relation and there can be multiple values of IdB for IbA Can anyone help in this.

    It would be a complex query if use either LINQ or CAML but search service will be a good option to utilize.  You can define your Managed Properties in Search Service Application and then query these lists. 
    Rahul Gupta, MCSE, MCSD - SharePoint

  • Newbie trying to query an XML field in Clob

    I've been unsuccessfully trying to query XML data in a CLOB field today without much success.
    The clob field stores approvals (Edited, Reviewed, Published) for each version.
    I'm trying to get the latest version (in this case 13) and what state (name) it is at (in this case 'Reviewed')
    Below is an example of the table and field with a single XML column...
    desc WIKI.OS_PROPERTYENTRY
    Name                                              Null?       Type
    ENTITY_NAME                                         NOT NULL VARCHAR2(125)
    ENTITY_ID                                         NOT NULL NUMBER(19)
    ENTITY_KEY                                         NOT NULL VARCHAR2(200)
    KEY_TYPE                                               NUMBER(10)
    BOOLEAN_VAL                                               NUMBER(1)
    DOUBLE_VAL                                               FLOAT(126)
    STRING_VAL                                               VARCHAR2(255)
    TEXT_VAL                                               CLOB
    LONG_VAL                                               NUMBER(19)
    INT_VAL                                               NUMBER(10)
    DATE_VAL                                               DATE
    SQL> select xmltype(text_val) from wiki.os_propertyentry where entity_id = 7274716 and entity_key = 'com.comalatech.workflow.approvals';
    XMLTYPE(TEXT_VAL)
    <ApprovalChecks>
      <ApprovalCheck>
        <name>Edited</name>
        <version>7</version>
        <approvers>
          <Approver>
         <approved>true</approved>
         <user>bgra030</user>
         <date>2008-10-31 13:47:25.638 NZDT</date>
         <comment>Initial import from Word document without change</comment>
          </Approver>
        </approvers>
        <weight>10</weight>
        <id>1</id>
        <stateId>0</stateId>
        <attachments/>
      </ApprovalCheck>
      <ApprovalCheck>
        <name>Reviewed</name>
        <version>7</version>
        <approvers>
          <Approver>
         <approved>true</approved>
         <user>bgra030</user>
         <date>2008-10-31 13:47:30.532 NZDT</date>
         <comment/>
          </Approver>
        </approvers>
        <weight>20</weight>
        <id>2</id>
        <stateId>0</stateId>
        <attachments/>
      </ApprovalCheck>
      <ApprovalCheck>
        <name>Signoff</name>
        <version>7</version>
        <approvers>
          <Approver>
         <approved>true</approved>
         <user>bgra030</user>
         <date>2008-10-31 13:47:32.532 NZDT</date>
         <comment/>
          </Approver>
        </approvers>
        <weight>30</weight>
        <id>3</id>
        <stateId>0</stateId>
        <attachments/>
      </ApprovalCheck>
      <ApprovalCheck>
        <name>Edited</name>
        <version>8</version>
        <approvers>
          <Approver>
         <approved>true</approved>
         <user>bgra030</user>
         <date>2008-11-02 10:54:07.903 NZDT</date>
         <comment>Updated references re Wiki, removed unwanted sections</comment>
          </Approver>
        </approvers>
        <weight>10</weight>
        <id>4</id>
        <stateId>0</stateId>
        <attachments/>
      </ApprovalCheck>
      <ApprovalCheck>
        <name>Reviewed</name>
        <version>8</version>
        <approvers>
          <Approver>
         <approved>true</approved>
         <user>bgra030</user>
         <date>2008-11-02 10:54:10.552 NZDT</date>
         <comment/>
          </Approver>
        </approvers>
        <weight>20</weight>
        <id>5</id>
        <stateId>0</stateId>
        <attachments/>
      </ApprovalCheck>
      <ApprovalCheck>
        <name>Signoff</name>
        <version>8</version>
        <approvers>
          <Approver>
         <approved>true</approved>
         <user>bgra030</user>
         <date>2008-11-02 10:54:13.161 NZDT</date>
         <comment/>
          </Approver>
        </approvers>
        <weight>30</weight>
        <id>6</id>
        <stateId>0</stateId>
        <attachments/>
      </ApprovalCheck>
      <ApprovalCheck>
        <name>Edited</name>
        <version>9</version>
        <approvers>
          <Approver>
         <approved>true</approved>
         <user>bgra030</user>
         <date>2009-11-13 08:53:00.649 NZDT</date>
         <comment>Testing approval information</comment>
          </Approver>
        </approvers>
        <weight>10</weight>
        <id>7</id>
        <stateId>0</stateId>
        <attachments/>
      </ApprovalCheck>
      <ApprovalCheck>
        <name>Edited</name>
        <version>9</version>
        <approvers>
          <Approver>
         <approved>false</approved>
         <user>bgra030</user>
         <date>2009-11-13 08:53:13.830 NZDT</date>
         <comment/>
          </Approver>
        </approvers>
        <weight>10</weight>
        <id>8</id>
        <stateId>0</stateId>
        <attachments/>
      </ApprovalCheck>
      <ApprovalCheck>
        <name>Edited</name>
        <version>12</version>
        <approvers>
          <Approver>
         <approved>true</approved>
         <user>bgra030</user>
         <date>2009-11-23 11:08:14.666 NZDT</date>
         <comment>Changes due to self auditing, using Study Audit Checklist and DM Study Checklist</comment>
          </Approver>
        </approvers>
        <weight>10</weight>
        <id>9</id>
        <stateId>0</stateId>
        <attachments/>
      </ApprovalCheck>
      <ApprovalCheck>
        <name>Reviewed</name>
        <version>12</version>
        <approvers>
          <Approver>
         <approved>true</approved>
         <user>bgra030</user>
         <date>2009-11-23 11:08:20.345 NZDT</date>
         <comment/>
          </Approver>
        </approvers>
        <weight>20</weight>
        <id>10</id>
        <stateId>0</stateId>
        <attachments/>
      </ApprovalCheck>
      <ApprovalCheck>
        <name>Signoff</name>
        <version>12</version>
        <approvers>
          <Approver>
         <approved>true</approved>
         <user>bgra030</user>
         <date>2009-11-23 11:08:23.997 NZDT</date>
         <comment/>
          </Approver>
        </approvers>
        <weight>30</weight>
        <id>11</id>
        <stateId>0</stateId>
        <attachments/>
      </ApprovalCheck>
      <ApprovalCheck>
        <name>Edited</name>
        <version>13</version>
        <approvers>
          <Approver>
         <approved>true</approved>
         <user>bgra030</user>
         <date>2011-10-31 10:42:37.703 NZDT</date>
         <comment>No change, just change of name of a linked page</comment>
          </Approver>
        </approvers>
        <weight>10</weight>
        <id>12</id>
        <stateId>0</stateId>
        <attachments/>
      </ApprovalCheck>
      <ApprovalCheck>
        <name>Reviewed</name>
        <version>13</version>
        <approvers>
          <Approver>
         <approved>true</approved>
         <user>bgra030</user>
         <date>2011-10-31 10:42:40.596 NZDT</date>
         <comm
    1 row selected.My query is way off,... I can't even get it to run, let alone getting the record I want without some hard coding...
    Can anyone help?
    Thanks in advance.
    select y.y_name, y.y_version, z.z_approved, z.z_user, z.z_date, z.z_comment
    from WIKI.os_propertyentry t,
         XMLTABLE('$p/ApprovalChecks/ApprovalCheck'
                  PASSING t.text_val as "p"
                  COLUMNS y_name       VARCHAR2(30) PATH 'ApprovalCheck/name',
                          y_version    NUMBER       PATH 'ApprovalCheck/version',
                          Approver     XMLTYPE      PATH 'ApprovalCheck/approvers/Approver/*') y,
         XMLTABLE('$a/Approver'
                  PASSING y.Approver as "a"
                  COLUMNS z_approved  VARCHAR2(8)   PATH 'Approver/approved',
                          z_user      VARCHAR2(30)  PATH 'Approver/user',
                          z_date      DATE          PATH 'Approver/date',
                          z_comment   VARCHAR2(100) PATH 'Approver/comment') z
    where entity_id = 7274716 and entity_key = 'com.comalatech.workflow.approvals'
    and   t.name = 'Reviewed'
    and   t.version = 13;
               PASSING t.text_val as "p"
    ERROR at line 4:
    ORA-00932: inconsistent datatypes: expected - got CLOB

    Further to the above, the query returns a single record okay,...
    SQL > l  
      1  with all_versions as (
      2    select c.title, y.y_name, y.y_version, z.z_approved, z.z_user, z.z_date z_date, z.z_comment,
      3           row_number() over( order by to_timestamp_tz(z_date, 'YYYY-MM-DD HH24:MI:SS.FF3 TZD') desc ) as rn
      4    from wiki.os_propertyentry t, wiki.content c,
      5         XMLTABLE('$p/ApprovalChecks/ApprovalCheck'
      6               PASSING xmltype(t.text_val) as "p"
      7               COLUMNS y_name       VARCHAR2(30) PATH 'name',
      8                    y_version       NUMBER       PATH 'version',
      9                    Approver       XMLTYPE      PATH 'approvers/Approver/*') y,
    10         XMLTABLE('$a'
    11               PASSING y.Approver as "a"
    12               COLUMNS z_approved  VARCHAR2(8)   PATH '/approved',
    13                    z_user      VARCHAR2(30)  PATH '/user',
    14                    z_date      VARCHAR2(30)  PATH '/date',
    15                    z_comment      VARCHAR2(100) PATH '/comment') z
    16    where c.contentid = t.entity_id
    17    and   c.spaceid = (select spaceid from wiki.spaces where spacename = 'Quality')
    18    and   entity_id = 7274716
    19    and entity_key = 'com.comalatech.workflow.approvals'
    20    )
    21  select title, y_name, y_version
    22  from all_versions
    23* where rn = 1
    SQL> /
    TITLE                           Y_NAME                          Y_VERSION
    Quality Audits (NIHI-5001)     Signoff                     17
    1 row selected.... but I want to now query on all records, not just one.
    When I comment out the clause (and entity_id = xxxxx) I now get an error. I should have got ~300 records,.... what do I need to do to make this work?
    SQL > 18
    18*   and   entity_id = 7274716
    SQL> > c /and/-- and
    18*   -- and     entity_id = 7274716
    SQL > l
      1  with all_versions as (
      2    select t.entity_id, c.title, y.y_name, y.y_version, z.z_approved, z.z_user, z.z_date z_date, z.z_comment,
      3           row_number() over( order by to_timestamp_tz(z_date, 'YYYY-MM-DD HH24:MI:SS.FF3 TZD') desc ) as rn
      4    from wiki.os_propertyentry t, wiki.content c,
      5         XMLTABLE('$p/ApprovalChecks/ApprovalCheck'
      6               PASSING xmltype(t.text_val) as "p"
      7               COLUMNS y_name       VARCHAR2(30) PATH 'name',
      8                    y_version       NUMBER       PATH 'version',
      9                    Approver       XMLTYPE      PATH 'approvers/Approver/*') y,
    10         XMLTABLE('$a'
    11               PASSING y.Approver as "a"
    12               COLUMNS z_approved  VARCHAR2(8)   PATH '/approved',
    13                    z_user      VARCHAR2(30)  PATH '/user',
    14                    z_date      VARCHAR2(30)  PATH '/date',
    15                    z_comment      VARCHAR2(100) PATH '/comment') z
    16    where c.contentid = t.entity_id
    17    and   c.spaceid = (select spaceid from wiki.spaces where spacename = 'Quality')
    18    -- and     entity_id = 7274716
    19    and entity_key = 'com.comalatech.workflow.approvals'
    20    )
    21  select entity_id, title, y_name, y_version
    22  from all_versions
    23* where rn = 1
    wikiprod: OPS$IT_DBA > /
              PASSING xmltype(t.text_val) as "p"
    ERROR at line 6:
    ORA-31011: XML parsing failed
    ORA-19202: Error occurred in XML processing
    LPX-00241: entity reference is not well formed
    Error at line 8
    ORA-06512: at "SYS.XMLTYPE", line 272
    ORA-06512: at line 1

  • Query result list sort order in the Service Manager Portal (2012).

    Hi there,
    I have a setup a user prompt for a request offering in which the values are based on a query results list.  When the user prompt is displayed in the portal the order of the items presented based on my query results list is in reverse
    alphabetical order (Z to A) instead of traditional A to Z.  I can clicked the column header to toggle the sort order, however having to do this is slightly annoying.
    My query results list is based on returning the Department field of a specific criteria of template AD user accounts (which are imported into the CMDB via the AD Connector).
    Where and how is the sort order defined?
    Thanks
    Bryan

    Hi Bryan,
    After a quick test I can see the query results is in a descending order based on the first display column of the query results configuration. In the Request offering wizard I don't see an option for sorting. I don't think it is possible to configure this
    out of the box. 
    But maybe it is possible from a Self Service Portal rendering point of view. Maybe there is a key for it in the settings.xml just like the maximum of query results:
    http://blogs.technet.com/b/servicemanager/archive/2011/11/08/advanced-query-results-customization-for-request-offerings.aspx
    If this is possible I'm also curious to know how! :)
    - Dennis

  • Need a query to list all table names

    I have more than 500 tables in my database.
    'insert_date' & 'update_date' columns are found in more than 100 tables with data type as date.
    I need a query to list all table names and 'insert_date' , 'update_date' column's content.
    Please Help
    Lee1212
    Message was edited by:
    LEE1212

    I have more than 500 tables in my database.
    'insert_date' & update_date column is found in more
    than 100 tables with data type as date.
    I need a query to list all table names and
    'insert_date' column's content.What do you mean by "column's content". A table can have many rows. Do you want to display all the distinct value for these columns?
    Below is the query to get the tables which has columns insert_Date and update_date
    select table_name
    from user_tab_columns
    where column_name ='INSERT_DATE'
    or column_name ='UPDATE_DATE'
    /You can write a PL/SQL block to retrive the distinct values of INSERT_DATE for these tables
    declare
    TYPE ref_cur IS REF CURSOR;
    insert_date_cur ref_cur;
    lv_insert_date DATE;
    cursor tables_list IS
    select table_name
    from user_tab_columns
    where column_name ='INSERT_DATE';
    begin
    for cur_tables in tables_list
    loop
      OPEN insert_date_cur for 'SELECT DISTINCT insert_date from '||cur_tables.table_name;
      DBMS_OUTPUT.PUT_LINE(cur_tables.table_name);
      DBMS_OUTPUT.PUT_LINE('--------------------------------');
      LOOP
      FETCH insert_date_cur into lv_insert_date;
      EXIT WHEN insert_date_cur%NOTFOUND;
      DBMS_OUTPUT.PUT_LINE(lv_insert_date);
      END LOOP;
    CLOSE insert_date_cur;
    end loop;
    end;I haven't tested this code. There might be some errors. Just posted something to start with for you.

  • Trying to convert a CLOB to an XMLTYPE

    I'm trying to insert a xm ldocument stored in a CLOB into a XMLTYPE column registered to a schema.
    I'm trying so use the function below to convert the CLOB to an XMLTYPEbut i keep getting a ORA-06553 Error: wrong number or arguments. Am i using the xmltype constructor properly?
    create or replace function to_xmltype (clobcol CLOB)
    return xmltype as
    begin
    return xmltype(clobcol,'http://localhost:8080/source/schemas/poSource/xsd/mySchema.xsd');
    end;
    insert into xml_table (xmldata) values (select to_xmltype(ct.clob_data) from clob_table ct );
    Thanks for the help

    Looks fine to me except that you should omit the values clause:
    insert into xml_table (xmldata) select to_xmltype(ct.clob_data) from clob_table ct ;

  • How to insert data to the specified row column of the multi column list box

    Hi All
    How do i insert data into the specified column of the multi cplumn list box?
    I have a table that containsall station nos and name.Then another table contains the data the various stations having at  for 24 hrs.That is 12 am to 11 pm.
    And i want to display each stations details as follows using a multi column list box/table
    My stationinfo table
    stnno   stnname......................
    s1           stn1
    s2            stn2
    s3             stn3
    The other table
    stnno      sysdatetime       data
    s1             12am                   1
    s2              12am                   4
    s1               1  am                 2
    So the station s1,s2.... will have data for 24 hrs.
    And i want to display it as follows using a multicolumn listbox
    stnname        12am   1 am ......................................11pm
    s1                   ...................
    s2                 ........................
    What i have in my  mind is to get all station nos
    and in a for loop get the station's data from 12 am to 11 pm
    or
    select every statios data for each hor.But in this case i have to query the database 24 times.So i dont think its a good way.
    Or any other better query available?
    Can anybody suggest me a good idea?
    One more thing...how to insert data into the specified field row or column of a multi column list box?
    Thanks in advance

    hi
    i want to know,,can u say ur need clearly...and i attached two image u see that one
    Indrajit
    | [email protected] | [email protected] .
    Attachments:
    station.JPG ‏35 KB
    station2.JPG ‏79 KB

  • SQL query to list all collections, members, OS, SP, IP and if physical/virtual

    Hi guys, I have the below query which lists all the collections and their members, however I need to expand it to also include the OS, Service Pack, IP and if it's a physical or virtual machine.
    I've tried a few things but only made it worse. Is anyone able to expand the below code to include those extras??
    SELECT
    v_FullCollectionMembership.CollectionID AS 'CollID',
    v_Collection.Name AS 'CollName',
    v_FullCollectionMembership.Name AS 'SystemName'
    FROM
    v_FullCollectionMembership, v_Collection
    WHERE v_FullCollectionMembership.CollectionID = v_Collection.CollectionID
    ORDER BY
    CollID ASC, SystemName ASC

    Hi,
    These requirements could be found in several threads or blogs. We need convert WQL to SQL, and you can involve SQL guys to integrate the statements and format the result.
    How to create a all virtual machines collection.
    SCCM SQL Query - IP Address
    ConfigMgr Systems without Current Service Packs, and System Patch Status 

  • Query to list all the key words

    Hi all,
    Could anyone tell me the query to list out all the keywords that are used in Oracle.
    That will be very helpful to me
    Thanks

    I created a new user and just gave him CREATE SESSION privilege. He has nothing else
    SQL> connect sys/*****@****** as sysdba
    Connected.
    SQL> create user reserve_word_test identified by password
      2  /
    User created.
    SQL> grant create session to reserve_word_test
      2  /
    Grant succeeded.Now i connect as that user and query V$RESERVE_WORDS
    SQL> connect reserve_word_test/password@******
    Connected.
    SQL> SELECT * FROM V$RESERVED_WORDS
      2  /
    SELECT * FROM V$RESERVED_WORDS
    ERROR at line 1:
    ORA-00942: table or view does not existAs the user does not have access to the data dictionary table its erroring out.
    But see this
    SQL> help reserved words
    RESERVED WORDS (PL/SQL)
    PL/SQL Reserved Words have special meaning in PL/SQL, and may not be used
    for identifier names (unless enclosed in "quotes").
    An asterisk (*) indicates words are also SQL Reserved Words.
    ALL*            DESC*           JAVA            PACKAGE         SUBTYPE
    ALTER*          DISTINCT*       LEVEL*          PARTITION       SUCCESSFUL*
    AND*            DO              LIKE*           PCTFREE*        SUM
    ANY*            DROP*           LIMITED         PLS_INTEGER     SYNONYM*
    ARRAY           ELSE*           LOCK*           POSITIVE        SYSDATE*
    AS*             ELSIF           LONG*           POSITIVEN       TABLE*
    ASC*            END             LOOP            PRAGMA          THEN*
    AT              EXCEPTION       MAX             PRIOR*          TIME
    AUTHID          EXCLUSIVE*      MIN             PRIVATE         TIMESTAMP
    AVG             EXECUTE         MINUS*          PROCEDURE       TIMEZONE_ABBR
    BEGIN           EXISTS*         MINUTE          PUBLIC*         TIMEZONE_HOUR
    BETWEEN*        EXIT            MLSLABEL*       RAISE           TIMEZONE_MINUTE
    BINARY_INTEGER  EXTENDS         MOD             RANGE           TIMEZONE_REGION
    BODY            EXTRACT         MODE*           RAW*            TO*
    BOOLEAN         FALSE           MONTH           REAL            TRIGGER*
    BULK            FETCH           NATURAL         RECORD          TRUE
    BY*             FLOAT*          NATURALN        REF             TYPE
    CHAR*           FOR*            NEW             RELEASE         UI
    CHAR_BASE       FORALL          NEXTVAL         RETURN          UNION*
    CHECK*          FROM*           NOCOPY          REVERSE         UNIQUE*
    CLOSE           FUNCTION        NOT*            ROLLBACK        UPDATE*
    CLUSTER*        GOTO            NOWAIT*         ROW*            USE
    COALESCE        GROUP*          NULL*           ROWID*          USER*
    COLLECT         HAVING*         NULLIF          ROWNUM*         VALIDATE*
    COMMENT*        HEAP            NUMBER*         ROWTYPE         VALUES*
    COMMIT          HOUR            NUMBER_BASE     SAVEPOINT       VARCHAR*
    COMPRESS*       IF              OCIROWID        SECOND          VARCHAR2*
    CONNECT*        IMMEDIATE*      OF*             SELECT*         VARIANCE
    CONSTANT        IN*             ON*             SEPERATE        VIEW*
    CREATE*         INDEX*          OPAQUE          SET*            WHEN
    CURRENT*        INDICATOR       OPEN            SHARE*          WHENEVER*
    CURRVAL         INSERT*         OPERATOR        SMALLINT*       WHERE*
    CURSOR          INTEGER*        OPTION*         SPACE           WHILE
    DATE*           INTERFACE       OR*             SQL             WITH*
    DAY             INTERSECT*      ORDER*          SQLCODE         WORK
    DECIMAL*        INTERVAL        ORGANIZATION    SQLERRM         WRITE
    DECLARE         INTO*           OTHERS          START*          YEAR
    DEFAULT*        IS*             OUT             STDDEV          ZONE
    DELETE*         ISOLATION
    RESERVED WORDS (SQL)
    SQL Reserved Words have special meaning in SQL, and may not be used for
    identifier names unless enclosed in "quotes".
    An asterisk (*) indicates words are also ANSI Reserved Words.
    Oracle prefixes implicitly generated schema object and subobject names
    with "SYS_". To avoid name resolution conflict, Oracle discourages you
    from prefixing your schema object and subobject names with "SYS_".
    ACCESS          DEFAULT*         INTEGER*        ONLINE          START
    ADD*            DELETE*          INTERSECT*      OPTION*         SUCCESSFUL
    ALL*            DESC*            INTO*           OR*             SYNONYM
    ALTER*          DISTINCT*        IS*             ORDER*          SYSDATE
    AND*            DROP*            LEVEL*          PCTFREE         TABLE*
    ANY*            ELSE*            LIKE*           PRIOR*          THEN*
    AS*             EXCLUSIVE        LOCK            PRIVILEGES*     TO*
    ASC*            EXISTS           LONG            PUBLIC*         TRIGGER
    AUDIT           FILE             MAXEXTENTS      RAW             UID
    BETWEEN*        FLOAT*           MINUS           RENAME          UNION*
    BY*             FOR*             MLSLABEL        RESOURCE        UNIQUE*
    CHAR*           FROM*            MODE            REVOKE*         UPDATE*
    CHECK*          GRANT*           MODIFY          ROW             USER*
    CLUSTER         GROUP*           NOAUDIT         ROWID           VALIDATE
    COLUMN          HAVING*          NOCOMPRESS      ROWNUM          VALUES*
    COMMENT         IDENTIFIED       NOT*            ROWS*           VARCHAR*
    COMPRESS        IMMEDIATE*       NOWAIT          SELECT*         VARCHAR2
    CONNECT*        IN*              NULL*           SESSION*        VIEW*
    CREATE*         INCREMENT        NUMBER          SET*            WHENEVER*
    CURRENT*        INDEX            OF*             SHARE           WHERE
    DATE*           INITIAL          OFFLINE         SIZE*           WITH*
    DECIMAL*        INSERT*          ON*             SMALLINT*
    SQL>If sql plus accesses the database then how its possible?

  • Howto handle persistence API query result list

    Hello.
    I need some advice on how to handle a persistence API query result List since the Object variable returned by the "list.get(i)" method cannot be cast to an EntityClass declared by the EntityClassManager.
    The piece of code below might help you understand my exact problem.
    EntityManagerFactory emf = Persistence.createEntityManagerFactory("SporTakipPU");
    EntityManager em = (EntityManager) emf.createEntityManager();
    Query q1 = em.createQuery( "SELECT d.id, d.date, c.name, c.sirname FROM Log d, Kisi c WHERE d.id = :id AND c.id = :id" );
    q1.setParameter( "id", argument );
    List logList = q1.getResultList();
    Log log = (Log) logList.get(1);
    In this code i cannot cast Object to Log in the last line. Apparently this has something to do with the query.
    Trying to solve this problem i declared two private string variables name and sirname and their set and get methods but this didn't help.
    Thanks...

    Entity Class : ReportView
    ===================
    @Entity
    @Table(name = "dummy")
    public class ReportView implements Serializable {
    @Id
    @Column(name = "id", nullable = false)
    private Integer id;
    // getter , setter
    SessionBean : ReportSessionBean
    ==========================
    public List<ReportView> getReports() {
    Query q = em.createNativeQuery("SELECT ID FROM REPORT", ReportView.class);
    List<ReportView> r=(List<ReportView>)q.getResultList();
    return r;
    JSF / Back Bean : ReportBackBean
    ==========================
    public class ReportBackBean {
    @EJB
    private ReportSessionRemote reportSessionBean;
    /** Creates a new instance of ReportBackBean */
    public ReportBackBean() {
    public List<ReportView> getReports() {
    return reportSessionBean.getReports();
    JSF
    ===
    <f:view>
    <h:dataTable value="#{ReportBackBean.reports}" var="report" border="1">
    <h:column>
    <h:outputText value="#{report.id}"/>
    </h:column>
    </h:dataTable>
    </f:view>
    Regards,
    Telman
    ..

  • ABAP Query, To list both, the PO created and PO modified for a given period

    Hi
    I want to create a query that list the purchasing orders created or modified during a given period. however, the creation date and the modification date are two different fields stored in differents tables.
    if I have these two fields in the selection creteria screen, the relationship between them will be the operator AND. so this will not enable me to have the information targeted.
    My quetion, is there a possibility to have the Operator OR in the first selection creteria screen , between these 2 fields.?
    the tables are:
    for the creation EKKO
    for the change :
    MECDGRID
    CDHDR Change document header
    CDPOS Change document items
    thanks

    Hello,
    Fetch data from EKKO and do a for all entries on the table CDHDR on the field OBJECTID and EBELN and t-code = ME21N OR ME21 ETC.
    Similarly between CDHDR and CDPOS tables based on objectid`s.
    Hope this helps you in solving your problem!
    Regards,
    Reetesh

Maybe you are looking for

  • Sorting problem in report

    hi, i am facing an issue with sorting of the values of a report in dashboard. the report consists of 15 columns and retrieves around 5000 rows in total. the first column is of varchar datatype and is the ID(unique). the rest are numeric datatype colu

  • I need help on standard workflow of Release for payment

    Hello to everyone, I'm trying to use WF WS00400011 standard provided by SAP through the PFTC and I activated it, inform a user that I created called WF different from my user, who will be responsible in the task standand (TS00407862) and also went to

  • Billing Service Contracts per order instead of a billing plan

    Is it possible, with standard config, to disconnect the billing plan from a service contract and bill the service order itself with a fixed labor charge. Where the fixed labor charge amount comes from the contract. In other words, we want to bill ser

  • Region bounded taskflow one level up task flow activity

    Hello, in a jspx I use the <af:region> tag with the value pointing to bean from which I get the bounded task flow calling several .jsff files. At the end of the processing I want to go back to the level of the original jspx to continue calling other

  • IPhoto won't print - no themes...again

    Hi, I've done a search for this one and it can't be the first time it's come up but I can't find the precise description anywhere else so here goes and hope someone can help... I've got an iMac and a MacbookAir, both bought with OS Snow Leopard insta