Oracle 10g Insert query performs inconsistent as a query vs procedure and p

Database Version: Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bi
No error messages....
I am facing a very weird issue that I have a insert statement in a procedure... pretty much
inert
into oracle_Table
SELECT cr.a AS a,
cr.b AS b,
cr.c AS c,
max(d.column_name) as d
FROM "table 1"@Pmo.World Cr,
[email protected] d
WHERE d."a" = cr."column name"
GROUP BY cr.a,
cr.b,
cr.c
@Pmo.World is a database link to a MSSQL...
The problem I am having right now is, every time I run this insert as a query. Everything works as what it should be... However, when I put this insert into a procedure, it inserts nothing...
Simple test Proceudre:
declare
-- Local variables here
i integer;
begin
inert
into oracle_Table
SELECT cr.a AS a,
cr.b AS b,
cr.c AS c,
max(d.column_name) as d
FROM "table 1"@Pmo.World Cr,
[email protected] d
WHERE d."a" = cr."column name"
GROUP BY cr.a,
cr.b,
cr.c
end;
Thinking about character conversion issue I changed the procedure to
inert
into oracle_Table
SELECT to_char(cr.a) AS a,
to_char(cr.b) AS b,
to_char(cr.c) AS c,
max(d.column_name) as d
FROM "table 1"@Pmo.World Cr,
[email protected] d
WHERE d."a" = cr."column name"
GROUP BY cr.a,
cr.b,
cr.c
Then this Inser works in the procedure... however when I revert it back with the original version that doesnt have to_char... it is working still... then I kept it running for few days... since it runs once per day, it was working for the first 2 days and then stopped working the third day... I verified the source table and every time this procedure runs, source tables were not empty...
It is so confusing because if I manually run the insert as a query, it worked every time I ran it... however if I put that into a procedure, it works from time to time..
Any help is highly apprecaited
Edited by: 986006 on Feb 4, 2013 8:51 AM

986006 wrote:
Thanks for the hints up... I have updated my post... As I post the test procedure...it is about the exact the same as the insert query... Every time, the insert would actually insert data into the table but every time I run the test procedure, nothing gets inserted in... It sounds unbelievable but it happens... ThanksYou obviously haven't read the FAQ, or at least you haven't bothered doing what it asks. Help us to help you.
Can you recreate the problem with simpler data on your local machine? If so provide create table and insert statements for test data.
Format your code and place between tags.
At the very least post the *exact* SQL or PL/SQL you are trying to run: what you've posted isn't even valid SQL.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

