Execute DBMS_STATS in PL/SQL and get ORA-00933

Hi all.
Im trying to execute the following procedure:
as
v_inicio_gather date;
v_fin_gather date;
v_inicio_delete date;
v_fin_delete date;
v_error varchar2(100);
sql_stmt varchar2(100);
begin
select sysdate into v_inicio_gather from dual;
DBMS_STATS.GATHER_DATABASE_STATS(ESTIMATE_PERCENT=>DBMS_STATS.AUTO_SAMPLE_SIZE,DEGREE=>1,GRANULARITY=>'ALL',CASCADE=>TRUE);
select sysdate into v_fin_gather from dual;
v_error := 'OK';
sql_stmt := 'insert into estadisticas_log values (:1, :2, :3, :4, :5)';
execute immediate sql_stmt using v_inicio_gather,v_fin_gather,v_inicio_delete,v_fin_delete, v_error;
commit;
exception
when others then
v_error := 'Codigo de error '|| sqlcode || ': ' || sqlerrm;
sql_stmt := 'insert into estadisticas_log values (:1, :2, :3, :4, :5)';
execute immediate sql_stmt using v_inicio_gather,v_fin_gather,v_inicio_delete,v_fin_delete, v_error;
commit;
end;
I get the error ORA 933 "SQL command not properly ended"
If I comment the dbms_stats call doesn't return error. Is it correctly called?
I'm using oracle 9.2.0.4.
Thanks in advance.

Sorry, but I don't understand you.
I declared my variables varchar2(100) and you say that they could be a bit small and after that why don't declare them as varchar2(2000). I don't have much idea of Oracle, but I think 100 is smaller than 2000 ;).
Could you be more specific?
Thank you.
Also your variables sizes could be a bit small. Why
not declare them as varchar2(2000) or better
I don't see the need to do use dynamic sql.
What was wrong with:
insert into estadisticas_log values
(v_inicio_gather,v_fin_gather,v_inicio_delete,v_fin_de
lete, v_error);
EXCEPTION
insert into estadisticas_log values
(v_inicio_gather,v_fin_gather,v_inicio_delete,v_fin_d
lete, v_error);Also your variables sizes could be a bit small. Why
not declare them as varchar2(2000) or better
v_error estadisticas_log.error%type;
sql_stmt estadisticas_log.sql_stmt%type;
Of cause you would need to use the correct column
name.

