Thursday, January 16, 2014

java.sql.SQLDataException: ORA-01405: fetched column value is NULL



Exception Description

ORA-01405 is thrown when you attempt to execute FETCH, which was returned as a NULL value, but there was no indicator in use. If you are using Oracle

I have a databse function to which if you pass a query it will give you back a CLOB containing XML output of that query , I encountered this error today when I try to pass a query which returns null as result there I got this exception.



Handling

Once I understood the exception and it's cause the handling code aws easy to write , in my catch block I will retun an error message like "No Record Found ,You may want to revise your query to get some data satifying your conditions".


Solution

You might try resolving ORA-01405 by substituting a value with NVL function when a NULL value appears, or simply construct your cursor so that NULL values are not returned (you may also specify that columns with NULL values are not received).

 

Tuesday, December 10, 2013

ORA-03115: unsupported network datatype or representation

In a code written by another developer I was trying to replace JDBC statement code with prepared statements

So I was trying to do something like
   
PreparedStatement preparedStatement=con.prepareStatement(sql);
preparedStatement.setString(1, START_DT);

preparedStatement.setString(2, END_DT);

    
ResultSet set = preparedStatement.executeQuery(sql);

but all the queries being executed by above code were giving me the below exception


"ORA-03115: unsupported network datatype or representation"

I found that mistakenly I was calling the executeQuery method and passing it the sql again (this happend because I changed the code to use PreparedStatements instead of Statement , and if you are using statement you need to pass sql to execute query) , which is wrong I needed to call the function like

ResultSet set = preparedStatement.executeQuery();

and this resolved the problem :).

Wednesday, November 20, 2013

javascript capture ctrl+key


Using below Javascript snippet you can trigger things in your web application based on key combinations
 

  /*http://stackoverflow.com/questions/2878983/capture-key-press-without-placing-an-input-element-on-the-page*/  

  document.onkeydown = function(evt) {

          evt = evt || window.event;

          //ctrl+caps

          if (evt.ctrlKey && evt.keyCode == 20 ) {

             

              //**Open a new tab and shift the focus to it

              window.open('url to your page','_blank');

              win.focus();

          }

      };

 

The below website can be used to look for the key codes

Thursday, October 31, 2013

How to get list of tables used in a stored procedure or package

Try to run below query and privide the first value as the owner of this procedure and second value as the procedure name

select
   owner,
   type,
   name,
   referenced_owner,
   referenced_type,
   referenced_name
from
   dba_dependencies
where
   ((owner like upper('&1')
   and
      name like upper('&2') )
   or
   (referenced_owner like upper('&1')
   and
   referenced_name like upper('&2') ))
   and
   referenced_owner != 'SYS'
   and
   referenced_type != 'NON-EXISTENT'
order by
   owner, type, name;

This will give you a list of all tables , synonym , other packages used in your stored procedure.

For more information please see the below link
http://www.dba-oracle.com/t_tables_referenced_inside_pl_sql_procedures.htm 

Tuesday, October 29, 2013

oracle execute privilege on package

 In order to see which roles have execute priviliges on a table/package/any other database object I use below sql query 

SELECT grantee
  FROM all_tab_privs
 WHERE table_name = '<Database object name>'
  AND privilege = 'EXECUTE'

For more details have a look at below stackoverflow thread. http://stackoverflow.com/questions/1255310/how-do-i-check-which-schemata-have-been-granted-execute-permission-on-an-oracle


Monday, October 28, 2013

ORA-08103: object no longer exists

I got this exception while I was trying to run a procedure (written by somebody else in our company) which takes very long time to execute , I found that because of the below sequence of events I was getting this exception

Steps Which Produced This Problem
  1. Procedure was opening a cursor (selecting records) , keeping it open for sometime during which it had to do other operations
  2. After finihing those operations it was trying to execute a loop on the cursor (It created before) and was getting this problem.
Reason
     I found that during this time some of those records my cursor was refering to were deleted , and when the cursor tried to fetch those records in the loop there I was getting "ORA-08103: object no longer exists".

Solution
    The only solution I have in mind is to open the cursor and start  utilizing it immidiatly , i.e. don't keep it open waiting for someother operations to finish.This way I will be able to minimoze the probability of this problem to occur in future.

I was trying to fetch the records in a generic oracle table (which I inserted) , another possible reason could be that you have insert rights but don't have select rights on that table. This was not the case in my situation as I had all the rights on the table but I am sharing it here to give you another possible reason of this problem.

Please also have a look at below Stackover threads for detailed discussions on this problem

http://stackoverflow.com/questions/18747649/exception-ora-08103-object-no-longer-exists-on-using-setfetchsize-of-hirabenate

http://stackoverflow.com/questions/2696519/global-temporary-table-on-commit-delete-rows-functionality-discrepancy

Wednesday, October 23, 2013

error occurred during initialization of vm could not reserve enough space for object heap

I was facing this error today where everytime I was trying to run my tomcat server in eclipse I was getting

"error occurred during initialization of vm could not reserve enough space for object heap"

It looked like a problem with the heap size VM arguments I  checked my eclipse.ini it had below correct heap size settings, Still I was getting the problem

-Xms256m
-Xmx768m
Soultion

I found that there is another place in eclipse where I had to set these VM aruguments and that was the option under

Windows-->Prefrences-->Java --> Installed JRE
I had to edit the configured JDK and add "-Xms256m -Xmx768m" to Default VM Argument.