PMD for Salesforce Code Check

PMD is a source code analyzer. It finds common programming flaws like unused variables, empty catch blocks, unnecessary object creation, and so forth. It supports Java, JavaScript, Salesforce.com Apex and Visualforce, PLSQL, Apache Velocity, XML, XSL.
Additionally it includes CPD, the copy-paste-detector. CPD finds duplicated code in Java, C, C++, C#, Groovy, PHP, Ruby, Fortran, JavaScript, PLSQL, Apache Velocity, Scala, Objective C, Matlab, Python, Go, Swift and Salesforce.com Apex and Visualforce.

Please note, that this module requires a Java 8 runtime environment.

Use link – https://dl.bintray.com/pmd/pmd-eclipse-plugin/updates/
to install PMD Software in eclipse from Help->Install New Software->Add Repository.

After installation Just right click on your project and select ‘Check Code‘ in PMD
You can generate PMD report which create Report folder in your project location.

Advertisements

INSERT … ON DUPLICATE KEY UPDATE Syntax

If you specify ON DUPLICATE KEY UPDATE, and a row is inserted that would cause a duplicate value in a UNIQUE index or PRIMARY KEY, an UPDATE of the old row is performed. For example, if column a is declared as UNIQUE and contains the value 1, the following two statements have identical effect:

INSERT INTO table (a,b,c) VALUES (1,2,3)
ON DUPLICATE KEY UPDATE c=c+1;

UPDATE table SET c=c+1 WHERE a=1;

The ON DUPLICATE KEY UPDATE clause can contain multiple column assignments, separated by commas.

With ON DUPLICATE KEY UPDATE, the affected-rows value per row is 1 if the row is inserted as a new row, and 2 if an existing row is updated.

INSERT INTO table (a,b,c) VALUES (1,2,3),(4,5,6)
ON DUPLICATE KEY UPDATE c=VALUES(a)+VALUES(b);

That statement is identical to the following two statements:

INSERT INTO table (a,b,c) VALUES (1,2,3)
ON DUPLICATE KEY UPDATE c=3;
INSERT INTO table (a,b,c) VALUES (4,5,6)
ON DUPLICATE KEY UPDATE c=9;

Importing Database in MySQL from a sql dump file

First create a dump or .sql file of the database you want to take back up of. Then transfer it to the computer on which you want to import the data (if the file is not on that computer). Now follow these steps:

Open terminal and then do the following:

1.Login to MySQL as root:

mysql -u root -p;


2.Then create a database, say dbname using:

create database dbname;

3.Use the database created:

use dbname;

4.Import the MySQL dump file:

source pathofsqlfile.sql

Here pathofsqlfile.sql is the absolute path of the sql dump file (you can also give relative path if the sql dump file is in mysql directory itself)

MySQL – technical definition

A very popular open source, relational DBMS for both Web and embedded applications from MySQL AB, Uppsala, Sweden (www.mysql.com), which was acquired by Sun in 2008. Pronounced “my S-Q-L,” it runs under Linux/Unix, Windows and Mac. The free MySQL Community Edition is available under the GNU license, and more than 100 million copies have been downloaded worldwide. MySQL Enterprise is the more comprehensive, paid version.

Extensive Language Support
Applications using MySQL are written in PHP, Perl, Python, Ruby, Java, C/C++, C# and Visual Basic. The MySQL programming interface (API) is a superset of the C language API for mSQL, which was developed by David Hughes in 1994.