Dynamic sql in SQL field

hello,
I need execute an SQL dynamic as field's SQL:
select field1, '(select field2 from table2)'
from table1;
And this field2 as output number. It's possible?

As Billy says, what are you trying to achieve?
SQL> create table a (id number, txt varchar2(20));
Table created.
SQL> create table b (id number, txt varchar2(20));
Table created.
SQL> insert into a select 1, 'fred' from dual union
  2                select 2, 'jim' from dual union
  3                select 3, 'bob' from dual;
3 rows created.
SQL> insert into b select 1, 'typesetter' from dual union
  2                select 2, 'builder' from dual union
  3                select 3, 'stripper' from dual;
3 rows created.
SQL> select a.id, a.txt, (select b.txt from b where b.id = a.id)
  2  from a;
        ID TXT                  (SELECTB.TXTFROMBWHE
         1 fred                 typesetter
         2 jim                  builder
         3 bob                  stripper
SQL> select a.id, a.txt, b.txt
  2  from a JOIN b ON (a.id = b.id);
        ID TXT                  TXT
         1 fred                 typesetter
         2 jim                  builder
         3 bob                  stripper
SQL> select a.id, a.txt, cursor(select b.txt from b)
  2  from a;
        ID TXT                  CURSOR(SELECTB.TXTFR
         1 fred                 CURSOR STATEMENT : 3
CURSOR STATEMENT : 3
TXT
typesetter
builder
stripper
         2 jim                  CURSOR STATEMENT : 3
CURSOR STATEMENT : 3
TXT
typesetter
builder
stripper
         3 bob                  CURSOR STATEMENT : 3
CURSOR STATEMENT : 3
TXT
typesetter
builder
stripper
SQL>

Similar Messages

  • Sql Problems, Same Field Names In Multiple Mysql Tables?

    I have a keyword search that searches multiple DB tables for thumbnail images using UNION ALL. I have two pages, results.php, and view.php.  My goal is to able to click a thumbnail image on results.php and be directed to a larger version of that same image on view.php. The problem is each image in all my tables uses the field name "id" so when I click a thumbnail on results.php I get two different images with the same id from different tables.  I tried changing the id's to different names, but when it was time to pass url parameters I can only choose 1 value. (if you can choose more than 1 I don't know how).  So my question is why are my id's from different tables being grouped together, and how can I change this?
    Image Results Page (which works perfect):
    SELECT *
    FROM table1
    WHERE keyword LIKE %colname% OR id  LIKE %colname% 
    UNION ALL
    SELECT *
    FROM table2
    WHERE keyword LIKE %colname% OR id  LIKE %colname% 
    View Image Page (having problems here):
    SELECT *
    FROM table1
    WHERE id = colname
    UNION ALL
    FROM table2
    WHERE id = colname

    Yes, that is going to be a problem - and it's just the beginning of your problems when you do not normalize your data. Your data model is not correct. You should not be storing similar data in 15 tables - it's a really big mistake.
    To solve your current problem you would need to include a table identifier in the query results in the Image results page, and pass that to the view page and then use PHP to dynamically create the SQL with the correct table....ugh!

  • ORACLE 8I SQL*LOADER DATAFILE의 특정 FIELD DATA를 SKIP하고 LOADING하는 방법

    제품 : ORACLE SERVER
    작성날짜 : 2002-04-09
    ORACLE 8I SQL*LOADER DATAFILE의 특정 FIELD DATA를 SKIP하고 LOADING하는 방법
    ===========================================================================
    아래의 예제와 같이 가변 길이의 filed들이 ',', '|' 와 같은 구분자로
    구분이 되고 있는 경우 oracle 8i부터 제공되는 'FILLER'라고 하는 필드
    구분자를 사용하여 상태인식자로 표시하여 insert시 skip할 수 있다.
    <Example>
    TABLE : skiptab
    ===========================
         col1 varchar2(20)
         col2 varchar2(20)
         col3 varchar2(20)
    CONTROLFIEL : skip.ctl
    load data
    infile skip.dat
    into table skiptab
    fields terminated by ","
    (col1 char,
    col2 filler char,
    col3 char)
    DATAFILE : skip.dat
    SMITH, DALLAS, RESEARCH
    ALLEN, CHICAGO, SALES
    WARD, CHICAGO, SALES
    data loading :
    $sqlldr scott/tiger control=skip.ctl
    결과 :
    COL1 COL3
    SMITH RESEARCH
    ALLEN SALES
    WARD SALES

  • Generate dynamic reports using sql query and send via mail

    Can anyone provide me the links to dynamically generate the sql query based reports and send it to Mail. it should be called from the scheduler program using PL/SQL

    suppose you have the query as
    spool myrep.txt
    select * from emp where rowid<3;
    spool off
    write the query in the emp.sql query at any directory like d:\sqljobs\emp.sql
    the call make a batch file like sndml.bat and write the following codes
    sqlplus scott/tiger@orcl @d:\sqljobs\emp.sql
    explorer mailto:[email protected] d"\sqljobs\myrep.txt
    or if you are using any mailing software then you can use that..

  • SQL for webADI fields

    Hello,
    I need a SQL to retrieve the fields and another field to show whether it is a line or header for the Project WebADI.
    Can anyone provide me with this SQL if you have ever worked on this?
    Thanks & Regards,
    Yuvraj

    SELECT DISTINCT fap.application_short_name "Application Short Name",
                      bib.user_name "Integrator User Name",
                      blb.user_name "Layout Name",
                      bicb.interface_col_name "Field Name",
                      blbb.user_name "Placement",                 
                      blc.DEFAULT_VALUE "Default Value",
                      CASE UPPER (NVL (blc.default_type, 'NONE'))
                         WHEN 'NONE' THEN 'None'
                         WHEN 'FORMULA' THEN 'Formula'
                         WHEN 'CONSTANT' THEN 'Constant'
                         WHEN 'PARAMETER' THEN 'Parameter'
                         WHEN 'SQL' THEN 'SQL'
                         WHEN 'ENVIRONMENT' THEN 'Environment'
                         ELSE 'UNKNOWN'
                      END
                         "Default Type"
        FROM apps.fnd_application fap,
             apps.bne_integrators_vl bib,
             apps.bne_layouts_vl blb,
             apps.bne_layout_blocks_tl blbb,
             apps.bne_layout_cols blc,
             apps.bne_interface_cols_b bicb,
             apps.bne_components_b bcb,
             apps.bne_param_lists_b bplb,
             apps.bne_param_list_items bpli
       WHERE     1 = 1
             AND fap.application_id = bib.application_id
             -- bne_integrators_b | bne_layouts_b
             AND bib.integrator_code = blb.integrator_code
             AND bib.application_id = blb.integrator_app_id
             -- bne_layouts_b | bne_layout_blocks_b
             AND blb.layout_code = blbb.layout_code
             AND blb.application_id = blbb.application_id
             -- bne_layout_blocks_b | bne_layout_cols
             AND blbb.layout_code = blc.layout_code
             AND blbb.application_id = blc.application_id
             AND blbb.block_id = blc.block_id
             -- bne_layout_cols | bne_interface_cols_b
             AND blc.application_id = bicb.application_id
             AND blc.interface_code = bicb.interface_code
             AND blc.sequence_num = bicb.sequence_num
             -- bne_interface_cols_b | bne_components_b
             AND bicb.application_id = bcb.application_id
             AND bicb.val_component_code = bcb.component_code
             -- bne_components_b | bne_param_lists_b
             AND bcb.param_list_code = bplb.param_list_code
             -- bne_param_lists_b | bne_param_list_items
             AND bplb.param_list_code = bpli.param_list_code
             AND blbb.language = 'US'
             AND fap.application_short_name = 'PA'
    ORDER BY 1, 2;

  • How to submit an input dynamically to an sql script in a shell script

    Dear all,
    I have a shell script myscript.sh, in that I am running an sql script , say mysql.sql, the sql script prompts for a value, and I have to type that prompted value to run the script. How can I give this value in my shell script itself.
    Sample script
    #!/bin/bash
    echo "script starting at $(date)"
    sqlplus apps/apps @mysql.sql
    echo "script completed at $(date)"
    exit
    Regards,
    Charan

    Hi,
    Please see
    $cat sql_para.sh
    #!/bin/bash
    . .bash_profile
    sqlplus -s apps/apps @status $1
    $cat status.sql
    select status from v$instance where host_name='&1';
    exit;$./sql_para.sh TEST
    You may also see
    http://www.nsa.no/259/shell-scripting-dbas-using-awk-manipulate-oratab
    https://communities.bmc.com/communities/docs/DOC-9942
    Thanks

  • SQL, PL/SQL Expression and PL/SQL function

    In a Post Calculation Computation field I wanted the following computation:
    if B is X
    then
    field = A
    else
    field = B
    end if;
    or as a decode
    Decode(B,X,A,B)
    I could not get this to work so I wrote a database function that simulates the decode. So when I put:
    My_decode(B,X,A,B)
    in the field it did work.
    Basically I am not sure what kind of code one is expected to put into SQL, PL/SQL Expression and PL/SQL function fields. Can someone give an example of each? Also the APEX help is sometimes incorrect.
    For example if you click the "Post Calculation Computation" label it says:
    The For example, if this item is named P1_X, you could use post calculation expressions such as UPPER(:P1_X), INITCAP(:P2_Y), MIN(:P1_X,:P2_Y-200), NVL(:P1_X,:P2_Y), or a function call such as return my_func(:P1_X); to set the final value of the item.
    But if you put return my_func(:P1_X); in the field you get an error. It should be just my_func(:P1_X);
    thanks Rene

    DECODE is only available in SQL, so would have to be used in a SQL Expression.Yes, that's what APEX keeps telling me when I use in in a field that has "SQL or PL/SQL expression" above it. So what do you put in the field?

  • How to download Oracle SQL / PL SQL

    Hi all
    I am pretty new to this IT field. I am on H4 visa in US so i thought of doing some online course.
    Can anybody let me know how to download Orcale SQL / PL SQL to practise and its related notes / material.
    Thanks,
    Abirami

    [url http://www.oracle.com/technetwork/indexes/documentation/index.html] Oracle Documentation has it all

  • SQL*PLUS를 사용하여 SQL SCRIPT를 동적으로 생성, 수행

    제품 : SQL*PLUS
    작성날짜 : 2003-05-29
    이 Documents 는 SQL 과 SQL*PLUS를 동적으로 생성하고 수행하는 방법을
    소개하고 있다. 이를 위해 자주 사용하는 3가지 사용 예를 소개한다.
    이 Document는 다음과 같이 구성되어져 있다.
    1. CREATING A DYNAMIC DROP TABLE SCRIPT
    2. CREATING A DYNAMIC GRANT PRIVILEGES SCRIPT
    3. CREATING A DYNAMIC SCRIPT TO SET SQL PROMPT TO DATABASE NAME
    1. CREATING A DYNAMIC DROP TABLE SCRIPT
    개발 과정 중 우리는 Table을 Drop하고 Original Data를 Import하는 작업을
    빈번하게 수행하는데, 이 때 개개의 Drop 문을 사용하지 않고
    SET_UP_DROP.SQL 이라 불리우는 다음의 Script를 사용한다.
    set heading off
    set feedback off
    spool drop_all.sql
    select 'drop table'||table_name||';'from user_tables;
    spool off
    set feedback on
    start drop_all.sql
    DROP_ALL.SQL script 는 다음과 같다.
    drop table DEPT;
    drop table BONUS;
    drop table SALGRADE;
    drop table DUMMY;
    drop table CUSTOMER;
    drop table ORD;
    drop table ITEM;
    drop table PRODUCT;
    drop table PRICE;
    2. CREATING A DYNAMIC GRANT PRIVILEGES SCRIPT
    자신의 모든 Table 을 다른 사람에게 SELECT 권한을 부여하고자 할 때 다음
    의 SET_UP_GRANT.SQL 을 이용하면 빠르고 손쉽게 해결할 수 있다.
    set heading off
    set feedback off
    spool grant_all.sql
    select 'grant select on'||table_name||'to SCOTT;'from user_tables;
    spool off
    set feedback on
    start grant_all.sql
    GRANT_ALL.SQL 의 script 는 다음과 같다.
    grant select on DEPT to SCOTT;
    grant select on BONUS to SCOTT;
    grant select on SALGRADE to SCOTT;
    grant select on DUMMY to SCOTT;
    grant select on CUSTOMER to SCOTT;
    grant select on ORD to SCOTT;
    grant select on ITEM to SCOTT;
    grant select on PRODUCT to SCOTT;
    grant select on PRICE to SCOTT;
    3. CREATING A DYNAMIC SCRIPT TO SET SQL PROMPT TO DATABASE NAME
    위의 개념들을 보다 더 잘 사용하기 위해서는 SQL Prompt를 자신의
    Database로 변환해주는 SET_UP_PROMPT.SQL Script를 login.sql File 에
    추가시켜 자동적으로 SQL*PLUS를 불러 올 수 있게 한다.
    이는 Multiple Databases에 유용하다.
    set termout off
    set heading off
    set feedback off
    spool set_prompt.sql
    select 'set sqlprompt'||value||'>"from v$parameter
    where name='db_name';
    spool off
    start set_prompt.sql
    SET_PROMPT.SQL 은 다음과 같다.
    set sqlprompt V734>
    V$PARAMETER 는 Dynamic Performance Table 의 View 이다. Install 후 SYS
    user만이 Dynamic Performance Table을 수행할 수 있으므로 위의 Script를
    사용하기 위해 View를 Create 하거나 User에게 Access 권한을 부여하여야
    한다.
    Reference Documents
    <Note:17387.1>

  • Is it possible to see SQL in SQL-T without having to check out the mapping?

    Hello guys, Is it possible to see SQL in SQL-T without having to check in the mapping? At my work they use SQL-T a lot and in SQL query tab they use a lot of SQL so I was wondering if you can see the query without checking out the mapping?  Let me know. Thanks

    Hi All, I am facing an issue wherein Decimal value of 0.01 is getting converted to 0.00. Let me brief you about Source-Target Types Source - Flat FileTarget - DB2Powercenter Version - 9.6.1 HF2 Issue -  Field in Source Flat file is defined as Number(5,2). Corrosponding field from DB2 Target Table is defined as Decimal(5,2). Mapping is simple straight forward mapping with 1:1 loading from Source to Target. Now, my Source File contain data as below0.010.020.0312.01 When I execute mapping DB2 target Table gets loaded with all records. Value from corrosponding field from DB2 target table is - 0.000.020.0312.01 As you can see, value of 0.01 is getting converted to 0.00 where as all other values are working fine as expected. As a quick fix I have applied to_decimal(source_field,2) before loading into Target. Could anyone explain if this is a bug in Powercenter or there's some other issue. If I think its a rounding issue then how come value of 0.02 is getting processed correctly? Please advise. Thanks,Rajesh Agrawal

  • PL/SQL vs SQL

    What are the fundamental differences between PL/SQL and SQL?

    Just to expand on what was said.
    PL/SQL is a formal procedural language based on Ada (Ada and Pascal are very similar). PL/SQL is in that respect equivalent to C, Pascal, Visual Basic etc.
    What makes PL/SQL different (a 4GL instead of a 3GL) is that it is specifically designed to deal with data processing problems in Oracle using SQL.
    In 3GLs you need to use SQL pre-compilers or special classes (wrapping the database's SQL call interface) to talk SQL to the database. E.g. Pro*C precompiler for use with C. The TQuery class in Delphi that wraps the Oracle Call Interface (OCI) into an object class.
    PL/SQL goes further as it allows you to natively use SQL inside the language, as if it is part of the language. The PL compiler/PL engine is however clever enough to recognise SQL statements and do the complex stuff needed to make a SQL call to the SQL engine. It handles bind variables for you. It handles SQL data types for you. It does the SQL engine call for you. It fetches the data from the SQL engine for you. Etc.
    Using SQL natively in the PL language is what makes PL/SQL so powerfull. It blurs the line between having to deal with two separate langauges - a procedure (and object orientated) programming language and the SQL language.
    This blurring does have its cons . Developers often fail to recognise just what is PL and what is SQL ito doing a proper program design and implementation. Or they treat PL/SQL as something different than Java, Delphi or C/C++. A programming language is a programming language, Programming 101 fundamentals apply. Irrespective of the language. Period.
    For example, they use PL/SQL cursor fetch loops to process SQL data in a row-by-row fashion, instead of using SQL to do that work instead. SQL is by far superior in this regard. Or they use SQL (i.e. SELECT func() INTO var FROM dual) to assign values from functions to PL/SQL variables. Why use SQL to do perform this variable assignment when dealing with PL variables?
    There are numerous brain farts from developers in this respect. Not understanding PL/SQL. Not even bothering to familiarise themselves with the Oracle manuals on the language. Which is a pity as this result in crappy code and a developer that fails to understand Oracle. Worse, developers start to dislike Oracle because it "does not work properly" due to their utter failure to grasp the concepts of the database and the language.
    However, if you understand what PL is and what SQL is in PL/SQL, and you treat both languages correctly, no other language on this planet allows you to process Oracle data more effectively. Fact: PL/SQL scales and performs better than whatever Java architecture and code you can deploy on an application tier.

  • How to resolve most of the Oracle SQL , PL/SQL Performance issues with help of quick Checklist/guidelines ?

    Please go thru below important checklist/guidelines to identify issue in any Perforamnce issue and resolution in no time.
    Checklist for Quick Performance  problem Resolution
    ·         get trace, code and other information for given PE case
              - Latest Code from Production env
              - Trace (sql queries, statistics, row source operations with row count, explain plan, all wait events)
              - Program parameters & their frequently used values
              - Run Frequency of the program
              - existing Run-time/response time in Production
              - Business Purpose
    ·         Identify most time consuming SQL taking more than 60 % of program time using Trace & Code analysis
    ·         Check all mandatory parameters/bind variables are directly mapped to index columns of large transaction tables without any functions
    ·         Identify most time consuming operation(s) using Row Source Operation section
    ·         Study program parameter input directly mapped to SQL
    ·         Identify all Input bind parameters being used to SQL
    ·         Is SQL query returning large records for given inputs
    ·         what are the large tables and their respective columns being used to mapped with input parameters
    ·         which operation is scanning highest number of records in Row Source operation/Explain Plan
    ·         Is Oracle Cost Based Optimizer using right Driving table for given SQL ?
    ·         Check the time consuming index on large table and measure Index Selectivity
    ·         Study Where clause for input parameters mapped to tables and their columns to find the correct/optimal usage of index
    ·         Is correct index being used for all large tables?
    ·         Is there any Full Table Scan on Large tables ?
    ·         Is there any unwanted Table being used in SQL ?
    ·         Evaluate Join condition on Large tables and their columns
    ·         Is FTS on large table b'cos of usage of non index columns
    ·         Is there any implicit or explicit conversion causing index not getting used ?
    ·         Statistics of all large tables are upto date ?
    Quick Resolution tips
    1) Use Bulk Processing feature BULK COLLECT with LIMIT and FOR ALL for DML instead of row by row processing
    2) Use Data Caching Technique/Options to cache static data
    3) Use Pipe Line Table Functions whenever possible
    4) Use Global Temporary Table, Materialized view to process complex records
    5) Try avoiding multiple network trips for every row between two database using dblink, Use Global temporary table or set operator to reduce network trip
    6) Use EXTERNAL Table to build interface rather then creating custom table and program to Load and validate the data
    7) Understand Oracle's Cost based Optimizer and Tune most expensive SQL queries with help of Explain plan
    8) Follow Oracle PL/SQL Best Practices
    9) Review tables and their indexes being used in the SQL queries and avoid unnecessary Table scanning
    10) Avoid costly Full Table Scan on Big Transaction tables with Huge data volume,
    11) Use appropriate filtration condition on index columns of seeded Oracle tables directly mapped to program parameters
    12) Review Join condition on existing query explain plan
    13) Use Oracle hint to guide Oracle Cost based optimizer to choose best plan for your custom queries
    14) Avoid applying SQL functions on index columns
    15) Use appropriate hint to guide Oracle CBO to choose best plan to reduce response time
    Thanks
    Praful

    I understand you were trying to post something helpful to people, but sorry, this list is appalling.
    1) Use Bulk Processing feature BULK COLLECT with LIMIT and FOR ALL for DML instead of row by row processing
    No, use pure SQL.
    2) Use Data Caching Technique/Options to cache static data
    No, use pure SQL, and the database and operating system will handle caching.
    3) Use Pipe Line Table Functions whenever possible
    No, use pure SQL
    4) Use Global Temporary Table, Materialized view to process complex records
    No, use pure SQL
    5) Try avoiding multiple network trips for every row between two database using dblink, Use Global temporary table or set operator to reduce network trip
    No, use pure SQL
    6) Use EXTERNAL Table to build interface rather then creating custom table and program to Load and validate the data
    Makes no sense.
    7) Understand Oracle's Cost based Optimizer and Tune most expensive SQL queries with help of Explain plan
    What about using the execution trace?
    8) Follow Oracle PL/SQL Best Practices
    Which are?
    9) Review tables and their indexes being used in the SQL queries and avoid unnecessary Table scanning
    You mean design your database and queries properly?  And table scanning is not always bad.
    10) Avoid costly Full Table Scan on Big Transaction tables with Huge data volume,
    It depends if that is necessary or not.
    11) Use appropriate filtration condition on index columns of seeded Oracle tables directly mapped to program parameters
    No, consider that too many indexes can have an impact on overall performance and can prevent the CBO from picking the best plan.  There's far more to creating indexes than just picking every column that people are likely to search on; you have to consider the cardinality and selectivity of data, as well as the volumes of data being searched and the most common search requirements.
    12) Review Join condition on existing query explain plan
    Well, if you don't have your join conditions right then your query won't work, so that's obvious.
    13) Use Oracle hint to guide Oracle Cost based optimizer to choose best plan for your custom queries
    No.  Oracle recommends you do not use hints for query optimization (it says so in the documentation).  Only certain hints such as APPEND etc. which are more related to certain operations such as inserting data etc. are acceptable in general.  Oracle recommends you use the query optimization tools to help optimize your queries rather than use hints.
    14) Avoid applying SQL functions on index columns
    Why?  If there's a need for a function based index, then it should be used.
    15) Use appropriate hint to guide Oracle CBO to choose best plan to reduce response time
    See 13.
    In short, there are no silver bullets for dealing with performance.  Each situation is different and needs to be evaluated on its own merits.

  • SQL to SQL Append

    Hi,
    I have a interface to load data from tables to table into same Oracle server, the target table is truncate every time that run interface and the data is just insert (don't update), i read that can use "IKM SQL to SQL Append" to avoid extra loading phases ( like flow tables, create index, etc. ). I put source table and datastore table from the same model, select "Staging Area Diferent from Target" and select the apropiate staging. The problem is that i can select the "IKM SQL to SQL Append" in the flow tab.
    Please can you help me with that ? i need this option to improve performance and space, every time that this interfaces run load aprox. 3 million of registers about 9 times with diferent conditions.
    Thanks.
    Juan Carlos Lopez
    Startegic Account Sales Consultant
    Oracle Venezuela

    Hola Juan, que tal estas?
    Eso es muy sencillo....
    Just import (or use if it is already imported) the KM Control Append and change the option "Flow Control" to No.
    Plus, let the Staging Area together at Target.
    I believe that will solve your problem because will generate just one step to load the data...
    If you have big problems on this, is very simple to change a KM....
    Un Saludo!
    Cezar Santos

  • XML parsing with SQL/PL-SQL

    Hi,
    My question is about how can an XML message can be best parsed using SQL/PL-SQL.
    The scenario is as follow. The XML message is stored in a CLOB; only some of its data needs to be extracted; there are six different types of structures of XML; the size of each XML is about 50 lines (maximum depth level is 3); the data could be written in English or Greek or French or German or Russian; this is going to be done every hour and the parsing is going to be against 3,000 records approx.
    In the development, I need to take into consideration performance. We are using Oracle 10, but we could migrate to Oracle 11 if necessary.
    Apologies for this basic question but I have never done XML parsing in SQL/PL-SQL before.
    Thank you.
    PS I have copied this question to the XML forum.
    Edited by: user3112983 on May 19, 2010 3:30 PM
    Edited by: user3112983 on May 19, 2010 3:39 PM

    user3112983 wrote:
    The scenario is as follow. The XML message is stored in a CLOB; only some of its data needs to be extracted; there are six different types of structures of XML; the size of each XML is about 50 lines (maximum depth level is 3); the data could be written in English or Greek or French or German or Russian; this is going to be done every hour and the parsing is going to be against 3,000 records approx.Parsing is done using the XMLTYPE data type (object class) in Oracle.
    Something as follows:
    SQL> create table xml_doc( id number, doc clob );
    Table created.
    SQL>
    SQL> insert into xml_doc values( 1, '<root><row><name>John</name></row><row><name>Jack</name></row></root>' );
    1 row created.
    SQL> commit;
    Commit complete.
    SQL>
    SQL> declare
      2          rawXml  xml_doc.doc%type;
      3          xml     xmltype;
      4  begin
      5          -- get the raw XML (as a CLOB)
      6          select doc into rawXml from xml_doc where id = 1;
      7
      8          -- parse it
      9          xml := new xmltype( rawXml );  
    10         -- process the XML...
    11  end;
    12  /
    PL/SQL procedure successfully completed.
    SQL>The variable xml in the sample code is the XML DOM object. XML functions can be used against it (e.g. to extract values in a tabular row and column structure).
    Note that the CLOB needs to contain a valid XML. An XML containing XML fragments is not valid and cannot be parsed. E.g.
    SQL> declare
      2          xml     xmltype;
      3  begin
      4          -- attemp to parse fragments
      5          xml := new xmltype( '<row><name>John</name></row>  <data><column>Name</column></data>' );
      6  end;
      7  /
    declare
    ERROR at line 1:
    ORA-31011: XML parsing failed
    ORA-19202: Error occurred in XML processing
    LPX-00245: extra data after end of document
    Error at line 1
    ORA-06512: at "SYS.XMLTYPE", line 301
    ORA-06512: at line 5This XML contains 2 fragments. A row structure and a data structure. It is not a valid XML and as such cannot be parsed. If a root tag is used to encapsulate these 2 fragments, then it will be a valid XML structure.
    In the development, I need to take into consideration performance. We are using Oracle 10, but we could migrate to Oracle 11 if necessary.Have not run into any XML performance problems specifically - and am using it extensively. Even large XMLs (10's of 1000's of elements) parse pretty fast.

  • Dilemma of an OCA (SQL, PL/SQL) with 4 years work-ex

    Dear all,
    I am an OCA(SQL, PL/SQL) and working on a enhancement/production support project (Tech: JAVA and Oracle, Func: Insurance) in my firm. I am doing quite well here and keep updating myself using oracle documentation and application functionality. But in a long term, I am confused about my career path, what should I do next? Should I upgrade myself with certification in advanced PL/SQL or should I move towards DBA activities or should I learn JAVA to be an software architect?
    Personally, I have great interest in oracle database, design and implementation, what can be a career path for a software architect?
    Please help.

    OracleDeft wrote:
    Dear all,
    I am an OCA(SQL, PL/SQL) and working on a enhancement/production support project (Tech: JAVA and Oracle, Func: Insurance) in my firm. I am doing quite well here and keep updating myself using oracle documentation and application functionality. But in a long term, I am confused about my career path, what should I do next? Should I upgrade myself with certification in advanced PL/SQL or should I move towards DBA activities or should I learn JAVA to be an software architect?
    Personally, I have great interest in oracle database, design and implementation, what can be a career path for a software architect?
    Please help.Bringing you PL/SQL up to OCP by studying for and taking 1z0-146 is probably a straightford and low impact descision.
    It may not however be in the route you wish to take your career, but it is relatively low cost and good gain.
    My impression is your not currently into Java ... learning that from the bottom may be a hard process and even having learn Java than in itself does not make one a software architect.
    Take a browse down all Oracle Certifications at [http://www.oracle.com/education/certification] ... certifications ... view all certifications ... but remember not all Oracle products / technologies have associated certifications.
    Consider SOA or BIEE or Oracle Application Express as well
    -

  • Convert Oracle SQL line to SQL Server SQL

    Hi All,
    I'm trying to convert this Oracle SQL to SQL that will work with SQL Server 2008 and am having some trouble with the MOD function. Anyone have any SQL Server chops?
    Oracle SQL
    TBL_MAIN.AuthoredDate- MOD (TBL_MAIN.AuthoredDate - to_date ('2012-01-01', 'fxYYYY-MM-DD'), 7) + 6 AS "Week Ending"
    SQL Server Code
    TBL_MAIN.AuthoredDate - ((Cast(TBL_MAIN.AuthoredDate as DATE) % CAST('2012-01-01' AS DATE)), 7) + 6 AS "Week Ending" Thanks,
    John
    Edited by: Johnbr (Oracle10G) on Mar 1, 2013 8:41 AM

    ahhh.. I just had to change my thinking... I got it now:
    SQL Server SQL
    DATEADD(dd, 7-(DATEPART(dw, TBL_MAIN.AuthoredDate)), TBL_MAIN.AuthoredDate) AS 'Week Ending'

Maybe you are looking for

  • My profile

    Good evening my dear , i can't enter to my profile in BBM  i don't why! and also some times my BBM is not working. pleace help me ! thanks

  • How to publish to video format avi , wmv , mov or mpg ?

    How to publish to video format avi , wmv , mov or mpg ?

  • Help un-installing and reinstalling iTunes on a PC

    I cannot access itunes in thefirst place, it says I have to re-install it. When I try and do that, it of course attemts to uninstall the previous version itunes I have installed. When I try to uninstall it, a diologue box pops up saying, "The feature

  • Agent reserved state

    Hello. Is available CUCM 4.3(2)sr1b and UCCX Enhanced 6.0(1)sr01. Periodically (1-3 times a day) agents pass to  reserved state and can be in reserved state different time. Forum messages on a theme are seen, but the problem remains. I give an exampl

  • Installer Build Error using LV Runtime Engine 2010

    I had an executable and installer working that were built in LV2009.  Since then I modified my source code and saved as LV version 2010.  I rebuilt the executable, but when I tried to run it on the target computer, I got an error message saying that