Should you use database level constraints?

After developing few inhouse applications for the firm I work, recently I started depending upon using database level constraints. Not just the primary key, foreign key & not null thingies, even the check constraint.
As a developer you can heavily depend on database level check constraints to minimize your front end validations. For example if you have a number column where your end user must enter some numbers a simple constraint like the following would make your coding efforts simpler:
Check item_quantity > 0 and item_quantity is not null

All you have to do is to check the “Enforce data integrity” checkbox while you design the block using block wizard!
Please try it today!

Adding google ad-sense with wordpress themes and issues with Internet Explorer

If you are planning to add Google ad-sense with wordpress, be warned! Your IE would take a screw up your carefully arranged theme to a disappointing experience.

Though I had “googled” a while yet to come across a proper fix to address this issue. Anybody out there with a fix?

Oracle CSService for ASM (Automatic Storage Management) & issues with network connections.

Oracle CSService a default component installed along with 10g database. If ASM is not used (developers who has a test database installed with their laptops) you really don’t need CSService running at all from your computer.
Further more, OracleCSService as you find this service under services, could cause headache in case if something goes wrong with it.
My latest experience with oracle CSService was nowhere documented!!! My lappy was taking more 7-8 minutes to load the network connections, while many network dependent applications were crashing royally, which forced me to uninstall the drivers for network card, roll back to a particular recovery point, uninstalling antivirus and firewall…just to name few.
The event log was always showing a crash about the OracleCSService each time once after I cleared the events and restarted the lappy.
Before formatting I just thought of changing the startup behavior of OracleCSService to manual from installation default “Automatic” and BINGO. I hit the jackpot!!
So if you are dealing with Oracle and all of a sudden you come across this particular issue, make sure your OracleCSService is starting properly. On the other hand just change the startup behavior to “Manual” or even you can “Disable” it.
Please cross check with gurus before you disable the OracleCSService on a production server.
Hope this tip is useful to some out there

Oracle database 10g, Create additional database, start & access.

Scenario

OS:  Microsoft Windows XP with Service Pack 3

Oracle Database: 10g (10.1.0.2.0)

Default installation folder: D:\oracle <= You may have your oracle installation in different path. Please change accordingly

Source: http://www.adp-gmbh.ch/ora/admin/creatingdbmanually.html

(I changed few things from the literature obtained through the above mentioned link and added my own observations with below provided solution(s))

This document may not be followed for production scenarios. The main audience for this document are beginners with Oracle database technology. The author WILL not take any responsibilities for loss of data or disasters if used in production environment. However the author confirms the entire exercises provided herein with were successfully tried in at least two individual computers.

The entire exercises below are executed from Windows command prompt (start->run->cmd)

Specifying the Instance’s SID

There can be more than one Oracle instance on a single machine. In order to be able to distinguish these instances, Oracle uses a SID (System Identifier) which is a string. The SID can be set through the ORACLE_SID environment variable.

D:\oracle\product\10.1.0>set ORACLE_SID=ORA10  <=The new database you want to create

Creating an Oracle Service

On Windows, each instance requires a Windows service. This service must first be created with oradim:

D:\oracle\product\10.1.0\Db_1>oradim -new -sid %ORACLE_SID% -intpwd MYSECRETPASSWORD -startmode M

Instance created.

It can be verified that a Windows service was created by typing services.msc into the console. A service named OracleServiceORA10 (ORA10 = %ORACLE_SID%) will be found. Also, the startup type is manual as was requested by -startmode M. Oracle also created a password file under %ORACLE_HOME%\database:

D:\oracle\product\10.1.0\Db_1>dir database

Volume in drive D has no label.

Volume Serial Number is C4E9-469A

Directory of D:\oracle\product\10.1.0\Db_1\database

03/05/2005  03:54 PM    <DIR>          .

03/05/2005  03:54 PM    <DIR>          ..

03/05/2005  11:16 AM    <DIR>          archive

03/05/2005  11:13 AM            31,744 oradba.exe

03/05/2005  03:54 PM             2,560 PWDORA10.ORA

As can be seen, the SID is in the password file’s name.

Creating the initialization parameter file

When an Oracle instance starts up, it requires either an initialization paramter file (init.ora) or an SPFILE. SPFILES have binary content and must be created from init.ora files. Therefore, the init.ora file (which is an ordianary text file) is created first. Here’s a minimal init.ora (under $ORACLE_HOME/dbs if it is Unix, or %ORACLE_HOME%\database, if it is windows) just to demonstrate how the control files are found. Of course, you will add more init params into the init.ora file.

