Pages

Different types of objects | ORACLE

There are different types of objects in oracle database. Normally what happens is that you create a schema and then compile your object scripts which will create the objects like tables, procesures, packages, links, synonyms, views etc.
When there is change in the codebase, you could just simply compile the scripts. This could miss something time and again and you will have problem in the production. What I prefer is to delete all the objects, ie clean the schema and then compile it and do the processing.

Here is a simple script/query in oracle which will generate queries to delete different objects in oracle.

select drop_objects from (
 SELECT 
  CASE object_type WHEN 'TABLE' THEN 'DROP table '||object_name||' CASCADE CONSTRAINTS;'
  WHEN 'VIEW' THEN 'DROP VIEW '||object_name||';'
  WHEN 'SEQUENCE' THEN 'DROP SEQUENCE '||object_name||';' 
  WHEN 'SYNONYM' THEN 'DROP SYNONYM '||object_name||';'
  WHEN 'FUNCTION' THEN 'DROP FUNCTION '||object_name||';'
  WHEN 'PROCEDURE' THEN 'DROP PROCEDURE '||object_name||';'
  WHEN 'PACKAGE' THEN 'DROP PACKAGE '||object_name||';'
  WHEN 'PACKAGE BODY' THEN 'DROP PACKAGE BODY '||object_name||';'
  WHEN 'TYPE' THEN 'DROP TYPE '||object_name||';'
  WHEN 'TYPE BODY' THEN 'DROP TYPE BODY '||object_name||';'
  WHEN 'MATERIALIZED VIEW' THEN 'DROP MATERIALIZED VIEW '||object_name||';' 
  END drop_objects
 FROM USER_objects
) 
where 1=1
 and drop_objects is not null
;

Screen, do your work in the background | linux

For computer programmers, working remotely with Putty through ssh connections is pretty common. Normally, what we do is that we connect to putty to a remote linux (or windows(cygwin)) server, hit some commands to do some instantaneous work. But the problem may arise when we hit a long running command. For example, you connect to oracle user and start using the sqlplus in oracle. You have a long running engine to run in oracle. Suppose it takes two hours, and after one hour of running of the procedure, the network connection is our for a few minutes. What happens is that you session will be destroyed and the process will be in undetermined state.

Now the solution.

What you could have done is that you could have run your process in the background, independent of the active ssh session. You could do that with VNC or other technologies but I am going to talk about screen here.

You should have screen installed on your server. There are different commands to install screen on different versions of linux.
What screen does is generate a background session where your actual work is done, and it is independent of the ssh sessions.
The concept of screen is to create a session, attach to a screen session, and detach from a screen session.

1) Start a screen session
screen -S <new_session_name>
2) See the list of Active Screen sessions
screen -ls or -list
3) To reattach to a detached screen session
screen -r <existing_session_name>
4) To detach an attached screen session
for another remote user
screen -d <session_name
detach from ones screen and get out of screen
CTRL + a + d
5) To attach a screen session that someone else is attached.
screen -dr <session_name>


6) How do i know if i am in a screen session
echo $STY 


If the above commands outputs any value, then you are in a screen session. If the output is empty, you are not in a screen session.


Or if you simply press the backspace button for a long time the screen starts flickering in white color, if you are in a screen session


7) How do I kill a screen session

screen -X -S [session # you want to kill] quit

Thats it.

How to Disable images in Google Chrome Browser

Disabling the images, not only loads the images faster, it also saves your bandwidth. So it is very useful especially when you are in a limited data plan. In most of the browsers, it is straight forward but for chrome it is little bit tricky to find the image settings location itself.

Here's what I did to disable images in my browser.


  • Click on and go to the settings.
  • Click the link which says "show advanced settings"
  • Under the Privacy title, click on the area which says "Content Settings..."
  • Now you could actually see the image settings location. Click on "Do not show images" radio button to disable the images on your browser.

Excel | How to create a drop down list on a cell

Every time I try to do this, I got stuck for a few minutes trying to remember from where to do it. For example i want to create a list of tasks and their corresponding statuses like (Not started, In progress, Completed, Accepted) etc. So this is how it is done.

One line solution

  • Go to the data validation section. Choose type = List and then provide a list of values you want to appear in the drop down separated by comma.
Well, for me one line solution will do. So I am skipping the multiple lines solution. May be you could figure it out yourself.

An application to check the validity of email address

I was stuck with a problem to verify whether an email address has the proper format of an email address or not. I came up with an application which you could just save in your computer , open in a browser and test the string whether it is a valid email address or not.

Here is the application itself.


Validation Check






Enter an email addresses.
Emails:






The code that made it possible is this one.
<!DOCTYPE html>
<html>
<head>
 <title>Validation Check</title>

 <script type="text/javascript"  >  
  function validateRandom() { 
   //var value = $('#emails').val();;
   var value = document.getElementById("emails").value;
   //alert(value);
   //var re = new RegExp("pattern");
   var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
   
   if( re.test(value) ){
    alert('The text is a valid email address, in terms of its pattern');
   }else{
    alert('The pattern of the text do not match as a valid email address.');
   }
   return false;
  } 
 </script>

</head>
<body>

Enter an email addresses.
<form method = "post" id="email_form" >
 Emails:<br/>
 <input name="emails" id="emails" value = 'rajan'/><br/>
 <button type="submit" name="email_form_submit" onclick="return validateRandom()">Submit</button>
</form>

</body>
</html>