Similar Messages

  • Why my subqueries all get ORA-00933 when I execute them?

    Everytime I try to run a subquery, I always get the following error:
    [error]
    ORA-00933: SQL command not properly ended
    [error]
    Here are two examples. The 1st is a large one, and the 2nd one is more paired down, because I'm trying to figure out where the error is, but Golden always points to where the subquery begins.
    1st query
    select p1.associate_id, p1.application_id, p1.entity_id, p1.profile_id, p1.language, p1.neutrals, p1.created_date, p1.sf_completed_date,
    p1.completed_time, p1.parent_respondent, p1.parent_aid, p1.attempt, p1.parent_attempt, p1.reported_top1, p1.reported_top2, p1.reported_top3,
    p1.reported_top4, p1.reported_top5, p1.top1, p1.top2, p1.top3, p1.top4, p1.top5
    from sf.profiles p1
    where p1.sf_completed_date < to_date('15-June-2006 00:00:00', 'DD-MM-YYYY HH24:MI:SS')
    and p1.parent_respondent is null
    and p1.parent_aid is null
    and p1.neutrals < 155 in (
    select nvl(max(p2.attempt), 0)
    from sf.profiles p2
    where p2.associate_id = p1.associate_id);2nd query
    select p1.language, pl.neutrals, p1.top1, p1.top2, p1.top3, p1.top4, p1.top5
    from sf.profiles
    where p1.parent_respondent_id is null (
    select nvl(max(p2.attempt), 0)
    from sf.profiles p2
    where p2.associate_id = p1.associate_id);I'm not sure what I'm doing wrong, is there anything that I can read up on to get better at these?
    I found this via Google
    http://www.lc.leidenuniv.nl/awcourse/oracle/server.920/a96540/queries.htm#2057934
    thanks

    It is because neither of your queries are syntactically valid. You cannot combine operators in the way you are trying to do it.
    I'm not sure aht you are trying to accomplish, but the queries need to be more like:
    select p1.associate_id, p1.application_id, p1.entity_id, p1.profile_id,
           p1.language, p1.neutrals, p1.created_date, p1.sf_completed_date,
           p1.completed_time, p1.parent_respondent, p1.parent_aid, p1.attempt,
           p1.parent_attempt, p1.reported_top1, p1.reported_top2, p1.reported_top3,
           p1.reported_top4, p1.reported_top5, p1.top1, p1.top2, p1.top3, p1.top4,
           p1.top5
    from sf.profiles p1
    where p1.sf_completed_date < to_date('15-June-2006 00:00:00', 'DD-MM-YYYY HH24:MI:SS') and
          p1.parent_respondent is null and
          p1.parent_aid is null and
          p1.neutrals < 155 and
          p1.neutrals in(or possibly =) (select nvl(max(p2.attempt), 0)
                          from sf.profiles p2
                          where p2.associate_id = p1.associate_id);
    select p1.language, pl.neutrals, p1.top1, p1.top2, p1.top3, p1.top4, p1.top5
    from sf.profiles
    where p1.parent_respondent_id is null  and
          p1.something IN(or possibly =)(select nvl(max(p2.attempt), 0)
                                         from sf.profiles p2
                                         where p2.associate_id = p1.associate_id);HTH
    John

  • Do I need a sub-query and getting ORA-00937 error

    I'm writing a query where I want returned all data that is in a list 510 and all duplicate entries for the AID are eliminated.
    select *
    from entities e
    where e.list_id in
    (select aid
    from entities e
    where e.list_id = 510
    having count(e.aid) > 1);
    When I run this, I get ORA-00937: not a single-group group function.
    I google the error and see
    http://ora-00937.ora-code.com/
    Which tells me I can't have a group function and individual column expression.
    So I removed the group by, but I still get the errors, and for some reason when I put the alias e for the aid in the subquery, I still get the same error.
    Hopefully this makes sense what I'm asking...
    thanks

    if you want to select rows that eliminate duplicates then you should be using distinct. And if you want to get the duplicate rows then,
    select *
    from entities e1
    where e1.rowid <
    (select max(e2.rowid)
    from entities e2
    where e2.list_id = 510
    and e1.aid = e2.aid);

  • Whats the difference between executing a package from SQL and Visual Studio?

    Hi,
    We have a package that is currently failing to run when deployed to SQL. This has been tried from a schedule and also executed manually both are failing.
    I have tried from Visual studio running on various machines (windows 8, server 2012) and in all cases run perfectly.
    I am trying to understand the differences between deploying to SQL and running from VS so maybe I can figure out why this is happening.
    I have the following errors when I run from SQL.
    DTS_E_PROCESSINPUTFAILED - all errors like this point to the 'Sort' tasks in the script
    dts_e_processinputerror not enough storage is available
    I have tested in four environments and all fail from SQL but not from VS!
    Last night I tried from my laptop and executed the package from SQL - it didn't fail but was still running in the morning so I terminated. Note this takes around 20 mins running from VS! why would it be so quick from VS but fail or take so long on SQL?
    The test running at the moment is on a server with dynamic memory currently at 14GB. I decreased SQLs RAM to 4GB and it hasn't failed yet but has been running for two hours. Before changing this the package failed after a short time.
    I thought it may have something to do with running from a virtual machine but doesn't explain why it couldn't run locally on my laptop.
    All ideas welcome :) Many thanks,
    Davina

    I will try to address issues one by one
    The error doesn't seems to be related to SSISDB configuration mode. It may be because of
    Change in package definition (please confirm that the package which you are running on your laptop is the same on your msdb? - reload your SQL package from MSDB in BIDS/SSDT and recreate your source and destination components)
    As your error message shows, "not enough memory available" (may be because of multicast)  - Usually you can override this error by restarting SQL Server [not an optimal solution but it work & if that work it shows that your package fills
    the memory - Keep an eye on task manager]
    Make sure that your statics on table are updated [run EXEC sp_updatestastics] 
    Make sure your indexes are not de-fragmented [run rebuild indexes]
    If you are dealing with many rows may be 40000 * 12 (because of multicast) = 4,800,000 rows the try to separate package. 
    Check your excel file format/column data type is correct
    Check user permission who is running the job has required permission on folder/file.
    Understand that sort is a blocking transformation and it requires all your data in memory before it sorts. so, if there are large number of rows then your complete memory will be occupied. 
    Difference between Visual Studio & BIDS/SSDT
    Nothing much, other than BIDS runs on 32 bit while jobs on 64 bit (but there run time environment are configurable, though) 
    There shouldn't be any performance difference until your
    package is on network location because transferring data to the network may slow the package. If package runs on SQL Server it uses SQL buffer pool to fetch data via SQL statement and then SSIS works on its own memory allotment. 
    Hope this will help you to understand and fix the issue.
    Glad to help! Please remember to accept the answer if you found it helpful. It will be useful for future readers having same issue.

  • PL/SQL function. ORA-00933: SQL command not properly ended

    This is my first attempt at pl/sql functions with dynamic sql. It will compile, but when I try to test it I get the ORA-00933 error at line 147. line 147 is OPEN retval FOR report_query;
    Please take a look and let me know what it wrong! thanks
    {CREATE OR REPLACE FUNCTION TSARPTS.Stats (v_Hub       IN VARCHAR2,
                                              v_type      IN VARCHAR2,
                                              v_subtype   IN VARCHAR2)
       RETURN SYS_REFCURSOR
    IS
       retval           SYS_REFCURSOR;
       report_query_a   VARCHAR2 (10000)
                           := '
      SELECT hub,
             CASE
                WHEN Total = 0 OR Pass_1st = 0 THEN 0
                ELSE ROUND (Pass_1st / (Total) * 100, 2)
             END
                AS Pass_1st_percent,
             CASE
                WHEN Total = 0 OR Pass_2nd = 0 THEN 0
                ELSE ROUND (Pass_2nd / (Total) * 100, 2)
             END
                AS Pass_2nd_percent,
             CASE
                WHEN Total = 0 OR Pass_3rd = 0 THEN 0
                ELSE ROUND (Pass_3rd / (Total) * 100, 2)
             END
                AS Pass_3rd_percent,
             CASE
                WHEN Total = 0 OR DNM = 0 THEN 0
                ELSE ROUND (DNM / (Total) * 100, 2)
             END
                AS DNM,
             CASE
                WHEN Total = 0 OR Incomplete = 0 THEN 0
                ELSE ROUND (Incomplete / (Total) * 100, 2)
             END
                AS Incomplete
        FROM (  SELECT hub,
                       SUM (DECODE (result, ''Pass_on_1st'', 1, 0)) Pass_1st,
                       SUM (DECODE (result, ''Pass_on_2nd'', 1, 0)) Pass_2nd,
                       SUM (DECODE (result, ''Pass_on_3rd'', 1, 0)) Pass_3rd,
                       SUM (DECODE (result, ''DNM'', 1, 0)) DNM,
                       SUM (DECODE (result, ''INCOMPLETE'', 1, 0)) Incomplete,
                         SUM (DECODE (result, ''Pass_on_1st'', 1, 0))
                       + SUM (DECODE (result, ''Pass_on_2nd'', 1, 0))
                       + SUM (DECODE (result, ''Pass_on_3rd'', 1, 0))
                       + SUM (DECODE (result, ''DNM'', 1, 0))
                       + SUM (DECODE (result, ''INCOMPLETE'', 1, 0))
                          Total
                  FROM employees_vw a, pse_vw b
                 WHERE     a.emplid = b.emplid
                       AND status IN (''S'', ''I'', ''N'')
                       AND TYPE = ''PSE''
       report_query_b   VARCHAR2 (10000)
                           := ' 
    SELECT hub,
           TYPE,
           subtype,
           CASE
              WHEN Total = 0 OR Pass_1st = 0 THEN 0
              ELSE ROUND (Pass_1st / (Total) * 100, 2)
           END
              AS Pass_1st_percent,
           CASE
              WHEN Total = 0 OR Pass_2nd = 0 THEN 0
              ELSE ROUND (Pass_2nd / (Total) * 100, 2)
           END
              AS Pass_2nd_percent,
           CASE
              WHEN Total = 0 OR Pass_3rd = 0 THEN 0
              ELSE ROUND (Pass_3rd / (Total) * 100, 2)
           END
              AS Pass_3rd_percent,
           CASE
              WHEN Total = 0 OR DNM = 0 THEN 0
              ELSE ROUND (DNM / (Total) * 100, 2)
           END
              AS DNM,
           CASE
              WHEN Total = 0 OR Incomplete = 0 THEN 0
              ELSE ROUND (Incomplete / (Total) * 100, 2)
           END
              AS Incomplete
      FROM (  SELECT hub,
       TYPE,
           subtype
                      SUM (DECODE (result, ''Pass_on_1st'', 1, 0)) Pass_1st,
                       SUM (DECODE (result, ''Pass_on_2nd'', 1, 0)) Pass_2nd,
                       SUM (DECODE (result, ''Pass_on_3rd'', 1, 0)) Pass_3rd,
                       SUM (DECODE (result, ''DNM'', 1, 0)) DNM,
                       SUM (DECODE (result, ''INCOMPLETE'', 1, 0)) Incomplete,
                         SUM (DECODE (result, ''Pass_on_1st'', 1, 0))
                       + SUM (DECODE (result, ''Pass_on_2nd'', 1, 0))
                       + SUM (DECODE (result, ''Pass_on_3rd'', 1, 0))
                       + SUM (DECODE (result, ''DNM'', 1, 0))
                       + SUM (DECODE (result, ''INCOMPLETE'', 1, 0))
                          Total
                  FROM employees_vw a, pse_vw b
                 WHERE     a.emplid = b.emplid
                       AND status IN (''S'', ''I'', ''N'')
                     AND TYPE = ''PSE''
       report_query     VARCHAR2 (10000);
    BEGIN
       IF v_hub <> '*'
       THEN
          report_query := report_query_a;
       ELSE
          report_query := report_query_b;
       END IF;
       IF v_hub <> '*'
       THEN
          report_query :=
             report_query || ' and hub = ''' || v_hub || ''' GROUP BY hub )
    GROUP BY hub,
             Pass_1st,
             Pass_2nd,
             Pass_3rd,
             Total,
             DNM,
             Incomplete';
       END IF;
       IF v_type <> '*' AND v_subtype <> '*' AND v_hub <> '*'
       THEN
          report_query :=
                report_query
             || ' and hub = '''
             || v_hub
             || ''' and type = '''
             || v_type
             || ''' and subtype= '''
             || v_subtype
             || '''
              GROUP BY hub,
                     TYPE,
                     subtype,
            GROUP BY hub,
                     TYPE,
                     subtype,
                     Pass_1st,
                     Pass_2nd,
                     Pass_3rd,
                     Total,
                     DNM,
                     Incomplete';
       END IF;
       OPEN retval FOR report_query;
       RETURN retval;
    END;
    Edited by: user10821012 on May 13, 2010 9:56 AM

    What you are seeing is pretty common. When I work with dynamic SQL I usually include some logic to put the dyanmic SQL into a string and a means to see what was generated, something like (untested here)
      v_sql_c := 'select * from dual';
      open refcur for v_sql_c;
    exception
      when others then
         insert into work_table (clob_column) values (v_sql_c);so I can later query the table to get to the generated SQL for debugging, something like
      select * from work_table;I also try to write dynamic SQL so I can paste it from the work table right into query execution without editing.

  • Oracle JDBC Driver, SQL, and erroneous ORA-00942

    We've been running the following prepared statement without trouble for several months: "SELECT ST FROM STATELT WHERE UPPER(ST)=UPPER(?) OR UPPER(STATE)=UPPER(?) OR UPPER(ABBREV)=UPPER(?) ", using the latest version of the Oracle JDBC drivers. The code that calls the statement, in this case, substitutes "ME" for the three ? characters via setString().
    Yesterday, we pointed our application to an identically populated schema running on the same Oracle 8.1.6.1.0 server. The only difference was that the schema name was 11 characters long rather than six. The STATELT synonym was valid, and could be queried via SQL*PLUS. However, running the query produced an ORA-00942: "table or view does not exist" error.
    Here's the really weird bit: Adding a space to the above anywhere that is legal including before SELECT, at the very end of the SQL, between SELECT and ST (so that there are 2 spaces there), on either side of any of the ='s, all make the SQL work.
    We tried this with an older 8.1.6 JDBC driver and the latest version from the Oracle TechNet site (downloaded yesterday), on three separate computers, and on Windows 2000 and Linux. The problem does seem to be specific to the new schema, but we see no reason why.
    I'd like to know what's up here, since it is shipping software. I'm beginning to suspect that the Oracle Server itself might be responsible, rather than the JDBC driver per se.

    Luis Cabral wrote:
    jschell wrote:
    Although if you are changing the object structure then the code to deal with it must change as well. So, especially in developement, why is restarting a problem?It is not that restarting per se is a problem. Here us developers do not have the required privileges to restart the JDBC pool and we have to ask the DBA to do it, and sometimes he is not immediately available. It is not a big thing but this can impact the development process.Your development process is hideously flawed then.
    The pool exists in the JEE server. And from your first post it seems that you have permission to restart that but not to access the management console. It is ridiculous to have access the the former and not the later.
    Not to mention that you should have your own JEE instance to develop on. Actually it is weird to me that a DBA would even be touching a JEE server. The competent ones I know don't even know how to do that. They know the database not the application servers.
    >
    In addition, having to restart a whole JDBC pool just because you changed a database object definition does not seem very flexible to me. Such issue does not exist in other connection types, for instance in OCI connections, that is why I thought there should be an option to turn it off if required.
    Well specifically you have to restart the pool because you were USING the object that changed.
    And I am rather certain that you can turn off the pool entirely.
    Even in production, I reckon that this may have a negative impact. For instance, say that you need to deploy a hot fix for a bug in one application that involves the re-creation of one single object type. This means that the whole JDBC pool, which may be used by other applications, may have to be shut down just because of that single object.Good point.
    I suggest you stop using complex objects in Oracle. I suspect that would eliminate the problem completely.

  • Executing unix script within java and getting the return value

    Hi
    I am executing a unix script from within java which will return me a value. Is there a way I get this value and use it inside my java code without doing this:
    BufferedReader in = new BufferedReader( new InputStreamReader( ls_proc.getInputStream() ));
    //readLine reads in one line of text
    int k = 1, i = 0;
    while (( ls_str = in.readLine()) != null)
    --kirk123                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    I was hoping to get what I want in one or two line codes.
    --kirk123                                                                                                                                                                                           

  • Installed 2 10g oracle homes and get ora-12557

    hi,
    I have installed 2 oracle 10g homes and now cannot connect to sqlplus as sysdba
    the error is 0ra-12557, TNS protocol adapter not loasdable.
    the installation is on windows 2003 server
    everything was fine until the second oracle home was added.
    help is appreciated
    rgds
    alan

    Typically this a PATH variable problem
    The golden rule is to install the oldest product first.
    Then make sure you path has the right ORACLE_HOME/bin 's
    In the right order.
    Remeber if you run say sqlplus from ORACLE-HOME1 it will look in
    ORACLE_HOME1/network/admin for its tnsnames files etc
    If you run sqlplus fom ORACLE_HOME2 then it will look in
    ORACLE_HOME2/network/badmin
    I always clone the network config files so they are the same in all homes.
    You have to be a little bit careful about this. FOr instance I have forms 6i wihich uses Net 8 so I can't exacly clode the tnsnames etries.
    But you get the picture.
    And generally make sure ORACLE_HOME is not set in your windows environment.
    Ths will cause problems.

  • Getting ORA-17629 and ORA-17627 during setting up of data guard

    Hi All,
    I am working on data guard setup, and getting ORA-17629 and ORA-17627. The orapwd file was copied to DR server, but still getting the same error when doing a duplicate database command.
    RMAN> run{
    2> allocate channel c1 type disk;
    3> allocate channel c2 type disk;
    4> allocate auxiliary channel a1 type disk;
    5> allocate auxiliary channel a2 type disk;
    6> duplicate target database for standby from active database
    7> spfile
    8> set db_unique_name='DRTELPRD'
    9> set standby_file_management='AUTO'
    10> set FAL_CLIENT='DRTELPRD'
    11> set FAL_SERVER='TELRPD'
    12> nofilenamecheck;
    13> }
    allocated channel: c1
    channel c1: SID=950 device type=DISK
    allocated channel: c2
    channel c2: SID=942 device type=DISK
    allocated channel: a1
    channel a1: SID=97 device type=DISK
    allocated channel: a2
    channel a2: SID=96 device type=DISK
    Starting Duplicate Db at 26-AUG-11
    contents of Memory Script:
    backup as copy reuse
    file 'e:\app\product\11.1.0\db_1\DATABASE\PWDtelprd.ORA' auxiliary format
    'e:\app\product\11.1.0\db_1\DATABASE\PWDdrtelprd.ORA' file
    'E:\APP\PRODUCT\11.1.0\DB_1\DATABASE\SPFILETELPRD.ORA' auxiliary format
    'E:\APP\PRODUCT\11.1.0\DB_1\DATABASE\SPFILEDRTELPRD.ORA' ;
    sql clone "alter system set spfile= ''E:\APP\PRODUCT\11.1.0\DB_1\DATABASE\SPF
    ILEDRTELPRD.ORA''";
    executing Memory Script
    Starting backup at 26-AUG-11
    RMAN-03009: failure of backup command on c1 channel at 08/26/2011 14:44:17
    ORA-17629: Cannot connect to the remote database server
    ORA-17627: ORA-01031: insufficient privileges
    ORA-17629: Cannot connect to the remote database server
    continuing other job steps, job failed will not be re-run
    released channel: c1
    released channel: c2
    released channel: a1
    released channel: a2
    RMAN-00571: ===========================================================
    RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
    RMAN-00571: ===========================================================
    RMAN-03002: failure of Duplicate Db command at 08/26/2011 14:44:17
    RMAN-03015: error occurred in stored script Memory Script
    RMAN-03009: failure of backup command on c2 channel at 08/26/2011 14:44:17
    ORA-17629: Cannot connect to the remote database server
    ORA-17627: ORA-01031: insufficient privileges
    ORA-17629: Cannot connect to the remote database server
    RMAN>

    Thanks for your instructions. It worked very good. But, I am getting errors for redo01.log files. The redo log files are not created.
    ORA-00313: open failed for members of log group 1 of thread 1
    ORA-00312: online log 1 thread 1: 'E:\ORACLE\ORADATA\TELPRD\REDO01.LOG'
    ORA-27041: unable to open file
    OSD-04002: unable to open file
    O/S-Error: (OS 2) The system cannot find the file specified.
    Errors in file e:\app\diag\rdbms\drtelprd\drtelprd\trace\drtelprd_mrp0_352.trc:
    ORA-00313: open failed for members of log group 1 of thread 1
    ORA-00312: online log 1 thread 1: 'E:\ORACLE\ORADATA\TELPRD\REDO01.LOG'
    ORA-27041: unable to open file
    OSD-04002: unable to open file
    O/S-Error: (OS 2) The system cannot find the file specified.
    Clearing online redo logfile 1 E:\ORACLE\ORADATA\TELPRD\REDO01.LOG
    Clearing online log 1 of thread 1 sequence number 3418
    Errors in file e:\app\diag\rdbms\drtelprd\drtelprd\trace\drtelprd_mrp0_352.trc:
    ORA-00313: open failed for members of log group 1 of thread 1
    ORA-00312: online log 1 thread 1: 'E:\ORACLE\ORADATA\TELPRD\REDO01.LOG'

  • Xml query error. ORA-00933: SQL command not properly ended

    Hi all,
    My Database Version: Oracle Database 10g Enterprise Edition Release 10.1.0.2.0.
    CREATE table test (Name varchar2(3), Id number);
    insert into test values ('abc', 61);
    insert into test values ('def', 46);
    select table_name,
    column_name,
    'abc' search_string,
    result
    from cols,xmltable(('ora:view("'||table_name||'")/ROW/'||column_name||'[ora:contains(text(),"%'|| 'abc' || '%") > 0]')
    columns result varchar2(10) path '.'
    where table_name in ('TEST');
    and i get: ORA-00933: SQL command not properly ended it points over '*xmltable*'

    ok, its possible to get output from a xml like this.
    i need output like this,
    customerid CustomerName Country
    1 xxxx 4
    2 yyyy 5
    xml:
    <Customer>
    <CustomerInformation>
              <Customerid>1</Customerid>
              <CustomerName>xxxx</CustomerName>
              <Country>4</Country>
         </CustomerInformation>
    <CustomerInformation>
              <Customerid>2</Customerid>
              <CustomerName>yyyy</CustomerName>
              <Country>5</Country>
         </CustomerInformation>
    </Customer>
    This xml is input to my stored procedure, i need to insert the xml tag values into customner_table.
    For this i insert the xml inro a xml_document_table having a xmltype column.
    after , by using the below mentioned query to select xml_tag values from that column.
    when i execute this query
    INSERT into customer_table(customer_id)
    SELECT X.XML_DOCUMENT.extract('/Customer/commodityInfo/CustomerInformation/Customerid/text()').getStringVal() "Customerid" from XML_DOCUMENT_TABLE X;
    i got output in a single row.
    customerid_
    1 <next line> 2
    But i need output like this,
    Customerid_
    1
    2
    im struggling with this simple insert. pls share ur idea.....
    Edited by: 887268 on Apr 4, 2012 10:04 PM
    Edited by: 887268 on Apr 4, 2012 10:17 PM

  • Err 62007: SQL Error: 99999 ORA-24338: Statement Handle not Executed

    Hi,
    I am facing a problem while adding a new parameter n my JSP Report JDBC query based on a ref-cursor from a stored procedure define in a package in database.
    No problem at database level, I have added the new parameter in package specification and Package body for that procedure and compile my package, it complies without any error and warning.
    but when I open the report and add parameter in the report JDBC query window, then it is generating a error message,
    "Err 62007: SQL Error: 99999 ORA-24338: Statement Handle not Executed "
    and I am unable to add the new parameter in report.
    e.g.
    Actual which was working is:
    My-package.My-procedure(:P1,:P2,:P3 ,:P4,:P5,:P6,:P7)
    I want to do this:
    My-package.My-procedure(:P1,:P2,:P3 ,:P4,:P5,:P6,:P7,:P8)
    but unable to do due to this error message:
    ("Err 62007: SQL Error: 99999 ORA-24338: Statement Handle not Executed ")
    Reports Builder 10g:
    Database 10g:
    Operating system windows XP:
    using JDBC Query base on ref-cursor coming from the stored procedure define in the Package.
    Regards,
    Khan

    and compile my package, it complies without any error and warning.That doesn't mean anything in this case. You are getting a runtime error, not a compilation error. The error is coming when you execute your procedure.
    Did you test your modified procedure in sqlplus or SQL Developer?

  • Java.sql.SQLException: ORA-00933: error when  executing query

    Hello,
    I am trying to execute the following query from a jsp page.
    String sqlUpdate ="UPDATE table_name SET name ='"+name+"', description='"+description+"', proj_link='" projlink"', active='" active"',sort_order='" order"',image='" image"',category='" category"', technology='" technology "' WHERE id="+id+" ";
    stmt.executeQuery(sqlUpdate);
    I get the follwoing error java.sql.SQLException: ORA-00933: SQL command not properly ended
    When I omit "description" from the query it executes fine. But when I place it back into the query I get the above error. The table is in Oracle database and the datatype of description id varchar2(4000). I declared all the variables used in the query, I then assigned values caught from the form and then am trying to update the form varibles in the table.
    Thanks,
    Nikky128

    Nikky128 wrote:
    Hello,
    I am trying to execute the following query from a jsp page.There's a big part of your problem. You shouldn't be doing database stuff in JSPs. If you must, you should be using JSTL and its <sql> tags.
    String sqlUpdate ="UPDATE table_name SET name ='"+name+"', description='"+description+"', proj_link='" projlink"', active='" active"',sort_order='" order"',image='" image"',category='" category"', technology='" technology "' WHERE id="+id+" ";Not using PreparedStatement here is just a silly noob error.
    When I omit "description" from the query it executes fine. But when I place it back into the query I get the above error. The table is in Oracle database and the datatype of description id varchar2(4000). I declared all the variables used in the query, I then assigned values caught from the form and then am trying to update the form varibles in the table.Probably a single or double quote that you can't see. PreparedStatement will eliminate that problem.
    %

  • Compare 2 schemas and get the difference with .sql file.

    Hi,
    I am using ORACLE DATABASE 11g R2 and ORACLE Linux 5.
    I want to perform a very lengthy process and want to make it automated.
    I am having a software named as SVN. In which all the developers keep their updated scripts.
    We have 2 schema's one is used for developement and when all the development seems good we implement the scripts on the final schema which is used by testing people also.
    Now every day we need to check the modifications in the development schema, that we do by observing the updated scripts in the SVN software. Now we get the scripts which are modified.
    We will fire this scripts to a sample schema then we will compare the objects in this schema and the same objects in our final schema. If the objects in sample schema is different than the final schema it should give me the
    script to create the same type object in the final schema.
    Below is a proper example to explain :-
    Developement Schema :- 'DEV'
    SVN Script Schema :- 'SVNscript'
    Main Schema :- 'MAIN'
    1) On Monday developers modified/added 4 tables in the development schema names 'DEV' after working for a day they found that the changes are necessary and so checked-in in the SVN software.
    2) On tuesday morning we found 4 scripts which has been modified/added in the SVN.
    The Scripts were as follows :-
    1St table :- An extra column was added.
    2nd table :- An index was created on it.
    3rd table :- 2 Columns were dropped from it.
    4th table :- A new table is added in the schema.
    Now taking these 4 scripts i am going to execute it in a sample schema named :- SVNscript
    SVNscript schema will have now 4 tables with proper properties(columns,indexes,...). Now this is the final table structure as we want in our 'MAIN' schema .
    Coming to MAIN schema which is our most important schema and all the development work is finally posted here.Considering MAIN schema is having around 1000 tables,500 function/procedure/package and many more DB objects.
    I want to compare(one way compare) from SVNscript schema --> MAIN schema :- That the objects present in the SVNscripts schema is same or not in the MAIN schema. If its not same then this code should generate a .sql script for me which i should be able to fire on the MAIN schema.
    The output .sql scripts should be something like this :-
    1st Table :- Alter table add...
    2nd Table :- Create index on table...
    3rd Table :- Alter table drop...
    4th table :- Create table tablename...
    I found a link while trying this but it is not the perfect fit to my requirement
    http://www.dbspecialists.com/files/scripts/compare_schemas.sql
    Please let me know the best code to compare 2 schemas and get a .sql file as output of the difference.
    Thanks in advance.

    Yes I followed the tutorial properly this time. Still i have a few queries :-
    1) This is returning me the 'ALTER TABLE...' statement but how to make it more efficient to return all the DDL dependent on the table, Like index,trigger,view...
    2) I want to compare objects in a different schema on a different db. I have created an DBLINK but how to use it ... can i use it like
    DBMS_METADATA.OPEN('TABLE'," Network_link_name " );Can you please give me some clear about it.
    3) I created a table 'TAB1' with which i want to compare a 'TAB1' in other schema.I was not getting how to compare on remote dblink so,I created the same table with the following code in the same schema
    CREATE TABLE TAB1_OLD as select * from TAB1@DBLINK where 1=2;Now when i fire the below query to get the alter difference I get the following error :-
    SQL> SELECT get_table_alterddl('TAB1','TAB1_old') FROM dual;
    SELECT get_table_alterddl('TAB1','TAB1_old') FROM dual
    ORA-31603: object "TAB1_old" of type TABLE not found in schema "SVNCHECK"
    ORA-06512: at "SYS.DBMS_METADATA", line 5225
    ORA-06512: at "SYS.DBMS_METADATA", line 5189
    ORA-06512: at "SVNCHECK.GET_TABLE_SXML", line 17
    ORA-06512: at "SVNCHECK.COMPARE_TABLE_SXML", line 12
    ORA-06512: at "SVNCHECK.GET_TABLE_ALTERXML", line 11
    ORA-06512: at "SVNCHECK.GET_TABLE_ALTERDDL", line 11
    Can you please guide me why i am getting this error?
    I have made sure that TAB1_OLD table has been created and the entries are also present in the data dictionary tables.
    SQL> select * from tab1_old;
    EMPNO ENAME                  MGR DEPTNO
    ----- -------------------- ----- ------The only difference is that this table was created with CREATE TABLE AS SELECT statement ....
    Thanks.

  • I am getting "ORA-00900: invalid SQL statement"  error.?

    I did installed oracle 11gR2. and used "DBMS_METADATA_DIFF.COMPARE_ALTER('TABLE','TBL_A','TBL_A','USER1','USER2')"   to see the result like below,  but I am getting "ORA-00900: invalid SQL statement"  error.   Any idea?
    I am using:
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
    PL/SQL Release 11.2.0.1.0 - Production
    CORE 11.2.0.1.0 Production
    TNS for 32-bit Windows: Version 11.2.0.1.0 - Production
    NLSRTL Version 11.2.0.1.0 - Production
    SQL> desc user1.tbl_a
    Name                                      Null?    Type
    FIELD_A1                                  NOT NULL NUMBER
    FIELD_A2                                           VARCHAR2(20)
    FIELD_A4                                  NOT NULL NUMBER(5,2)
    FIELD_A5                                           VARCHAR2(10)
    FIELD_A6                                  NOT NULL NUMBER(2)
    SQL> desc user2.tbl_a
    Name                                      Null?    Type
    FIELD_A1                                  NOT NULL NUMBER
    FIELD_A2                                           VARCHAR2(50)
    FIELD_A3                                           DATE
    FIELD_A4                                           NUMBER(5,2)
    FIELD_A5                                  NOT NULL VARCHAR2(10)
    SQL> select dbms_metadata_diff.compare_alter('TABLE','TBL_A','TBL_A','USER1','USER2') from dual
    expected result:
    DBMS_METADATA_DIFF.COMPARE_ALTER('TABLE','TBL_A','TBL_A','U1','U2')
    ALTER TABLE "U1"."TBL_A" ADD ("FIELD_A3" DATE)
      ALTER TABLE "U1"."TBL_A" DROP ("FIELD_A6")
      ALTER TABLE "U1"."TBL_A" MODIFY ("FIELD_A2" VARCHAR2(50))
      ALTER TABLE "U1"."TBL_A" MODIFY ("FIELD_A4" NUMBER(5,2) DEFAULT 0)
      ALTER TABLE "U1"."TBL_A" MODIFY ("FIELD_A4" NULL)
      ALTER TABLE "U1"."TBL_A" MODIFY ("FIELD_A5" NOT NULL ENABLE)

    Thanks for reply rp,
    I got result using "select dbms_metadata_diff.compare_alter('TABLE','TBL_A','TBL_A','USER1','USER2') from dual"

  • While executing the following pl/sql block   Iam getting  following error

    While executing the following pl/sql block
    Iam getting following error
    ORA-06550: line 5, column 11:
    PLS-00320: the declaration of the type of this expression is incomplete or malformed
    ORA-06550: line 5, column 11:
    PL/SQL: Item ignored
    declare
    TYPE t_customer_details IS REF CURSOR;
    o_customer_details t_customer_details;
    v_rec o_customer_details%ROWTYPE;
    begin
    o_customer_details:=pkg_search.fngetcustdetails( 2727,1000841, NULL,NULL,119105329);
    LOOP
    FETCH o_customer_details INTO rec ;
    EXIT WHEN o_customer_details%NOTFOUND;
    DBMS_OUTPUT.PUT_LINE(' print' );
    END LOOP;
    CLOSE o_customer_details;
    end;

    sorry
    declare
    TYPE t_customer_details IS REF CURSOR;
    o_customer_details t_customer_details;
    begin
    o_customer_details:= pkg_search.fngetcustdetails( 2727,1000841, NULL,NULL,119105329);
    FOR v_rec IN o_customer_details
    LOOP
      DBMS_OUTPUT.PUT_LINE(' print' );
    END LOOP;
    END;I changed code,
    Can you say , o_customer_details:= pkg_search.fngetcustdetails( 2727,1000841, NULL,NULL,119105329); is it right?
    pkg_search.fngetcustdetails return ref cursor??

Maybe you are looking for