Browse to the folder D:\oracle\product\10.1.0\Db_1\database and create a new text file. Paste the following inside the newly created text file (text in green).

control_files = (d:\oracle\databases\ora10\control01.ora,

d:\oracle\databases\ora10\control02.ora,

d:\oracle\databases\ora10\control03.ora)

undo_management = auto

db_name         = ora10

db_block_size       = 8192

(This is just basic requirements for initialization parameter file)

Rename the newly created text file to “initORA10.ora” (make sure you have selected to show the common extensions from “folder options”)

The undo_management parameter is necessary if we want to use automatic undo management. Although the above seems to be the bare required minimum, you probably also want do define background_dump_dest, core_dump_dest and user_dump_dest.

Starting the instance

Now, that we have created an Oracle service and the init.ora file, we’re ready to start the instance:

D:\oracle\product\10.1.0\Db_1>sqlplus /nolog

SQL*Plus: Release 10.1.0.2.0 – Production on Sat Mar 5 16:05:15 2005

Copyright (c) 1982, 2004, Oracle.  All rights reserved.

SQL> connect sys/MYSECRETPASSWORD as sysdba

Connected to an idle instance.

SQL*Plus tells us that we’re connected to an idle instance. That means that it is not yet started. So, let’s start the instance. We have to start the instance without mounting (nomount) as there is no database we could mount at the moment.

SQL> startup nomount

ORACLE instance started.

Total System Global Area  113246208 bytes

Fixed Size                   787708 bytes

Variable Size              61864708 bytes

Database Buffers           50331648 bytes

Redo Buffers                 262144 bytes

This created the SGA (System Global Area) and the background processes.

Creating the database

We’re now ready to finally create the database:

You MUST create ‘D:\oracle\databases\ora10\’ folder manually before issuing the “create database” command. Browse to D:\oracle folder and right click to create “databases” and under “databases” you need to create the folder “ORA10”. If you ignore or fail to manually create these folders and sub folders be sure the create database command will fail miserably.

SQL>create database ora10

logfile   group 1 (’D:\oracle\databases\ora10\redo1.log’) size 10M,

group 2 (’D:\oracle\databases\ora10\redo2.log’) size 10M,

group 3 (’D:\oracle\databases\ora10\redo3.log’) size 10M

character set          WE8ISO8859P1

national character set utf8

datafile ‘D:\oracle\databases\ora10\system.dbf’

size 50M

autoextend on

next 10M maxsize unlimited

extent management local

sysaux datafile ‘D:\oracle\databases\ora10\sysaux.dbf’

size 10M

autoextend on

next 10M

maxsize unlimited

undo tablespace undo

datafile ‘D:\oracle\databases\ora10\undo.dbf’

size 10M

autoextend on

next 10M

maxsize unlimited

default temporary tablespace temp

tempfile ‘D:\oracle\databases\ora10\temp.dbf’

size 10M

autoextend on

next 10M

maxsize unlimited;

If something goes wrong with the creation, Oracle will write an error into the alert.log. The alert log is normaly found in the directory that is specified with the background_dump_dest. If this parameter was not specified (as is the case in our minimal init.ora), the alert.log will be written into %ORACLE_HOME%/RDMBS/trace. If an ORA-01031: insufficient privileges is returned, that means most likely, that the current user is not in the dba group (on unix), or the ORA_DBA (windows). If the init.ora file is not at its default location or has not been found with the pfile attribute, an ORA-01078: failure in processing system parameters and an LRM-00109: could not open parameter file ‘/appl/oracle/product/9.2.0.2/dbs/initadpdb.ora’ error is issued. The create database command also executes a file whose name is determined by the (hidden) init parameter _init_sql_file (which seems to default to sql.bsq) After the creation of the database, it can be mounted and opened for use.

Completing the DB creation

In order to complete the db creation, the following scripts must be run as sys:

%ORACLE_HOME%/rdbms/admin/catalog.sql

%ORACLE_HOME%/rdbms/admin/catproc.sql and

SQL*Plus provides a shortcut to refer to the ORACLE_HOME directory: the question mark (?). Therefore, these scripts can be called like so:

