pinoydba.com
Home | Blogs | About Me | Contact Me | Profile | Store | Disclaimer

Welcome!

What is Pinoy? It's a slang for Filipino, a person who comes from the Republic of the Philippines, or commonly known as the Philippine Islands. I am a Filipino and works as an Oracle DBA in the United States. Whenever an issue arises or just for experiments, I usually forget what I did to solve/conduct them. There must be a central location where I can put everything. Thus, pinoyoracledba.com was born. It's a collection of ideas, tips and tricks, scripts, or anything interesting that happened to me on an Oracle database.

The simpler, the better! has always been my motto. You don't have to complicate things. Simple things, for me, is always easier, just like my site.

FYI, anything that is written here is based on my personal experiences and is not endorsed by any other party. Also, I will not be held liable for issues that can arise by following whatever I did. Just like any other good DBA would say... ALWAYS TEST!

Hope you can find this site helpful in whatever you need and remember, I am not a guru in Oracle.

Blogs

Adding a Core in SOLR
2010-06-24 12:25:09

For users to search our site, we implemented SOLR. It's a multi-core environment and I was tasked with adding another core in the same directory as the other cores. Let's just say they are in /solr/cores. The new core will have the same fields as one of the others except with a little twist.Considering that I was a newbie with this software, here's what I did:

  • Created a new core (core2) directory with conf and data subdirectories
% mkdir /solr/cores/core2
% mkdir /solr/cores/core2/conf
% mkdir /solr/cores/core2/data
  • Copied all the files from core1
% cp /solr/cores/core1/conf/* /solr/cores/core2/conf
  • Modified the /solr/cores/core2/conf/data-config.xml accordingly
  • Modified the /solr/cores/core2/conf/solrconfig.xml by changing the <dataDir> value to where we want the data to live
<dataDir>${solr.data.dir:/solr/cores/core2/data}</dataDir>
  • Modified the /solr/solr.xml (the global config file for SOLR) and added the new core
<core name="new_reqs" instanceDir="/export/home/webdev/solr/core2/"/>
  • Restarted tomcat. This is what we used with SOLR.
  • Make SOLR aware of the new core using the browser

http://localhost:8983/solr/admin/cores?action=CREATE&name=new_reqs&instanceDir=/solr/cores/core2

After doing all that, we tried querying the index from the SOLR admin and of course, nothing was being returned. One of the programmers created a mini-program that would insert into the SOLR index. Querying it afterwards returned results.

Nested table in Oracle
2010-06-08 11:56:55

I was tasked with researching on how nested tables work in Oracle 10gR2. After reading documents and doing some tests, here are the basic command to create a nested table. Let's say I would like to store all the employees in each department (no actual design involved). The table that I will be creating will have the following columns:

  • department name
  • employee list
where the employee list is actually a table. First, I created a type object that will hold the employees first and last names:
SQL> create type emp_obj as object
  2  (first_name varchar2(50),
  3  last_name varchar2(50));
  4  /
Type created.
Then I created a table that will hold the emp_obj type:
SQL> create type emp_obj_tab is table of emp_obj;
  2  /
Type created.
 Then, I created the actual table:
SQL> create table emp_tab (
  2  dept_name varchar2(50),
  3  emp_list emp_obj_tab
  4  ) nested table emp_list store as emp_list_tab
  5  /
Table created.
The "nested table" clause indicates that the emp_list is a physical table with the name emp_list_tab. Now, insert into the table:
SQL> insert into emp_tab values ('I.T.',emp_obj_tab(emp_obj('JOHN','DOE')));
1 row created.
SQL> commit;
Commit complete.
Let's select from the table:
SQL> select et.dept_name, el.first_name, el.last_name
  2  from emp_tab et, table(et.emp_list) el
  3  order by el.first_name
  4  /
DEPT_ FIRST_NAME           LAST_NAME
----- -------------------- --------------------
I.T.  JOHN                 DOE
To insert another employee in the table under the I.T. dept:
SQL> insert into table(select emp_list from emp_tab where dept_name = 'I.T.')
  2  values ('JOE','SMIHT');
1 row created.
SQL> commit;
Commit complete.
To update the employee name (as in this case, SMITH was spelled):
SQL> update table(select emp_list from emp_tab where dept_name = 'I.T.')
  2  set last_name = 'SMITH'
  3  where first_name = 'JOE'
  4  and last_name = 'SMIHT';
1 row updated.
SQL> commit;
Commit complete.
SQL> select et.dept_name, el.first_name, el.last_name
  2  from emp_tab et, table(et.emp_list) el
  3  order by el.first_name
  4  /
DEPT_ FIRST_NAME           LAST_NAME
----- -------------------- --------------------
I.T.  JOE                  SMITH
I.T.  JOHN                 DOE
To delete an employee:
SQL> delete from table(select emp_list from emp_tab where dept_name = 'I.T.')
  2  where first_name = 'JOHN' and last_name = 'DOE';
1 row deleted.
SQL> commit;
Commit complete.
SQL> select et.dept_name, el.first_name, el.last_name
  2  from emp_tab et, table(et.emp_list) el
  3  order by el.first_name
  4  /
DEPT_ FIRST_NAME           LAST_NAME
----- -------------------- --------------------
I.T.  JOE                  SMITH
Hope this helps.

Out of Resources in MySQL
2010-06-08 11:29:21

One of our sister companies called me today asking if I know anything about the error that they are encountering, which is:

ERROR 23 (HY000): Out of resources when opening file (Errcode: 24)
Looking at the error, it looks like it's a database parameter value. Researching it, my hunch was correct. The parameter open_files_limit need to be changed to resolve the issue. So, I changed the value of the parameter in the /etc/my.cnf file and restarted the database.
See full list
affiliate_link
TigerDirect
Home | Blogs | About Me | Contact Me | Profile | Store | Disclaimer