Similar Messages

  • Hi i am using oracle 10g how to view the content of the stored procedure or trigger ?

    Hi i am using oracle 10g .How to edit  the content of the stored procedure or trigger ?

    jklopkjl wrote:
    Hi i am using oracle 10g .How to view the content of the stored procedure or trigger ?
    query ALL_SOURCE
    SQL> desc all_source
    Name                                      Null?    Type
    OWNER                                              VARCHAR2(30)
    NAME                                               VARCHAR2(30)
    TYPE                                               VARCHAR2(12)
    LINE                                               NUMBER
    TEXT                                               VARCHAR2(4000)

  • Oracle 10g Express Edition performances

    I'm looking for something about performances of Oracle 10g Express Edition to make a little presentation for the University. Can anyone help me?
    Thnaks

    I'm looking for something about performances of
    Oracle 10g Express Edition to make a little
    presentation for the University. Can anyone help me?What's the matter with the docco? 1 processor only, 1GB ram, one db
    and 4GB disk.
    As to how this will affect your* performance, this can only be
    done by you testing under given conditions. However, if you are doing
    Uni work, why not use the EE - you only have to pay for deployment AFAIK.

  • Oracle 10g - Insert in to Temporary Table - Record count mismatch between s

    We are trying insert records from a select query in to temporary table, some of the records is missing in the temporary table. The select statement is having multiple joins and union all which it little complex query. In simple terms the script contains 2 part 1st Part Insert in to temporary table 2nd part Select query with multiple joins, inline sub queries, unions and group by classes and conditions
    Eg. If we execute select statement alone it returns some count for example => 60000 After inserting into the temp table, in temp table the count is around 42000 why is the difference?
    It is simple bulk inserts... insert in to temp table select from xxx. also, there is no commit in between. The problem is all the records populated by the select statement are not inserted in to temp table. some records are not inserted.*
    Also, we had some other observation. It only happens in its 2nd execution and not its first run. Hope there might be some cache problem
    Even, we also did not believe that. We are wondering. In TOAD, we tested however at times it happens. In application jar file, after "insert in to temp select * from xxx" we take the i. record count of temp table and ii. record count of "select * from xxx" separately but both doesn't match. Match only at 1st time.
    Thank you in advance for your efforts and help.
    Shiva.

    The code looks like
    sql = "insert in to temptable select x,y,z,.... from xxx,abc,pqr..where...."; (logial but not real is very complex around 700 lines with multiple joins, inline sub queries, group by etc. )
    stmt = conn.createStatement();
    rCount= stmt.executeUpdate(sql);
    Actual issue is
    rCount = xxxx = Count(temptable) < count(select x,y,z,.... from xxx,abc,pqr..where....)
    why this diffference ? some records populated in the select but not inserted in to temp table
    Anyone can explain?

  • Oracle 10g - WAN low performance.

    Hello All,
    I have problem with Oracle 10g Server working on Windows 2003. There is a database and its working with client in delphi.
    Inside LAN all working perfect, but trough WAN im waiting for transaction results about 10 times longer. I noticed that there is not connected with bandwidth, the same results i get with 512 Kbits, 2Mbits, and 5Mbits, pings and for example copying files working perfect, but traffic between clients and server 10g used always max 512Kbit of bandwidth. Any ideas?
    Kris

    On your WAN connections, what kind of ping times do you see? What kind of distances are we talking about for your WAN connections? Is your application "chatty"? How many round-trips does a transaction consist of?
    -Mark

  • Oracle 10g Issue [ORA-00932: inconsistent datatypes: expected ]

    Hi,
    The following Code Snippet works fine in Oracle 9i DB but gives "ORA-00932: inconsistent datatypes: expected - got -; " error in 10g DB. We are facing lot of issues with this since we migrated application to 10g
    create or replace procedure cca is
    TYPE Cur_OPCols_Typ IS REF CURSOR;
    l_Cur_OPCols Cur_OPCols_Typ;
    str VARCHAR2(32767) :='select sysdate, 123 from dual';
    TYPE StringTyp IS TABLE OF VARCHAR2(7000) INDEX BY BINARY_INTEGER;
    capture StringTyp;
    BEGIN
         Open l_Cur_OPCols FOR str;
         FETCH l_Cur_OPCols BULK COLLECT INTO capture;
    dbms_output.put_line (capture.COUNT);
         Close l_Cur_OPCols;
    END cca;
    Please advise...
    Regards,
    Chinmay

    But...
    SQL> select * from v$version;
    BANNER
    Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
    PL/SQL Release 9.2.0.1.0 - Production
    CORE    9.2.0.1.0       Production
    TNS for Solaris: Version 9.2.0.1.0 - Production
    NLSRTL Version 9.2.0.1.0 - Production
    <br>
    <br>
    "afiedt.buf" 13 lines, 370 characters
      1  declare
      2   TYPE Cur_OPCols_Typ IS REF CURSOR;
      3   l_Cur_OPCols Cur_OPCols_Typ;
      4   str VARCHAR2(32767) :='select sysdate, 123 from dual';
      5   TYPE StringTyp IS TABLE OF VARCHAR2(7000) INDEX BY BINARY_INTEGER;
      6   capture StringTyp;
      7  BEGIN
      8   Open l_Cur_OPCols FOR str;
      9   FETCH l_Cur_OPCols BULK COLLECT INTO capture;
    10   dbms_output.put_line (capture.COUNT);
    11   Close l_Cur_OPCols;
    12* END cca;
    SQL> /
    declare
    ERROR at line 1:
    ORA-00932: inconsistent datatypes: expected - got -
    ORA-06512: at line 9                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Oracle 10g - Insert value into a self-created table in stored proc

    Hi all,
    Say I'm creating a table using the following logic,
    pc_create_table := 'create global temporary table revs(var1 number(5,0), ..., ...,) on commit preserve rows';
    execute immediate pc_create_table;
    When I'm attempting to insert value into this table (v_var1 is a pre-defined variable),
    pc_insert_value := 'insert into revs(var1, ..., ...,) values (v_var1, ...)'
    execute immediate pc_insert_value;
    I got the following error: "ORA-00984: column not allowed here"
    Any advise on this issue? Thanks a lot

    isaacniu wrote:
    However I got two errors in that line,
    Error(68,6): PL/SQL: SQL Statement ignored
    Error(68,18): PL/SQL: ORA-00942: table or view does not existAnd why do you want your PL/SQL code to run DDLs??
    Its not designed that way, is not a good practice and is strictly not recommended. You can read <a href ="https://forums.oracle.com/forums/profile.jspa?userID=287238">Billy Verreynne's</a> take on this :
    {message:id=10040770}
    To my suprise it's saying the table or view does not exist. According to my logic, the table "revs" created by executing pc_create_table, however it's NOT explicitly declared in other parts of this script, is this where the problem is?The Problem is, SQLs fired using Execute Immediate are evaluated, compiled, parsed and executed at run time. So when you compile procedure pc_create_table, table revs is still not created. Hence you get error when you try inserting rows in it.
    Any advises are appreciated.Get the table created by your DBA, and use insert statement without execute immediate in your procedure.

  • Oracle 10g tools for performance/troubleshooting

    Hi
    I want to find some tools for moniting the performance and troublesooting. Any suggest? OEM tuning pack, statspack...etc
    Thanks

    Different tools for different troubles. What trouble are you trying to shoot?
    For general information, try the Performance Tuning guide.

  • OracleAS 10g (9.0.4.0.2) Load Balancing  Forms, Discoverer and reports

    I am having some problems trying to load balance with Oracle Forms, Discoverer and reports Oracle Application Server Release 10g (9.0.4.0.2) and I was wondering if you could help. Has any one ever got this to work consistently? We are an ERP product written mostly in forms (904) and are trying to implement are largest customer there performance issue so we need the load balancing to work. Will also accept other recommendation as cost effective as solutions.
    Site 1:
    A: SERVER –
    •     Host as1.xyzco.local
    •     Version 10.1.2.0.2
    •     Installation Type Identity Management and Metadata Repository
    •     Oracle Home E:\oracle\inf_1012
    •     Farm as1db.xyzco.net
    o     HTTP_Server
    o     Internet Directory
    o     OC4J_SECURITY
    o     Single Sign-On:orasso
    o     Management
    B SERVER –
    •     Host as2. xyzco.local
    •     Version 9.0.4.0.2
    •     Installation Type Business Intelligence and Forms
    •     Oracle Home E:\oracle\mid_904
    •     Farm as2db. xyzco.net
    o     Discoverer
    o     Forms
    o     home
    o     HTTP_Server
    o     OC4J_BI_Forms
    o     Reports Server
    o     Web Cache
    o     Management
    C SERVER –
    •     Host as3. xyzco.local
    •     Version 9.0.4.0.2
    •     Installation Type Business Intelligence and Forms – Discoverer and Reports
    •     Oracle Home E:\oracle\mid_904
    •     Farm as2db. xyzco.net
    o     Discoverer
    o     Forms
    o     home
    o     HTTP_Server
    o     OC4J_BI_Forms
    o     Reports Server
    o     Web Cache
    o     Management
    All servers Are:
    •     Windows 2003 Standard Server with current service packs
    •     Xeon Dual Processor with 4GB ram
    •     Raid 0 drives 2 for OS and 2 for Oracle
    Daniel Brody
    ([email protected])

    I have more then half decent results with webcache as load balancer, but it still is a round robin (as mentioned before). This means that a session will not be transfered from one application server to the other once the session has been created.
    So far I did not discover any benefits of a hardware loadbalancer over webcache, because (here it is again:) you are not able to transfer open sessions from one application server to the next. This has to do with the Oracle Forms architecture. In fact it is still client-server, only with the application server functioning as extra server ;)

  • How to avoid:Query returns extra trailing spaces in oracle 10g

    I want to use cursor sharing FORCE, SIMILAR for performance tuning. but i am having some problems like query process will give extra trailing spaces this will throw errors from the java application while reading literals.
    do we have any option in oracle 10g to avoid extra trailing spaces during query processing ?
    alter session set cursor_sharing ='EXACT'
    select 1 from dual;
    '1'
    1
    alter session set curson_sharing='FORCE'
    select 2 from dual;
    '2'
    2
    alter session set curson_sharing='SIMILAR'
    select 3 from dual;
    '3'
    3

    You are right, But we already wrote millions of queries during that time we used cursor sharing is EXACT. so i don't want to take risk in modifying all the existing queries by adding TRIM.
    do we have any option in oracle to trim after/ during processing the query.
    Now we are facing performance issues and suggested us to use SIMILAR as cursor_sharing. but all the selected rows are giving extra tralining spaces.
    I think i am clear now.

  • Oracle 10G gives in sorted order without order by ,in 11g it is not.

    we are facing a strange problem.
    we have M Views on which we perform select operation ,we put joins of M Views and get the results by select operation , the results was in sorted order (asc) and we were not using any order by clause in the select query , this was in oracle 10G.
    The compelte schema where these M views are and also the underneath tables are now migrated to oracle 11g using import/export option.
    Now the queries which was giving the result set in sorted order (asc), are not given the result set in sorted order anymore. it is in different order but I think at always return the same order not asc or desc but an specific random order .
    we can not change the query as of now as there are 1000+ and each query would require a order by statement .
    Do we have any parameters which can be change , so that we can force oracle to use a different plan so that it gives result in order ?
    the select queries are very simple ones not complicated no extra function or group by is used in most of the queries.
    Please suggest possible solutions . Thanks much.

    Su**** wrote:
    Please guide me how to go to this doc link ,i am newbi, and do not how to go to this link.
    MOS Doc 345048.1 ('Group By' Does Not Guarantee a Sort Without Order By Clause In 10g and Above)
    Go to http://support.oracle.com, log in to My Oracle Support, and search for 345048.1 If you don't have a My Oracle Support account, you'll need to contact whoever manages your company's Oracle support and ask them to create an account for you.
    Basically, no version of Oracle has ever guaranteed the order of results if you don't specify an ORDER BY clause. In 10g, the only algorithm that was available to implement a GROUP BY happened to sort the results as a side effect. 11g introduced a new algorithm for grouping results that is more efficient and does not have the side effect of ordering the results. Most likely, your query plans have changed to use the more efficient grouping algorithm.
    If you want the results to be sorted, you should add an appropriate ORDER BY clause. If you go through the MOS document, there will also be suggestions for ways that you can disable the new grouping algorithm though I would not recommend that.
    Justin

  • Query performance vs MySQL

    I have a table with about 500 million records in it stored within both Oracle and MySQL (MyISAM). I have a column (say phone_number) with a standard b-tree index on it in both places. Without data or indexes cached (not enough memory to fully cache the index), I run about 10,000 queries using randomly generated phone numbers as criteria in 10 concurrent threads. It seems that the average time to retrieve a record in MySQL is about 200 milliseconds whereas in Oracle it is about 400 milliseconds. I'm just wondering if MyISAM/MySQL is inherently faster for a basic index search than Oracle is, or should I be able to tune Oracle to get comparable performance.
    Of course the hardware configurations and storage configurations are the same. It's not the absolute time I'm concerned about here but the relative time. Twice as long to perform basically the same query seems concerning. I enabled tracing and it seems like some of the problem may be the recursive calls Oracle is making. Is there some way to optimize this a bit further?
    Realize, I just want to look at query performance right now...ignoring all of the issues (locking, transactional integrity, etc.)
    Thanks,
    Greg

    In Oracle, a standard table is heap-organized. A b-tree index then contains index keys and ROWIDs, so if you need to read a particular row in the table, you first do a few I/O's on the index to get the ROWIDs and then look up the ROWIDs in the table. For any given key, ROWIDs are likely to be scattered throughout the table, so this latter step generally involves multiple scattered I/O's.
    You can create an index-organized table or a hash cluster in Oracle in order to minimize the cost of this particular sort of lookup by clustering data with the same key physically near each other and, in the case of IOTs, potentially eliminating the need to store the index and table separately. Of course, there are costs to doing this in that inserts are now more expensive and secondary indexes are likely to be less useful. That probably gets you closer to what MySQL is doing if, as ajallen indicates, a MySQL table is generally stored more like an IOT than a heap-organized table.
    If you get really creative, you could even partition this single table to potentially improve performance further.
    Of course, if you're only storing one table, I'm not sure that you could really justify the cost of an Oracle license. This may well be the case where MySQL is more than sufficient for what this particular customer needs (knowing, nothing, of course, about the other requirements for the system).
    Justin

  • Migration from Oracle 9i 32 bit to Oracle 10G 64 bit on Windows 2003 Server

    I am working on migrating Oracle 9i 32 bit to Oracle 10G 64 bit on Windows 2003 from Old server to new server. We have db around 500 GB and 3 schemas. I installed Oracle 10G on new server, created tablespaces, schema's blah blah and now doing export and import at schema level from old server to new server.
    Import is taking more than 4 to 5 hours on new server. My manager is saying, window time is bit longer and he wants me to try possiblities to make this process faster. Can some one help me on this, to use the best possible method to complete this process faster?
    Will below step work, if I try?
    If I install, oracle 9i and 10g both on new server in different home directories and take the hot backup from old machine and restore on new machine in 9i home directory and use the upgrade configuration assistant from 10g and do the upgrade? Pls advice.
    Thanks in advance,
    Hari babu
    Edited by: user6367891 on Mar 2, 2010 5:28 AM

    It looks good.
    I have one question in below steps:
    To migrate an Oracle9i or older database to an Oracle Database 10g Release 1 (10.1) database for 64-bit Windows:
    1 Perform steps 1 - 11 in "Migrating an Oracle Database 10g Release 1 (10.1) Database".
    2 Shut down the database on the 64-bit computer:
    SQL> SHUTDOWN IMMEDIATE;
    3 Start the database migration:
    SQL> STARTUP MIGRATE;
    4 Migrate the database as described in Chapter 3, "Upgrading a Database to the New Oracle Database 10g Release" in Oracle Database Upgrade Guide.
    In step 4, it says, migrate database as described in chapter 3. In chapter 3, it says, to do the upgrade the process using dbca or manually. Pls confirm whether do the upgrade process after issuing startup migrate or not.
    Thanks in advance.

  • Encryptind and decrypting database column in oracle 10g

    hi guys...
    i am sai sandeep,i got a doubt how to encrypt a database column in oracle 10g..?
    i am using a table " emp_uid " ,and strtucture as follows,
    create table emp_uid(user_id varchar2(20),pwd varchar2(20));
    i need to encrypt a pwd column in the emp_uid.
    how to do it..?
    thanking u  advance.....

    Ok, here's a basic example...
    SQL> create table myusers (username varchar2(30), password varchar2(40));
    Table created.
    SQL> create or replace procedure add_user(username in varchar2
      2                                      ,password in varchar2) is
      3  begin
      4    insert into myusers (username, password)
      5      values (add_user.username
      6             ,dbms_crypto.hash(utl_raw.cast_to_raw(add_user.username||'!'||add_user.password)
      7                              ,dbms_crypto.hash_sh1)
      8             );
      9    commit;
    10  end;
    11  /
    Procedure created.
    SQL> exec add_user('Fred','Fr3ddy')
    PL/SQL procedure successfully completed.
    SQL> select * from myusers
      2  /
    USERNAME                       PASSWORD
    Fred                           E5C975DB4C0A1CF65683E36421A6305F09F4EA9A
    SQL> set serverout on;
    SQL> create or replace procedure loginuser(username in varchar2
      2                                       ,password in varchar2) is
      3    v_hash     varchar2(40);
      4    v_username varchar2(30);
      5  begin
      6    v_hash := dbms_crypto.hash(utl_raw.cast_to_raw(loginuser.username||'!'||loginuser.password), dbms_crypto.hash_sh1);
      7    select username
      8    into   v_username
      9    from   myusers
    10    where  username = loginuser.username
    11    and    password = v_hash;
    12    dbms_output.put_line('User: '||v_username||' logged in.');
    13  exception
    14    when no_data_found then
    15      dbms_output.put_line('Username/Password is not valid!');
    16  end;
    17  /
    Procedure created.
    SQL> exec loginuser('Fred','Freddy');
    Username/Password is not valid!
    PL/SQL procedure successfully completed.
    SQL> exec loginuser('Fred','Fr3ddy');
    User: Fred logged in.
    PL/SQL procedure successfully completed.
    Ideally you would do the hashing of the password inside the client side application so only the Hashed value goes over the network, but the above demonstrates the principle of using hashes to store passwords.  Because it's a one way algorithm, only a brute force method can be used to try and determine the original password.  There is no way to directly un-hash the value.  To check for a valid login, we don't retrieve the password and try to unhash it to compare against what the user has supplied, we actually take what the user has supplied and hash that in the same way and then compare the hashes.
    The point of including the username or some other data in the hashing process means that if two users have the same password, they will still have different hash values, so it won't be apparent they are the same passwords.  In my example, the point of putting another character between the concatenation of username and password is in case the username and password together would give the same result e.g.
    If we had one user "Fred" with password "Fr3ddy" then just concatenating the strings would give "FredFr3ddy".
    If we had another user "FredF" and he happened to choose a password "r3ddy" then just concatenating those would also give "FredFr3ddy"
    by introducing a known breaking character they would be different e.g. "Fred!Fr3ddy" and "FredF!r3ddy" and hence give different hash values.
    That's the basics of how passwords are stored for security.
    It would take a lot of processing power and brute force methods just to determine a single password for a single user when using hashing methods of security.
    With encryption, a brute force method could be used to find the decryption key, and once found that could be used to decrypt ALL the encyrpted data, hence it is less secure, especially when some clever person will no doubt have written the key down somewhere so they don't forget it.  With hashing there's no key to write down. 

  • Kill Session in Oracle 10g

    Oracle 10g r2
    I killed a session after fetching the sid and serial from the v$session as under
    select * from v$session where username='SAM';
    alter system kill session '530,7420'
    Now the status showed killed.
    But again after some time one i query the v$session the status turn to inactive.
    Why so?

    Yeah Madrid....
    Thanks for that.. at the developer side.. they did get session killed.
    But actually my doubt here was. that once i killed the session then i go the status as "killed" in the v$session
    but less then a minute when i again query the v$session then i see the status aa inactive. This is what is not clear to me.

