Wednesday, December 9, 2009
Wednesday, December 2, 2009
Monday, November 30, 2009
notes from learning mysql stored procedures
Stored procedures advantages
Stored procedure increases performance of application. Once created, stored procedure is compiled and stored in the database catalog. It runs faster than uncompiled SQL commands which are sent from application.
Stored procedure reduced the traffic between application and database server because instead of sending multiple uncompiled long SQL commands statement, application only has to send the stored procedure name and get the result back.
Stored procedure is reusable and transparent to any application which wants to use it. Stored procedure exposes the database interface to all applications so developer doesn’t have to program the functions which are already supported instored procedure in all programs.
Stored procedure is secured. Database administrator can grant the right to application which to access which stored procedures in database catalog without granting any permission on the underlying database table.
Beside those advantages, stored procedure still has its own disadvantages which are bellow
Stored procedures disadvantages
Stored procedure make the database server high load in both memory for and processors. Instead of being focused on the storing and retrieving data, you could be asking thedatabase server to perform a number of logical operations or a complex of business logic which is not the role of it.
Stored procedure only contains declarative SQL so it is very difficult to write a procedure with complexity of business like other languages in application layer such as Java, C#, C++…
You cannot debug stored procedure in almost RDMBSs and in MySQL also. There are some workarounds on this problem but it still not good enough to do so.
Writing and maintain stored procedure usually required specialized skill set that not all developers possess. This introduced the problem in both application development and maintain phrase.
this is how a stored procedure is called -DELIMITER // - changes the delimiter to //
CREATE PROCEDURE GetAllProducts() -GetAllProducts()is the name of the stored procedure.BEGIN - tells the start of the procedure's workings
SELECT * FROM products; - the actual procedure
END //- changes the delimiter to //and tells the end of the procedureDELIMITER ; - changes back the delimiter to a semicolon
CALL STORED_PROCEDURE_NAME()
a variable is instantiated in a stored procedure this way: declare variable_name data type(size) default value. eg declare totalProducts int default 0
multiple variables with the same data type can be declared together. eg. declare x, y int default 0
there are two ways to assign values to variables:
1 - using the set keyword - set totalProducts = 39;
2 - using select... into - select count(*) into totalProducts from products
variables have scopes which determine their life span.
variables with an @ are session variables and have a life span until the end of the session.
variables have modes: in, out, inout
to be continued
blackbery security
do you see a problem with that? i do. if my phone gets stolen or lost, all someone will have to do is to enter the incorrect password 10times or the maximum amount of times and then they would be able to use the phone. i thought the phone would be locked but alas, thats not the case. so if this information gets into the hands of some people, it would be detrimental to alot of others in the bb world :)
Friday, November 27, 2009
Zend Studio opens with no menu
Symptoms
When running Zend Studio:
1. The ZS's main window comes up totally empty.
2. Sometimes the window has some of the frames painted, but the rest of the window is empty.
3. In the empty ZS window the mouse cursor is changing while moving around the window (as if there are objects: like buttons and other objects).
4. There were erratic mouse/window movements reported.
Summary
Zend Studio starts up with various windowing GUI problems in some linux distros, while using the XGL-Compiz/Beryl product.
Cause
1. Incompatibility between the XGL environment, the JRE, and the Zend Studio Client.
2. The decoration in the 3D environment clashes with the Java Runtime and distorts the operation and visualization of the Zend Studio client's window.
Workaround
There are two ways to execute Zend Studio, by running the ZDE script, and by running the runStudio_unix.sh script, both are in the bin directory of zend studio
(usually /usr/local/Zend/ZendStudio-/bin)
The following workarounds may be used, but there is no guarantee how well or how long it might work for you in your environment.
modification of ZDE script for xgl:
1. Open your ZDE script with your favorite editor
2. add the next line of code at line 1693.
options="$options -Dawt.toolkit=sun.awt.motif.MToolkit"
for example:
1693:
1694: debugOut ""
1695: unset POSIXLY_CORRECT
1696: if [ $DO_NOT_FORK ]
becomes:
1693: options="$options -Dawt.toolkit=sun.awt.motif.MToolkit"
1694: debugOut ""
1695: unset POSIXLY_CORRECT
1696: if [ $DO_NOT_FORK ]
3. Save the file.
modification of runStudio_unix.sh script for xgl:
1. open the the file in your favorite editor.
2. modify the java execution line,
the line starts with: ../jre/bin/java -Xms16m -Xmx256m -cp...
change it to: ../jre/bin/java -Dawt.toolkit=sun.awt.motif.MToolkit -Xms16m -Xmx256m -cp...
^^^^^^^^^^^^^^^^^^^^^^^^^^
as you can see, the only difference is an extra parameter to the java program.
3. Save the file.
Another solution
the AWT_TOOLKIT environment variable can be set in order for Java to choose a working AWT Toolkit.
export AWT_TOOLKIT="MToolkit"
In most Linux Distributions it's enough to append this line to /etc/profile.
Older Girls Party
Wednesday, November 25, 2009
gimp save for web plugin
for ubuntu users, download the Ubuntu deb archive of 0.28.4 file.
Monday, November 23, 2009
Clear textarea default value
onfocus="if(this.value==this.defaultValue){this.value='';}" onblur="if(this.value==''){this.value=this.defaultValue;}"
Thursday, November 19, 2009
Wednesday, November 18, 2009
p4a alphabet sorter with text search
function textSearchWithcreateAlphabeticalSorter(){
$alphabet_array = array();
$alphabet_array[] = 'A';
$alphabet_array[] = 'B';
$alphabet_array[] = 'C';
$alphabet_array[] = 'D';
$alphabet_array[] = 'E';
$alphabet_array[] = 'F';
$alphabet_array[] = 'G';
$alphabet_array[] = 'H';
$alphabet_array[] = 'I';
$alphabet_array[] = 'J';
$alphabet_array[] = 'K';
$alphabet_array[] = 'L';
$alphabet_array[] = 'M';
$alphabet_array[] = 'N';
$alphabet_array[] = 'O';
$alphabet_array[] = 'P';
$alphabet_array[] = 'Q';
$alphabet_array[] = 'R';
$alphabet_array[] = 'S';
$alphabet_array[] = 'T';
$alphabet_array[] = 'U';
$alphabet_array[] = 'V';
$alphabet_array[] = 'W';
$alphabet_array[] = 'X';
$alphabet_array[] = 'Y';
$alphabet_array[] = 'Z';
$frmeAlphabet = & $this->build('p4a_frame', 'frmeAlphabet');
$name = & $this->build('p4a_field', 'txtName');
$name->setLabel('Horse Name');
$name->addAction('onReturnPress');
$this->intercept($name, "onReturnPress", "searchHorses");
foreach ($alphabet_array as $letter){
//echo $letter;
//echo 'btn'.$letter;exit;
$btn = & $this->build('p4a_button', 'btn'.$letter);
$btn->setLabel($letter);
$btn->setValue($letter);
$btn->setBgcolor('white');
$btn->setStyleProperty('border', '0');
$frmeAlphabet->anchorLeft($btn);
//$btn->addAction('onClick');
$this->intercept($btn, 'onClick', 'sortBySelectedButtonValue');
}
$frmeMain = & $this->build('p4a_frame', 'frmeMain');
$frmeMain->anchor($name);
$frmeMain->anchor($frmeAlphabet);
return $frmeMain;
}
function searchHorses(){
$horse_name = & $this->txtName->getNewValue();
$where = " 0=0 and horse_name like '%$horse_name%'";
$this->horseSrc->setWhere($where);
}
function sortBySelectedButtonValue($letter){
//echo $letter->getValue();
$selectedLetter = $letter->getValue();
//echo $this->getActiveObject();exit;
//$query = "select * from horses where 0=0 and horse_name like '$selectedLetter%'";
$where = "0=0 and horse_name like '$selectedLetter%'";
//$this->horseSrc->setQuery($query);
$this->horseSrc->setWhere($where);
//$this->horseSrc->setWhere($query);
}
