Credits

Monday, August 29, 2011

School Fairs and More

The city of General Santos and its neighboring municipalities and cities celebrate various festivals including founding anniversaries. As I type, we have the week long celebration  of Tuna Festival to run until September 5 and every one could only appreciate the holidays but more importantly, different activities are held including exhibits, trainings, and job fairs.

While most job fairs are limiting, we  can only be lucky that various jobs are available including  Materials Manager Jobs  for try and luck.

Job competitions can be quite stiff but with the right job materials, skills, and intrinsic motivation, you too can be employed in your ideal job.

SQL’S Update and Delete Stored Procedures

In my previous post, we have created an INSERT  stored procedure to allow us entry of new record without using the normal way of adding records to our table.

We can also create update and delete stored procedures while embedding our SQL commands to do the usual works.

To call these procedures, we type:
CALL proc_customers_DELETE_byPK(1001)  // to delete customer number 1001

CALL proc_customer_UPDATE_byPK(1000,'new@gmail.com')  // to change the old email address of customer number 1000

[+/-] show/hide

/* stored procedure to update */
DELIMITER $$

DROP PROCEDURE IF EXISTS `momsdb`.`proc_customer_UPDATE_byPK` $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `proc_customer_UPDATE_byPK`(in p_customer_number int(11),in p_email varchar(50))
BEGIN
UPDATE customers
SET
email=p_email
WHERE customer_number = p_customer_number;

END $$

DELIMITER ;

/*stored procedure to delete */

DELIMITER $$

DROP PROCEDURE IF EXISTS `momsdb`.`proc_customers_DELETE_byPK` $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `proc_customers_DELETE_byPK`(in p_customer_number int(11))
BEGIN
DELETE FROM customers
WHERE customer_number = p_customer_number;
END $$

DELIMITER ;

When Students Make Business

Schooling is never cheap especially if students want quality education from a good - reputable school. Thus, it is not surprising that students make ends meet in different ways and that include making business of different sorts. Some sell different stuffs including gadgets while others simply sell services including computer repairs or school paper writings among others.

But, one caught my attention is seeing students customizing cars and bikes including paint jobs and  verde custom wheels   among others  for business.

Working students are to be praised because they prefer to work to support their schooling than taking the easy route. While it may be harder to manage their time, I guess their priorities can make anything possible.

SQL's Stored Procedure Plus More

When we were taught to write stored procedures in command prompt, I simply had harder time writing and editing. So, good thing that MySQL 5.0 supports stored procedure.


Creating a stored procedure requires that we call our database, thus, to call a table CUSTOMER to allow new record, we write:
/* the database for required table */
USE MOMSDB

/* to call our stored procedure procedure with the new record*/
CALL proc_customer_INSERT_byPK(103,'CHRISTY','christy@gmail.com','Calumpang','0912-345-2345')

 /* the codes inside our stored procedure*/
DELIMITER $$

DROP PROCEDURE IF EXISTS `momsdb`.`proc_customer_INSERT_byPK` $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `proc_customer_INSERT_byPK`(
in p_customer_number int(11),
in p_name text,
in p_email varchar(50),
in p_shipping_address text,
in p_phone_number text)
BEGIN
INSERT INTO customers
(customer_number,
name,
email,
shipping_address,
phone_number
)
VALUES
(
p_customer_number ,
p_name ,
p_email ,
p_shipping_address ,
p_phone_number
);


END $$

DELIMITER ;

SQL’S Stored Procedure


A stored procedure, by definition, is a segment of declarative SQL code which is stored in the database catalog and can be invoked later by a program, a trigger or even a stored procedure.

You can create stored procedures in command line window or at least in MySQL 5.0 as earlier versions don't support stored procedures or triggers. You can even create stored procedures in MySQLyog for easy writing.

Below are excerpts of stored procedure's advantages and disadvantages along with its syntax and sample.

Stored Procedures Advantages
  • Stored procedure increases performance of application.
  • Stored procedure reduced the traffic between application and database server
  • Stored procedure is reusable and transparent to any application.
  • Stored procedure is secured.

Stored Procedures Disadvantages
  • Stored procedures make the database server high load in both memory for and processors.
  • Stored procedure only contains declarative SQL so it is very difficult to write a procedure with complexity of business logic like other languages in application layer such as Java, C#, C++…
  • You cannot debug stored procedure in almost RDMBSs and in MySQL also.
  • Writing and maintaining stored procedure usually required specialized skill set that not all developers possess.

[+/-] show/hide


MySQL Stored Procedures
The syntax for using Stored Procedures is as follows:

CREATE

[DEFINER = { user | CURRENT_USER }]
PROCEDURE sp_name ([proc_parameter[,...]])
[characteristic ...] routine_body

CREATE
[DEFINER = { user | CURRENT_USER }]
FUNCTION sp_name ([func_parameter[,...]])
RETURNS type
[characteristic ...] routine_body

proc_parameter:
[ IN | OUT | INOUT ] param_name type

func_parameter:
param_name type

type:
Any valid MySQL data type