Maybe you are looking for

  • How to Create a Configuration Manager Console Custom View

    I am trying to create an assembly per the SDK example here: https://msdn.microsoft.com/en-us/library/hh948614.aspx I have added the assemblies per this article: https://social.technet.microsoft.com/Forums/en-US/5d74d30d-295b-4c51-8518-abdabbad731b/co

  • Email for ipod touch 2g on iOS 4.2.1

    I have an ipod touch 2g which has iOS ver 4.2.1..thats the max available for this device.Since there are no apps on the app store compatible with ipod touch 2g , it has been reduced to a music player only. I was wondering If I can still use the mail

  • How do i get icloud on my mac????

    i just bought an older imac from my boss. id say its about an 08 maybe 06. well since it came from a doctors office the whole computer had to be wiped clean back to original hard drive. now it doesnt hve icloud on it and will not locate my iphone in

  • Acrobat 9.2.0 Pro Extednded deffective print to PDF

    PC: Win7 Home Premium; Recently have had no success with printing to PDF using Acrobat 9.2.0 Pro Extednded. After some malware infection Acrobat 9.2.0 Pro Extednded stopped printing to PDF. Cleaned out the malware, did a fresh reinstall of PDF 9.6.2

  • APO - capacity profile time capacity for resources

    Dear all, I have a problem which I hope can be resolved by one of you ... In APO, it is possible to add downtimes for resources using transaction /SAPAPO/RES01 ... After adding this, we can click on "capacity profile" and then we see the time capacit