SQL> @?/rdbms/admin/catalog.sql  <= If you have multiple oracle products installed, like developer suits, database in the same machine, “?” may not point to your database installation path. Hence you could call the script like following

SQL>@D:\oracle\product\10.1.0\Db_1\rdbms\admin\catalog.sql

SQL> @?/rdbms/admin/catproc.sql  <= If you have multiple oracle products installed, like developer suits, database in the same machine, “?” may not point to your database installation path. Hence you could call the script like following

SQL>@D:\oracle\product\10.1.0\Db_1\rdbms\admin\catproc.sql

Explanations for the scripts catalog.sql and catproc.sql

catalog.sql creates the data dictionary. catproc.sql creates all structures required for PL/SQL. catalog.sql calls, for example, catexp.sql which is a requirement for exp, or dbmsstdx.sql which is a requirement to create triggers.

While executing “catproc.sql” you may notice that many errors would be thrown on the screen and it must be basically because of the limited initORA10.ora parameter files (I am not a database guy, hence I cannot authenticate my claim)

However you will see the successfully completed messages by the end of the execution of “catproc.sql”. You need to worry only if the “catproc.sql” terminates with errors.

The user system might also want to run ?/sqlplus/admin/pupbld.sql. pupbld.sql creates a table that allows to block someone from using sql plus.

SQL> connect system/manager

SQL> @?/sqlplus/admin/pupbld

Of course, tablespaces, users, tables and so on must be created according to the use of the database.

Setting up database to using java

Also call @?/javavm/install/initjvm if you want to enable the JServer option(?).

Oracle managed files

Refer also to DB_CREATE_ONLINE_LOG_DEST_n and DB_CREATE_FILE_DEST for Oracle-managed files.

Errors while creating database

If there is an error while the database is created, such as a ORA-01092: ORACLE instance terminated. Disconnection forced, the alert log should be consulted. This file most probably contains a more desriptive error message. If the error occurs at a very early stage, there won’t be an alert.log. In this case, the error will most probably be found in a trace file in udump directory.

The original document from the link mentioned on the top of this document is limited to creating a database and there is hardly any explanations which will guide a beginner to start the newly created database or access it through different oracle products (developer suit, SQL*Plus etc)

There are multiple methods to start the new database. I will stick to the easiest, one time settings so that you can forget about “forgetting” the commands and the order of issuing them in order to start your databases at later stages.

Stop the OracleServiceORA10 before you change the registry values. (eg: start->cmd->net stop OracleServiceORA10 or go to services console and stop the service)

Start regedit and browse to this particular registry key “HKEY_LOCAL_MACHINE\ SOFTTWARE\ORACLE\ KEY_OraDb10g_home1”

On your right hand side pan, you will see fresh entries for your newly created database “ORA10”

Locate the following entry “ORA_ORA10_AUTOSTART” which must have the value “FALSE”. Change this value to “TRUE”

For additional information please refer to http://www.dba-oracle.com/oracle9iAS_tips_windows_service.htm

Exit the registry editor and go to command prompt and issue the command “net start OracleServiceORA10” or go to services control panel and start the Oracle service for ORA10.

Make sure the listener service is up and running.

How to check whether the listener is up and running

Go to command prompt and issue the following command

Lsnrctl status

If any warnings or errors are shown

Issue the following command

Lsnrctl start

Now confirm you can connect to your new database

From command prompt issue “sqlplus /nolog”

Once you are provided with “SQL>” prompt

Issue the command “conn sys/mypassword@ora10 as sysdba”

If the database and listener services are up already, you must get connected to the new database immediately.

You need to add your newly created database details with TNSNAMES.ORA file in order to connect from different products.

Hope this document is useful to beginners & “somewhat” professionals :)

Computer name changes “Network path not found”!!!

Had you recently come across this problem when you try to add a computer back to your domain once after a demotion or computer name change? There could multiple reasons including your network card drivers or NIC itself. Before going for the extreme solutions like formatting and installing all your drivers and software once again, give the following tip a try:

Find another NIC and attach it with your problematic computer. Restart the PC and if your computer didn’t recognize the NIC, install the necessary drivers. (Windows XP with service pack 2 recognize most of the NIC cards, or if compatible mark them under RealTech network interface cards)
Now try to add the computer back to domain. Most cases this should solve your problem.

Using your linux live CD for recovering data from Corrupt Windows Installations

