Create table using a dynamic SQL returns error.

DBMS_UTILITY.exec_ddl_statement (
'create table test_table as select column_names from table_name@dblink
where condition' )
i am using the above statement in a pl/sql procedure.
It throws an error saying
"Exact fetch returns more than requested no. of rows"
can any one help me on this please!!!
Very Urgent
Thanks in Advance.
Bala.

Works for me. But the more important question would be the need to have this run within PL/SQL? Why do you want to do that? what is the requirement? can you not do this one time at SQL*Plus prompt and be done with it?
SQL> drop table emp ;
Table dropped.
SQL>
SQL>
SQL> exec dbms_utility.exec_ddl_statement('create table emp as select * from [email protected] where deptno = 10') ;
PL/SQL procedure successfully completed.
SQL> select count(*) from emp ;
  COUNT(*)
         3
1 row selected.
SQL> select count(*) from [email protected] ;
  COUNT(*)
        14
1 row selected.
SQL> select count(*) from [email protected] where deptno = 10 ;
  COUNT(*)
         3
1 row selected.
SQL>Message was edited by:
Kamal Kishore

Similar Messages

  • Create table statement in Dynamic SQL

    Hello,
    I am trying to create a table as a select query through a PL/SQL block using dynamic SQL. Following is the query,
    declare
    stmt varchar2(2000);
    begin
    stmt := '''CREATE TABLE output AS SELECT PATIENT_ID, FIRST_NAME FROM employee''';
    execute immediate stmt;
    end;
    it throws the following error.
    declare
    ERROR at line 1:
    ORA-00900: invalid SQL statement
    ORA-06512: at line 5
    I have tried to execute the statement without the variable and it executes fine. I mean,
    begin
    execute immediate ' CREATE TABLE output AS SELECT PATIENT_ID, FIRST_NAME FROM employee ';
    end;
    works flawlessly. Can you please help me with this.
    Thanks

    Hi,
    declare
    stmt varchar2(2000);
    begin
    stmt := 'CREATE TABLE output AS SELECT PATIENT_ID, FIRST_NAME FROM employee';
    execute immediate stmt;
    end;Nothing different from what Anurag has shown above.
    But you will have to consider a few things.
    1) Since it is possible it is not a must to use it
    2) It is considered a bad design where in you have to create tables on the fly.
    3) Consider if it is absolutely required.If u can give us an idea of your requirement.I am sure the Gurus here can give you suggestions
    4) this kind of design will lead you into trouble sooner or later for sure
    Regards,
    Bhushan

  • Logical error in creating tables using db link in solaris

    Hi,
    While creating table using the syntax create table newtab...as select * from tab@dblink .. I am facing a problem. The newtab table created is having a structure different (from datalength point of view of varchar2 and char datatypes) from the source. The data length is getting tripled i.e. if a column a is varchar2(20) in tab then it is becoming --- a varchar2(60) in newtab. This is happening in solaris environment when the two databases are in 2 different servers. Please let me know if there are any patches to resolve the problem.
    Thanks
    Arnab

    ORA-02019: connection description for remote database not foundHave you used this database link successfully for some other queries?
    The error posted seems to indicate that the DB Link is not functional at all. Has it worked for any other type of DML operation or is this the first time you ever tried to use the link?

  • Workaround for opening a strongly typed cursor using native dynamic SQL

    Hi All,
    In reading the PL/SQL documentation for Oracle 9i, I noted that the OPEN-FOR
    statement with a dynamic SQL string only allows the use of weakly typed cursors.
    I have verified this limitation with my own experimentation as follows:
    DECLARE
    type rec_type is record(
    str     varchar2(40),
    num     number(22)
    type cur_type is ref cursor return rec_type;
    my_cur     cur_type;
    que     varchar2(100);
    tab     varchar2(40);
    BEGIN
    tab := 'dynamic_table_name';
    que := 'select key_name, key_value from ' || tab || ' where key_name like ''01%''';
    open my_cur for que;
    loop
    if my_cur%found then
    dbms_output.put_line('source_name: ' || my_cur.str || ', page_sn: ' || my_cur.num);
    exit;
    end if;
    end loop;
    close my_cur;
    END;
    Running the above trivial example in an anonymous sql block yields the following
    errors as expected:
    ORA-06550: line 10, column 8:
    PLS-00455: cursor 'MY_CUR' cannot be used in dynamic SQL OPEN statement
    ORA-06550: line 10, column 3:
    PL/SQL: Statement ignored
    ORA-06550: line 13, column 54:
    PLS-00487: Invalid reference to variable 'MY_CUR'
    ORA-06550: line 13, column 7:
    PL/SQL: Statement ignored
    Is there a workaround to the situation? Since I do not know the table name at run
    time, I must use Native Dynamic SQL. I have a long and complex record type
    that I wish to return through JDBC using the REFCURSOR Oracle type in order to
    avoid having to register an inordinate number of OUT parameters. Moreover, I
    would like to return potentially one or more results in a ResultSet. Using the
    standard method of registering native SQL types for the IN and OUT bindings
    can only return one result. Hence the reason I would like to return a strong
    cursor type. Also, the type of query I am doing is complex, and needs to be
    executed in a PL/SQL procedure for performance reasons. Therefore simply
    executing a SELECT query dynamically built up on the the JDBC client won't
    do the trick.
    If anybody has experience with a similar problem and would like to volunteer
    information on their workaround, I would really appreciate it.
    Best Regards,
    J. Metcalf

    We can use strongly-typed REF CURSORs in DNS, but the typing derives from a table e.g.
    TYPE EmpCurTyp IS REF CURSOR RETURN emp%ROWTYPE;
    so the problem is your use of "return rec_type" bit.
    Forgive my bluntness but I think you have misunderstood strong and weak typing. You actually want to be using weakly-typed cursors. I mean this:
    Moreover, I would like to return potentially one or more results in a ResultSet. suggests that the structure of your resultset may vary, which is precisely what a weakly-typed ref cursor allows us to do. Then we can use the JDBC metadata methods to interrogate the structure of the resultset, innit.
    so try this:
    DECLARE
    type cur_type is ref cursor;
    my_cur cur_type;
    que varchar2(100);
    tab varchar2(40);
    BEGIN
    tab := 'dynamic_table_name';
    que := 'select key_name, key_value from ' || tab || ' where key_name like ''01%''';
    open my_cur for que;
    loop
    if my_cur%found then
    dbms_output.put_line('source_name: ' || my_cur.str || ', page_sn: ' || my_cur.num);
    exit;
    end if;
    end loop;
    close my_cur;
    END;
    ras malai, APC
    Cheers, APC

  • PLS-00455: cursor 'CUR_1' cannot be used in dynamic SQL OPEN statement

    create or replace function f_my_test_func
    return refcur_pkg.refcur_t1
    is
    cur_1  refcur_pkg.refcur_t1;
    begin
    open cur_1
    for
    'select * from dept';
    return cur_1;
    exception
    when others
    then
    insert into ddl_log (SQLTEXT)
    values
    ('fucntion error'); 
    end;

    I would suggest that cur_1 refcur_pkg.refcur_t1 is a stongly typed ref cursor i.e. it has RETURN dept%ROWTYPE or something similar in the declaration. You can't use strongly typed ref cursors with dynamic SQL in this way. The declaration should be weakly typed or just use sys_refcursor.
    DTYLER_APP@pssdev2> DECLARE
      2
      3      TYPE t_Strong   IS REF CURSOR RETURN dual%ROWTYPE;
      4
      5      lc_Strong       t_Strong;
      6
      7  BEGIN
      8
      9      OPEN lc_Strong FOR
    10      'SELECT * FROM dual';
    11
    12  END;
    13  /
        OPEN lc_Strong FOR
    ERROR at line 9:
    ORA-06550: line 9, column 10:
    PLS-00455: cursor 'LC_STRONG' cannot be used in dynamic SQL OPEN statement
    ORA-06550: line 9, column 5:
    PL/SQL: Statement ignored
    DTYLER_APP@pssdev2>
    DTYLER_APP@pssdev2> DECLARE
      2
      3      TYPE t_Weak   IS REF CURSOR;
      4
      5      lc_Weak       t_Weak;
      6
      7  BEGIN
      8
      9      OPEN lc_Weak FOR
    10      'SELECT * FROM dual';
    11
    12  END;
    13  /
    PL/SQL procedure successfully completed.
    DTYLER_APP@pssdev2> DECLARE
      2
      3      lc_Weak       sys_refcursor;
      4
      5  BEGIN
      6
      7      OPEN lc_Weak FOR
      8      'SELECT * FROM dual';
      9
    10  END;
    11  /
    PL/SQL procedure successfully completed.
    DTYLER_APP@pssdev2>HTH
    David

  • How to create table using Procedure

    Hi,
    I want to create table using procedure .
    How to write procedure for the table creation?
    thanks in advance.

    Use dynamic sql or DBMS_UTILITY.EXEC_DDL_STATEMENT:
    SQL> desc tbl1
    ERROR:
    ORA-04043: object tbl1 does not exist
    SQL> begin
      2      execute immediate 'create table tbl1(x number)';
      3  end;
      4  /
    PL/SQL procedure successfully completed.
    SQL> desc tbl1
    Name                                      Null?    Type
    X                                                  NUMBER
    SQL> drop table tbl1
      2  /
    Table dropped.
    SQL> begin
      2      DBMS_UTILITY.EXEC_DDL_STATEMENT('create table tbl1(x number)');
      3  end;
      4  /
    PL/SQL procedure successfully completed.
    SQL> desc tbl1
    Name                                      Null?    Type
    X                                                  NUMBER
    SQL>  SY.

  • Create Tables using sql.

    Hi Dear;
    can i create tables from SQL enterprise manager and not from SAP-BO without having problem in the upgrade?
    thank you Dear.

    Hi Adele,
    I never heard that there is any issue with additional / custom tables in a B1 <b>company</b> database.
    For certification there is no issue with that - except that you must use your SAP namespace also for these tables.
    For your reference I add here the current links to the page about Solution Certification (B1-SDK) + the Test Plan - which lists all requirements:
    B1-SDK: SAP BUSINESS ONE ADD-ON SOLUTION CERTIFICATION  (B1-SDK) [original link is broken]
    Test Plan: https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/81a22ee1-0701-0010-45aa-ec852e882de3
    Regards,
    Frank
    Message was edited by: Frank Moebius
    PS: Adding tables to SBO-Common is a different game though since it is not expected that a partner adds tables there and <u>eventually</u> additional tables there might get removed during upgrades.
    If you have a need for additional data storage across all companies, please create a dedicated database for that purpose.

  • How to create a function with dynamic sql or any better way to achieve this?

            Hello,
            I have created below SQL query which works fine however when scalar function created ,it
            throws an error "Only functions and extended stored procedures can be executed from within a
            function.". In below code First cursor reads all client database names and second cursor
            reads client locations.
                      DECLARE @clientLocation nvarchar(100),@locationClientPath nvarchar(Max);
                      DECLARE @ItemID int;
                      SET @locationClientPath = char(0);
                      SET @ItemID = 67480;
       --building dynamic sql to replace database name at runtime
             DECLARE @strSQL nvarchar(Max);
             DECLARE @DatabaseName nvarchar(100);
             DECLARE @localClientPath nvarchar(MAX) ;
                      Declare databaselist_cursor Cursor for select [DBName] from [DataBase].[dbo].
                      [tblOrganization] 
                      OPEN databaselist_cursor
                      FETCH NEXT FROM databaselist_cursor INTO @DatabaseName
                      WHILE @@FETCH_STATUS = 0
                      BEGIN       
       PRINT 'Processing DATABASE: ' + @DatabaseName;
        SET @strSQL = 'DECLARE organizationlist_cursor CURSOR
        FOR SELECT '+ @DatabaseName +'.[dbo].[usGetLocationPathByRID]
                                   ([LocationRID]) 
        FROM '+ @DatabaseName +'.[dbo].[tblItemLocationDetailOrg] where
                                   ItemId = '+ cast(@ItemID as nvarchar(20))  ;
         EXEC sp_executesql @strSQL;
        -- Open the cursor
        OPEN organizationlist_cursor
        SET @localClientPath = '';
        -- go through each Location path and return the 
         FETCH NEXT FROM organizationlist_cursor into @clientLocation
         WHILE @@FETCH_STATUS = 0
          BEGIN
           SELECT @localClientPath =  @clientLocation; 
           SELECT @locationClientPath =
    @locationClientPath + @clientLocation + ','
           FETCH NEXT FROM organizationlist_cursor INTO
    @clientLocation
          END
           PRINT 'current databse client location'+  @localClientPath;
         -- Close the Cursor
         CLOSE organizationlist_cursor;
         DEALLOCATE organizationlist_cursor;
         FETCH NEXT FROM databaselist_cursor INTO @DatabaseName
                    END
                    CLOSE databaselist_cursor;
                    DEALLOCATE databaselist_cursor;
                    -- Trim the last comma from the string
                   SELECT @locationClientPath = SUBSTRING(@locationClientPath,1,LEN(@locationClientPath)-  1);
                     PRINT @locationClientPath;
            I would like to create above query in function so that return value would be used in 
            another query select statement and I am using SQL 2005.
            I would like to know if there is a way to make this work as a function or any better way
            to  achieve this?
            Thanks,

    This very simple: We cannot use dynamic SQL from used-defined functions written in T-SQL. This is because you are not permitted do anything in a UDF that could change the database state (as the UDF may be invoked as part of a query). Since you can
    do anything from dynamic SQL, including updates, it is obvious why dynamic SQL is not permitted as per the microsoft..
    In SQL 2005 and later, we could implement your function as a CLR function. Recall that all data access from the CLR is dynamic SQL. (here you are safe-guarded, so that if you perform an update operation from your function, you will get caught.) A word of warning
    though: data access from scalar UDFs can often give performance problems and its not recommended too..
    Raju Rasagounder Sr MSSQL DBA
          Hi Raju,
           Can you help me writing CLR for my above function? I am newbie to SQL CLR programming.
           Thanks in advance!
           Satya
              

  • Create Table using DBMS_SQL package and size not exceeding 64K

    I have a size contraint that my SQL size should not exceed 64K.
    Now I would appriciate if some one could tell me how to create a table using
    Dynamic sql along with usage of DBMS_SQL package.
    Brief Scenario: Users at my site are not given permission to create table.
    I need to write a procedure which the users could use to create a table .ALso my SQL size should not exceed 64K. Once this Procedure is created using DBMS_SQL package ,user should pass the table name to create a table.
    Thanks/

    "If a user doesn't have permission to create a table then how do you expect they will be able to do this"
    Well, it depends on what you want to do. I could write a stored proc that creates a table in my schema and give some other user execute privilege on it. They would then be able to create a able in my schema without any explicitly granted create table privilege.
    Similarly, assuming I have CREATE ANY TABLE granted directly to me, I could write a stroe proc that would create a table in another users schema. As long as they have quota on their default tablespace, they do not need CREATE TABLE privileges.
    SQL> CREATE USER a IDENTIFIED BY a
      2  DEFAULT TABLESPACE users TEMPORARY TABLESPACE temp;
    User created.
    SQL> GRANT CREATE SESSION TO a;
    Grant succeeded.
    SQL> CREATE TABLE a.t (id NUMBER, descr VARCHAR2(10));
    CREATE TABLE a.t (id NUMBER, descr VARCHAR2(10))
    ERROR at line 1:
    ORA-01950: no privileges on tablespace 'USERS'So, give them quota on the tablespace and try again
    SQL> ALTER USER a QUOTA UNLIMITED ON users;
    User altered.
    SQL> CREATE TABLE a.t (id NUMBER, descr VARCHAR2(10));
    Table created.Now lets see if it really belongs to a:
    SQL> connect a/a
    Connected.
    SQL> SELECT table_name FROM user_tables;
    TABLE_NAME
    T
    SQL> INSERT INTO t VALUES (1, 'One');
    1 row created.Yes, it definitely belongs to a. Just to show that ther is nothing up my sleeve:
    SQL> create table t1 (id NUMBER, descr VARCHAR2(10));
    create table t1 (id NUMBER, descr VARCHAR2(10))
    ERROR at line 1:
    ORA-01031: insufficient privilegesI can almost, but not quite, see a rationale for the second case if you want to enforce some sort of naming or location standards but the whole thing seems odd to me.
    Users cannot create tables, so lets give them a procedure to create tables?
    John

  • Dynamic sql giving error --please help

    Hi ,
    I have written the following code --
    CREATE OR REPLACE FUNCTION tabcount (
    tab IN VARCHAR2, field IN VARCHAR2 ,whr IN VARCHAR2)
    RETURN INTEGER
    IS
    retval INTEGER;
    BEGIN
    DBMS_OUTPUT.PUT_LINE ('whr' ||whr);
    DBMS_OUTPUT.PUT_LINE ('field1' ||field);
    EXECUTE IMMEDIATE
    ' SELECT COUNT(*) FROM ' || tab ||
    ' WHERE ' || field || 'like '/'%'||whr ||'%'/''
    INTO retval;
    DBMS_OUTPUT.PUT_LINE ('countis!' ||retVal);
    RETURN retval;
    END tabcount;
    It is giving the following error--
    ORA-00920: invalid relational operator
    ORA-06512: at "TABCOUNT", line 10
    ORA-06512: at line 2
    I am not sure how to enclose the like operator within the single quotes.Double quotes is not working for me.
    Thanx in advance,
    Ira

    Offhand, it looks like you may still have some syntax problems -- probably need a blank space before the WHERE --maybe some other stuff too.
    What you need to do to debug it is this (and this works just about anytime you are having trouble with dynamic SQL):
    1. store the sql statement in a variable.
    2. Use DBMS_OUTPUT to display your select statement BEFORE calling execute immediate.
    3. copy/paste that select into a separate window and run/debug it.
    4. Once you know what is wrong with that statement, go back and fix the code accordingly.
    Have fun,
    --scott                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Using Native Dynamic SQL in Forms

    Can Native Dynamic SQL be used in Forms 5.0 or Forms 6.0? (Database 8.1.6.0.0)
    I have tried the following code (examples below) from the PL/SQL User's Guide and Reference Release 8.1.6 and the Metalinks Note: 62592.1 and the trigger/procedure (in Forms) will not compile. I appreciate any help given.
    Example1:
    (I have a table named temp_jane with a column named companies and a value 'Hello'. When compiling, I receive the error: 'Error 103 at line 8, column 11 Encountered the symbol ''IMMEDIATE" when expecting one of the following :=.(@%; ')
    declare
    str varchar2( 200 );
    val varchar2( 20 );
    ret temp_jane%rowtype;
    begin
    str := 'select company from temp_jane where company = :b1';
    val := 'Hello';
    execute immediate str into ret using val;
    message('Value fetched from table: '&#0124; &#0124;ret.company);
    end;
    Example2:
    (Here is the real issue, I don't know what the select statement, so I need to be able to assign a variable. When compiling, I receive the error: 'Error 103 at line 28, column 21 Encountered the symbol "VSQLSTATEMENT" when expecting one of the following: select ').
    declare
    type ItemsControlCurTyp is ref cursor;
    ItemsCur ItemsControlCurTyp;
    ItemsRec Items%rowtype;
    vSQLStatement varchar2( 5000 );
    vExecuteSQL varchar2( 5000 );
    vNumRows integer;
    vValue varchar2( 2000 );
    vFirstOne varchar2( 1 ) := 'Y';
    vRetval varchar2( 2000 );
    begin
    -- Display the column prompts with the right text.
    set_item_property( 'ITEMS_AVAILABLE.NDB_VALUE', PROMPT_TEXT, :ITEMS_CONTROL.AVAILABLE_LABEL );
    set_item_property( 'ITEMS_CHOSEN.NDB_VALUE', PROMPT_TEXT, :ITEMS_CONTROL.CHOSEN_LABEL );
    -- Save the original version of CHOSEN_STRING in case the user reverts or cancels.
    :ITEMS_CONTROL.CHOSEN_STRING_ORIG := :ITEMS_CONTROL.CHOSEN_STRING;
    vSQLStatement := :ITEMS_CONTROL.SELECT_STATEMENT;
    vExecuteSQL := vSQLStatement;
    -- Open the cursor
    open ItemsCur for vSQLStatement;

    Hi JTaylor
    You cannot use NDS in Client side (Developer). You have to use DBMS_SQL only.
    Regards
    A K Srinivasan
    Oracle.

  • Can't create table - using JDeveloper 11g (11.1.1.3.0)

    I am running a DDL to create a table:
    CREATE TABLE HORSE
    HORSE_NAME VARCHAR2(30) NOT NULL
    , PLACE VARCHAR2(20)
    , RACE_NAME VARCHAR2(30)
    , RACE_DATE DATE
    , CONSTRAINT HORSE_PK PRIMARY KEY
    HORSE_NAME
    ENABLE
    The message I get is:
    Error at Command Line:48 Column:13
    Error report:
    SQL Error: ORA-02264: name already used by an existing constraint
    02264. 00000 - "name already used by an existing constraint"
    *Cause:    The specified constraint name has to be unique.
    *Action:   Specify a unique constraint name for the constraint.
    This suggests to me that I should change the name to something else, like HORSE_ID. Whilst I don't agree that HORSE_NAME is used in another constraint I have changed the name but it doesn't make a scrap of difference.
    There is another parallel table called HORSES (plural) but but other examples ( eg PUNTER/PUNTERS) have been happily created.
    I would be grateful for any suggestions.
    Thanks,
    Jim

    The message is not specifically about the HORSE_NAME - it is more likely about the table name.
    You probably already have another database object called Horse (maybe not a table but it could be a view or a procedure).
    Try a different name for the table.

  • Trying to create table using Union All Clause with multiple Select stmts

    The purpose of the query is to get the Substring from the value for eg.
    if the value is *2 ASA* then it should come as ASA
    where as if the value is *1.5 TST* the it sholud come as TST like wise for others too.
    I am trying to execute the below written SQL stmt but getting error as:
    *"ORA-00998 must name this expression with the column alias 00998.00000 - Must name this expression with the column alias"*
    CREATE TABLE TEST_CARE AS
    SELECT row_id, old_care_lvl,SUBSTR(old_care_lvl,3), len FROM test_care_lvl
    WHERE LENGTH(old_care_lvl) =5
    UNION ALL
    SELECT row_id, old_care_lvl,SUBSTR(old_care_lvl,3), len FROM test_care_lvl
    WHERE LENGTH(old_care_lvl) =7
    UNION ALL
    SELECT row_id, old_care_lvl,SUBSTR(old_care_lvl,3), len FROM test_care_lvl
    WHERE LENGTH(old_care_lvl) =14
    UNION ALL
    SELECT row_id, old_care_lvl,SUBSTR(old_care_lvl,3),LEN FROM test_care_lvl
    WHERE LENGTH(old_care_lvl) =7 AND old_care_lvl ='Regular'
    I want to create the table using the above given multiple select using the Union ALL clause but when trying to create run the query getting error as "ORA-00998 must name this expression with the column alias 00998.00000 - Must name this expression with the column alias"
    Please guide me how to approach to resolve this problem.
    Thanks in advance.

    When you create a table using a SELECT statement the column names are derived from the SELECT list.
    Your problem is that one of your columns is an expression that does not work as a column name SUBSTR(old_care_lvl,3)What you need to do is alias this expression and the CREATE will pick up the alias as the column name, like this:
    CREATE TABLE TEST_CARE AS
    SELECT row_id, old_care_lvl,SUBSTR(old_care_lvl,3) column3, len FROM test_care_lvl
    WHERE LENGTH(old_care_lvl) =5
    UNION ALL
    SELECT row_id, old_care_lvl,SUBSTR(old_care_lvl,3), len FROM test_care_lvl
    WHERE LENGTH(old_care_lvl) =7
    UNION ALL
    SELECT row_id, old_care_lvl,SUBSTR(old_care_lvl,3), len FROM test_care_lvl
    WHERE LENGTH(old_care_lvl) =14
    UNION ALL
    SELECT row_id, old_care_lvl,SUBSTR(old_care_lvl,3),LEN FROM test_care_lvl
    WHERE LENGTH(old_care_lvl) =7 AND old_care_lvl ='Regular'
    );You may not like the name "column3" so use something appropriate.

  • Creating Views using XSU PL/SQL API.Urgent please.

    Folks,
    I need some help in creating a View.
    I am using XSU PL/SQL to generate an XML Document.
    I have a table (SDI) with 2 cols CMPY_NUM and CPTY_BORG_NUM.
    If the values in these 2 cols are equal then the xml
    value to be returned is 'OURS' else return 'THEIRS'.
    How do I Create this View please?
    The XSU PL/SQL I am using to generate the XML is:
    declare
    queryCtx DBMS_XMLquery.ctxType;
    xmlResult CLOB;
    begin
    queryCtx := DBMS_XMLQuery.newContext('select CMPY_NUM,CPTY_BORG_NUM from SDI');
    xmlResult := DBMS_XMLQuery.getXML(queryCtx);
    DBMS_XMLQuery.closeContext(queryCtx); -- you must close the query handle..
    end;
    Output
    <?xml version='1.0'?>
    <ROWSET>
         <ROW num="1">
         <CMPY_NUM>1</CMPY_NUM>
    <CPTY_BORG_NUM>2/CPTY_BORG_NUM>
         </ROW>
    <!-- additional rows ... -->
    </ROWSET>
    Please can any one tell me how to create a view that will be used in place
    of the select statement,and returns back OURS or THEIRS
    Create View XML AS

    This is a duplicate of this posting Creating a View to check for 2 conditions.. This is a particularly heinous case because some of our finest minds have already responded in that thread.
    Lose ten culture points.
    Regards, APC

  • While creating Projects Using the API, get two errors: 'Customer name must be passed' and 'class category is invalid'

    Hi
    While trying to Create Projects using the API, I'm getting two types of errors -
    The first is : 'API failed in one stage 1 Customer Name is a mandatory Quick Entry field. Value must be passed'
    The second is : '
    'API failed in one stage 1 Project: '<Project_Number>'
    The class category is invalid.'
    Both the messages are produced by our custom program. .. however I am not able to understand why the underlying errors occur.
    The first error ( Customer Name is a mandatory quick entry field), is caused by Projects that are to be created from Project templates where it is configured with Quick Entry Customer Name required. We are passing Customer Site number ( Party Bill to site number and Party Ship to side number). The site numbers being passed are also set as 'Primary'. Yet they are failing.
    For the second Error ( The Class Category is invalid), I rechecked multiple times, the Class categories for the Projects I am trying to create, with the Config in R12 and they are fine. Can't understand the reason for these two issues. Has anyone encountered such an issue ? If so how was it resolved?
    Regards
    Vivek

    HI All
    I resolved both the issues. In case there are others facing similar issues, following was the cause and resolution of my errors
    1. Error 1: Customer Name is a Mandatory Quick Entry field. Value must be passed.
    The cause was that the data loaded into our custom staging table was not in the right fields. This was because the data file values and the CTL were not in sync.
    Resolution:
    Corrected the data file to be in Sync with the structure defined in the CTL and  this loaded it successfully
    2. Error 2: The class category is invalid.
    The cause of this error was that  in the  Projects Template (used to create the project from), the Quick Entry setup had a Class Category set as required and I was not passing a value ( a class code value) for that Class Category.
    Hope this helps somebody else
    Cheers
    Turnbill

Maybe you are looking for

  • Error While Provisioning User from OIM to OID

    This is the Error I'm getting While Creating a user and provisioning. DOBJ.THROWABLE_IN_SAVE Unhandled throwable java.lang.NoClassDefFoundError in com.thortech.xl.dataobj.tcScheduleItem's save This error happens when i try to provision the user with

  • RFC to JDBC to RFC sync

    Hi all, Anyone have any link for RFC to JDBC to RFC sync scenario step by step? (For reverse one means JDBC to RFC to JDBC used RRBEANS configuration in sender jdbc channel and created one receiver JDBC channel.) What should I do for the same? Any su

  • Why is the time bar in Calendar not corrected for DST?

    My iPad has corrected its clock for DST, but the time bar in Calendar is still an hour out. Any ideas?

  • TS1702 i have no sound on game apps what should i do to get it back?

    while playing a game a pop up said no sound with a X and a circle around it. After that i had no sound on my tap apps???

  • Performance issue: extractor:

    Hi, I have an issue with the performnace of the extractor: Extractor is a generic one with FM in its definition The reason i found was logic in the FM: the select statement was extracting the fields from View and one more table with join statement: l