characteristic:
LANGUAGE SQL
| [NOT] DETERMINISTIC
| { CONTAINS SQL | NO SQL | READS SQL DATA | MODIFIES SQL DATA }
| SQL SECURITY { DEFINER | INVOKER }
| COMMENT 'string'

routine_body:
Valid SQL procedure statement
Writing the first stored procedure
The first stored procedure is very simple. It retrieves all products from products table. First let’s take a look at the stored procedure simple source code below:

1 DELIMITER //
2 CREATE PROCEDURE GetAllProducts()
3 BEGIN
4 SELECT * FROM products;
5 END //
6 DELIMITER ;

Saturday, August 13, 2011

Invest on Technology as Learning Media

Technology is undeniably helping teachers, students and everyone else to do almost everything. For one, programming becomes easier  because computers and software are around to make the task done. And with different variants of computer technology that includes mainframes, laptops, notebooks, netbooks and PDA's, the general public can only consider their budget and  requirements and search the market for a more appropriate technology choice.

With the decreasing prices of computer technology, we can find portals of computers for sale at way low cost. Thus, if your questions include,   where can I find discount desktops   among others, you bet, you can search the net and you can be lucky enough to find the best buy. 

So, invest on technology because learning is beyond any price tags.

Benefits of Educational Tour

Our graduate school professor recently announced to our class that he would set up an educational tour to another region as part of his subject requirements.  While we dread already of  the possible expenses, we can only be excited too as we shall take a different kind of learning from the field exposure.

Further, the tour shall help us relaxed from all the juggle and hurdles of work and family obligations. More importantly, we shall see new places, experience new culture and traditions and see tourist spots in other areas.

While the financial constraint can be ignored, we can only start saving for the anticipated tour.

SQL's Join Command

One of the handy and useful implementation of SQL commands  is the use of JOIN to connect several tables to filter queries among others.

For instance, we can select records that comply a certain condition and connecting two tables at least can only be made possible through the use of JOIN. Take the example below excerpted from http://www.1keydata.com/sql/sqljoins.html :

SELECT  A1.region_name REGION, SUM(A2.Sales) SALES
FROM Geography A1, Store_Information A2
WHERE A1.store_name = A2.store_name
GROUP BY A1.region_name



TableStore_Information
store_name Sales Date
Los Angeles $1500 Jan-05-1999
San Diego $250 Jan-07-1999
Los Angeles $300 Jan-08-1999
Boston $700 Jan-08-1999
Table Geography
region_name store_name
East Boston
East New York
West Los Angeles
West San Diego
Result:
REGION   SALES
East   $700
West   $2050
We can also use inner join in the given example and we can write it as: SELECT  A1.region_name REGION, SUM(A2.Sales) SALES FROM Geography A1 inner join Store_Information A2 on  A1.store_name = A2.store_name GROUP BY A1.region_name

Wednesday, August 10, 2011

When Students Marry

I have been teaching in college for over a decade and I have seen various students of different stature and conditions and one thing that alarms most schools and teachers is the fact that there are students who marry unexpectedly while in school.  Thus, it is not surprising that they come to us with their wedding invitations and  diamond rings   to boot.


While other students tend to adjust faster with their role transitions, others simply stop and prefer to stay at home and remain a housewife or a househusband.


While it excites us that students have their legal partners, it saddens us too that they experience marriage life faster than they should. But, we can only hope that they can both succeed in school and in their personal life.

User - Level Access in Java



Main program with deactivated File and Reports and shortcut buttons for common user access only.

login form for user - type "User/Administrator"

It is  possible to have user - level access in Java.Depending on the user type whether he is an ordinary  user or administrator would tell the level access.

For an ordinary user, he can only access transactions where for this instance of a business application, sales, expenses and payments are only the options allowed.

This kind of operation requires us to deactivate menu items or shortcut buttons. The program below illustrates this example.

[+/-] show/hide



/** Creates new form MainProgram */
public MainProgram(String xusername,String xusertype) {
initComponents();
this.username=xusername;
this.usertype=xusertype;
MainProgramStatus(); //to de/activate menu options
lblusername.setText(this.username);
setExtendedState(JFrame.MAXIMIZED_BOTH);


}
:
:

public void MainProgramStatus(){
//to activate / deactivate menu options for user type
if (usertype.equals("User"))
{ mFile.setEnabled(false);
mReports.setEnabled(false);
jButton1.setEnabled(false);
jButton4.setEnabled(false);}
else
{
mFile.setEnabled(true);
mReports.setEnabled(true);
jButton1.setEnabled(true);
jButton4.setEnabled(true);}
}

Tuesday, August 9, 2011

Frenzy Teacher

Lately, I somehow manage to do all my tasks after going through difficult times of juggling my programming works for masteral requirements, coping with make - up classes, preparing for lectures and recording papers. 

But, since I have a scheduled trip again next week to attend to our business ventures, I  have to deal with my make - up classes again among other tasks. Good thing though, I am done with my masteral projects and my second masteral professor is lenient with us.

I can only hope that I can make through all my obligations without much fuss and difficulty.  Exams are due next week, so, papers are expected to pile up.