I am not yet a die-hard fan of linux. With whole of double clicking missing in almost all distros I prefer to stick to good ol` Microsoft Windows (forever unless linux comes up with double click solutions). Yet, linux would be handy when you are left with no other options other than formatting your computer & losing your business and personal data. Though linux cannot fix your Windows OS issues, a live CD could minimum help you with copying data from your dying Windows installation.

So here you go. Get a Ubuntu 8.x or Fedora live CD (the latest, the best)

Make necessary changes with your BIOS so that your computer would boot from the live CD next time when you restart it.

If you are going to use ubuntu desktop distro 8.x (I would recommend it because of the NTFS support built into it) just select the language and select the option “Do not modify…” and wait until the ubuntu’s clean interface loads into your computer’s memory completely.

Then point your mouse to “Applications->Accessories->Terminal” to launch a terminal window

Next three simple commands (regardless whether you do understand what those commands do, still you are going to recover (possible) data from your unbootable hard drive!!!)

Please refer the image attached below

linux command set for mounting NTFS volume

linux command set for mounting NTFS volume


The first command "sudo /sbin/fdisk -l" shows you all the fixed disk volumes (partitions) and the partition with * should be your boot volume.The second command "sudo mount /dev/sda1 /mnt" mounts your NTFS volume to folder /mnt
Now you can easily change your folder focus using command "cd /mnt" and issues the last command in the set "ls" to view the content of the partition you have just mounted.

You can use the file browser application with Ubuntu to graphically dispaly the contents. Now using an external storage device you can easily start copying/moving files from “/mnt” & sub folders.

Fix your problems with one-touch buttons (HP 6510b laptops)

HP 6510b One-touch buttons

You may run into a quite frustrating situation with your HP 6510b laptops once after a factory reset has done. All of a sudden you will find the one-touch buttons (Wireless, presentation, sound controls etc) not responding to the “soft” touches.

Here is the solution (as suggested by HP Chat service support)

Shutdown your computer

Remove the battery from the system along with all other external devices (flash drives, usb mass storage devices etc)

Keep pressing down the power button for nearly 10 seconds and leave the laptop for next 5 minutes time to discharge all the electricity it has.

Put the battery back in and turn on the machine. This must had solved your issues with the one-touch buttons already.

Without this tip in place, I had tried to recover the machine four times in a row…so give it a try :)

FileMyster, A neat and free tool for synching your folders

FileMyster, developed by www.bateel-software.com could be one of the best free software tools you could always keep for synchronizing your folders. Say you have a folder with music files and you have a backup drive on which periodically copy them to address a disaster situation. Regardless whether you want to synchronize your music, images or business data, FileMyster could do it for you automatically. All you have to do is to tell how you need to sync your files. Download it from here http://www.bateel-software.com/software.html

This tool which is less than 1 mb in download size could, not only synchronize your folders, your network servers as well. Just set up the filemyster service (only on Windows) and press the go button. You can set up intervals, file types, exclusion lists…and name what else you want from a free software, it is there. Hope you would enjoy using this free tool from today onwards.

Fix TCP/IP and Winsock errors

You could run into problems with your TCP/IP protocol (not usually) and Windows doesn’t allow you to uninstall this mandatory protocol through add remove control panel or from the network property page. The same goes with winsock also.

Here are the procedures to fix TCP/IP and winsock errors:

open “cmd” & type “netsh int ip reset c:\resetiplog.txt” (without quotes). The text file resetiplog will have an entire log of changes, fixes windows does to fix the errors.

Once the command successfully completes, then:

from “cmd” issue this command “netsh winsock reset”. You must restart the computer so that the fixes are applied.

Installing Oracle database on domain member servers (10g onwards)

There would be alternative methods, of which I am not aware of. I found a way to install oracle 10g onwards databases on domain member server(s) accidently. It is as simple as following:

Log on to your domain member server (eg: oracle.abc.com) as local administrator.

Start the installation & and it must be successful without throwing errors starting from CSS services failing to install or start when you try to install the oracle database using domain admin or domain administrator credentials.

Tested and confirmed platform: Windows 2003 native mode

Additional tips: Never ever try to install Oracle database on your Domain Controller

Try to avoid complex passwords for the sys,system accounts (if you are doing a default installation). I failed to install Oracle 10g database with passwords like abc123, abc!123 when abcdefgh, klazksk worked perfect.