Complete IT Professional http://www.completeitprofessional.com Helping Software Developers Get Ahead In Their Careers Thu, 26 Mar 2015 11:00:19 +0000 en-US hourly 1 http://wordpress.org/?v=4.1.1 Oracle TRUNC Function Explained with Exampleshttp://www.completeitprofessional.com/oracle-trunc/ http://www.completeitprofessional.com/oracle-trunc/#comments Thu, 26 Mar 2015 11:00:19 +0000 http://www.completeitprofessional.com/?p=3371 ]]> Oracle TRUNC FunctionThe TRUNC function is one of the most common and versatile functions in Oracle. Let’s take a look at how it’s used and some examples.

Purpose of the Oracle TRUNC Function

The purpose of the Oracle TRUNC function is to truncate either a number or a date value.

The TRUNC function works on two different data types – number or date. This means you can provide it with either of these two data types, and the TRUNC function will perform slightly differently and give you a result for that data type.

If you supply it a date data type, then it will return the portion of that value as specified by your format model. If you supply it a numeric data type, it will round the number to the specified number of decimal places.

Let’s take a look at how this is used.

 

Syntax

The syntax of the TRUNC function is slightly different, depending on which data format you’re supplying. In both cases, there are two parameters.

Using a date value, the syntax is:

TRUNC( date, fmt )

Using a number, the syntax is:

TRUNC( number, decimals )

Let’s take a look at the parameters for this function.

 

Parameters

The parameters of the Oracle TRUNC function for dates are:

  • date (mandatory): This is the date or datetime value that is to be truncated or reduced to.
  • fmt (optional): This is the format that the date value is to be truncated to. If it is not specified, then the function will truncate the date value to the nearest day. See below for the valid format parameters that can be used.

The parameters of the Oracle TRUNC function for numbers are:

  • number (mandatory): This is the numeric value that is to be truncated.
  • decimals (optional): This is the number of places to the left or right of the decimal point to truncate the number value. If it is positive, digits to the right are truncated, and if it is negative, digits to the left are truncated. If it is omitted, number is then truncated to a whole number (0 decimal places).

If you use the date version of the TRUNC function, then the value returned is always of datatype date, even if you use a different datetime datatype as the parameter.

If you use the number version of the TRUNC function, then the returned value is the same as the number parameter if you don’t specify the decimals. If you do specify the decimals, then it returns a data type of NUMBER.

 

Available Formats for Date TRUNC

These are the available format values for using the TRUNC function on dates. You can specify these as part of the second parameter when using the TRUNC function on dates.

UnitValid Format Parameters
YearSYYYY, YYYY, YEAR, SYEAR, YYY, YY, Y
ISO YearIYYY, IY, I
QuarterQ
MonthMONTH, MON, MM, RM
WeekWW
Week NumberIW
WeekW
DayDDD, DD, J
Start day of the weekDAY, DY, D
HourHH, HH12, HH24
MinuteMI

 

Using Oracle TRUNC on SYSDATE

The Oracle TRUNC function is often used on the SYSDATE keyword. It’s something I do quite often. It’s useful to get the current date, without the time, by using the SYSDATE keyword.

You can use it by simply running:

TRUNC(SYSDATE)

See below for more examples about using TRUNC with SYSDATE.

 

Can You Use Oracle TRUNC on a TIMESTAMP?

Yes, you can. The DATE version of the TRUNC function accepts any date data type, including timestamp. You can then truncate it to the format you need.

As of Oracle version 9 (version 9.2.0.3 I believe), you can perform TRUNC on timestamp. Before this version, you got an error (ORA-00932: inconsistent datatypes: expected NUMBER got TIMESTAMP).

If you are unable to use TRUNC on timestamps in your version, you can CAST it to a DATE first:

TRUNC(CAST(TIMESTAMP as DATE))

See below for some examples on using TRUNC with TIMESTAMP.

 

Can You Use Oracle TRUNC on a STRING?

No, you can’t use the Oracle TRUNC function on a string data type. If you want to remove characters from a string data type, you can use the SUBSTR function

 

Examples of the Oracle TRUNC Function

Here are some examples of the TRUNC function. I find that examples are the best way for me to learn about code, even with the explanation above.

These examples use a table called “datelist” that I created using the following code:

CREATE TABLE datelist (
 datevalue DATE,
 timestampvalue TIMESTAMP
 );

 

INSERT INTO datelist (datevalue, timestampvalue) VALUES (SYSDATE, SYSTIMESTAMP);

 

SELECT datevalue, timestampvalue FROM datelist;
DATEVALUETIMESTAMPVALUE
26/MAR/1526/MAR/15 05:58:01.378000000 AM

And yes, it is about 6AM when I’m writing this post!

Example 1

This example shows how to use TRUNC on a date to truncate it to a year.

SELECT TRUNC(datevalue, 'YEAR') AS TRUNCVALUE
FROM datelist;

Result:

TRUNCVALUE
01/JAN/15

It shows the date value converted to a year, which is the first day of the first month of the year.

 

Example 2

This example uses TRUNC on a date to truncate it into a month.

SELECT TRUNC(datevalue, 'MONTH') AS TRUNCVALUE
FROM datelist;

Result:

TRUNCVALUE
01/MAR/15

It shows a similar result, converting the date to a month and year value, which changes the day to the first of that month.

 

Example 3

This example uses TRUNC on a date to truncate it to a day.

SELECT TRUNC(datevalue, 'DD') AS TRUNCVALUE
FROM datelist;

Result:

TRUNCVALUE
26/MAR/15

It looks to be the same value that is returned, because the provided value is already a day/month/year type.

 

Example 4

This example uses TRUNC to show the date value as an IW format (which is the week number in a year).

SELECT TRUNC(datevalue, 'IW') AS TRUNCVALUE
FROM datelist;

Result:

TRUNCVALUE
23/MAR/15

It has truncated the value back to March 23, which is the Monday of the same week.

 

Example 5

This example shows how to use TRUNC on SYSDATE.

SELECT TRUNC(SYSDATE) AS TRUNCVALUE
FROM dual;

Result:

TRUNCVALUE
26/MAR/15

It looks to be the same value that is returned, because SYSDATE is already in that format.

 

Example 6

This example uses TRUNC on a TIMESTAMP value.

SELECT TRUNC(timestampvalue) AS TRUNCVALUE
FROM datelist;

Result:

TRUNCVALUE
26/MAR/15

As you can see, it has removed the time value from the timestamp and just returned a date.

 

Example 7

This example uses a TIMESTAMP and shows it as months.

SELECT TRUNC(timestampvalue, 'MM') AS TRUNCVALUE
FROM datelist;

Result:

TRUNCVALUE
01/MAR/15

This shows the timestamp value truncated to the month, which is March.

 

Example 8

This example shows TRUNC using a number.

SELECT TRUNC(5718.46987) AS TRUNCVALUE
FROM dual;

Result:

TRUNCVALUE
5718

The number is truncated to a whole number. The decimals are removed, which is done without rounding.

 

Example 9

This example truncates the number to 2 places.

SELECT TRUNC(5718.46987, 2) AS TRUNCVALUE
FROM dual;

Result:

TRUNCVALUE
5718.46

The result shows the original number with two decimal places, without any rounding.

 

Example 10

This example truncates the number to 3 places to the left of the decimal.

SELECT TRUNC(5718.46987, -3) AS TRUNCVALUE
FROM dual;

Result:

TRUNCVALUE
5000

This value is the result of truncating the 3 decimal places, so it only shows the thousands value.

 

Example 11

This example truncates the number using a decimal value of 0.

SELECT TRUNC(5718.46987, 0) AS TRUNCVALUE
FROM dual;

Result:

TRUNCVALUE
5718

This is the same as providing no decimal places, as it rounds to a whole number.

 

Similar Functions

Some functions which are similar to the Oracle TRUNC function are:

  • TRIM – removes the leading and trailing characters from a string
  • SUBSTR – returns a part of the provided value, based on the specified position and length
  • ROUND – rounds a value to the specified number of places.

Lastly, if you enjoy the information and career advice I’ve been providing, sign up to my newsletter below to stay up-to-date on my articles. You’ll also receive a fantastic bonus. Thanks!

Image courtesy of digitalart / FreeDigitalPhotos.net

]]>
http://www.completeitprofessional.com/oracle-trunc/feed/ 0
What Is The System Analyst Job Description?http://www.completeitprofessional.com/system-analyst-job-description/ http://www.completeitprofessional.com/system-analyst-job-description/#comments Mon, 23 Mar 2015 11:00:07 +0000 http://www.completeitprofessional.com/?p=3366 ]]> What Is The System Analyst Job DescriptionHave you heard of the “System Analyst” job title? Perhaps you are a System Analyst and want to find out what the actual description is. Learn what the system analyst job description is in this article.

System Analyst Job Description

The job description of a system analyst is:

A system analyst looks at existing IT systems to analyse, design, and implement new IT solutions, or modify existing IT solutions.

That’s the short answer. If you’ve been around IT for any length of time, you might have seen people or worked with people who fit this description. They also might seem similar to business analysts – but we’ll get to that later.

 

What Does A System Analyst Do?

A job description is helpful to know at a high level what your role is. But, what does a system analyst actually do?

Some of the tasks or jobs that they can do are:

  • Analyse existing IT systems
  • Perform requirements analysis
  • Translate the business “speak” or the business problem into technical or project requirements
  • Speak with internal and external stakeholders and team members (developers, other business analysts and system analysts, testers, business representatives)
  • Understand the software development life cycle
  • Document the interfaces in new and existing or legacy systems
  • Help determine the time and cost involved in developing a solution
  • Presenting or contributing to a solution discussion with the client and business representatives
  • Working closely with the project manager to determine and adhere to the timeline, costs, and identify risks and issues
  • Write, or contribute to, a technical requirements document
  • Work with designers and developers to create a solution to match the business requirements
  • Perform system testing
  • Help implement the solution
  • Document the process or solution

These tasks are often listed along with the system analyst job description in job posts. Does this line up to what you actually do as a system analyst? Does it help to understand what a system analyst actually does if you’re not a system analyst?

 

What Is The Difference Between a System Analyst and a Business Analyst?

The job description and tasks listed above seem quite similar to those of a business analyst. Also, my current role as a business analyst means I do many of these tasks as well.

So how does it differ from a business analyst? Is this another case of two job titles meaning the same thing?

Well, they’re actually a bit different. The “systems analyst” role sits more on the IT side of the “business/IT” divide. They are usually more technical and have a background in software development, kind of like a technical business analyst. The tasks listed above around “writing technical requirements documents” and “performing system testing” are not usually done by a business analyst, but they’re perfectly normal tasks for a system analyst.

The “business analyst” sits more on the business side of the “business/IT” divide. They are responsible for understanding the business process and business problems, and don’t necessarily need an IT background (thought it helps, I can assure you). They may spend more time gathering requirements and working with the business stakeholders than a system analyst, but less time looking at the system and would never write code or technical requirements.

great post by Laura Brandenburg over at Bridging the Gap explains this in more detail.

 

What Skills Does A System Analyst Need?

Similar to a business analyst, there are several skills that are desirable for system analysts to have, and are often listed along with the system analyst job description in job posts:

  • Strong analysis skills
  • Strong written and verbal communication skills
  • Knowledge of programming concepts, such as testing, maintenance, development process, architecture
  • Experience in one or more programming languages is helpful

These skills are similar to that of a business analyst, but are more technical.

The most important ones are analysis and communication, which are essential to their job. What use is a system analyst who can’t analyse, or communicate with others? This is a fundamental part of their role.

Programming concepts are also needed, and because they work more on the IT side of the project, they need to be able to understand the developers and work with them to design a solution that meets their requirements. They also need to be able to translate what the developers have said into terms that the business stakeholders can understand.

 

Well, I hope this article has helped you understand what a system analyst does and the system analyst job description.

Do you have any questions on this role? Share them in the comments section below!

Career Action Tip: If you’re interested in becoming a systems analyst, evaluate your analysis skills, communication skills, and programming experience against the requirements of a system analyst. Look on some job boards for system analyst roles and see how you meet the criteria for these roles.

Lastly, if you enjoy the information and career advice I’ve been providing, sign up to my newsletter below to stay up-to-date on my articles. You’ll also receive a fantastic bonus. Thanks!

Image courtesy of David Castillo Dominici / FreeDigitalPhotos.net

]]>
http://www.completeitprofessional.com/system-analyst-job-description/feed/ 1
Oracle CONCAT Function with Exampleshttp://www.completeitprofessional.com/oracle-concat/ http://www.completeitprofessional.com/oracle-concat/#comments Thu, 19 Mar 2015 11:00:24 +0000 http://www.completeitprofessional.com/?p=3337 ]]> Oracle CONCAT FunctionThe Oracle CONCAT function is not a very widely used function, but still helpful. Learn more about the CONCAT function in this article.

Purpose of the Oracle CONCAT Function

The Oracle CONCAT function allows you to join, or concatenate, two strings together. It’s part of standard string manipulation in many programming languages.

For example:

string1 = “Yes ”

string2 = “Please”

To concatenate these strings means to join them together.

string3 = “Yes Please”

 

Syntax

The syntax of the Oracle CONCAT function is:

CONCAT( string1, string2 )

The string that is returned is the same data type as string1, which can be any of CHAR, VARCHAR2, NCHAR, NVARCHAR2, CLOB or NCLOB. However, if you’re converting two different data types, the type returned is one that results in a “lossless” conversion. In other words, it keeps the LOB or the Unicode data type if one exists.

The function only allows you to concatenate two strings together. If you want to concatenate multiple strings, you can use nested functions, or the double pipe character, as mentioned below.

 

Parameters

The parameters of the Oracle CONCAT function are:

  • string1 (mandatory): The first string to concatenate as part of this function.
  • string2 (mandatory): The second string to concatenate as part of this function.

The parameters are quite simple compared to other functions that we’ve looked at so far. Both parameters are mandatory and are both string data types.

Let’s have a look at some questions about using the CONCAT function and then some examples.

 

What’s the Difference between Oracle CONCAT vs Pipe?

In short, there is no difference in how the concatenation is done.

The purpose of the CONCAT function is to allow scripts to perform concatenation when moving between systems which have different character sets (and therefore may not support the vertical bars or pipes). As stated by Oracle, this was provided as an alternative to the vertical bars.

In most cases, you can use the double pipe || as concatenation, for several reasons:

  • It’s the ANSI standard
  • It’s easier to read
  • It allows for multiple strings to be concatenated (more than the two permitted by CONCAT)
  • It has similar performance

A StackOverflow experiment was run that compared CONCAT and || over a loop of 100 million, and found almost identical performance.

 

Can You Use Oracle CONCAT with Column Values?

Yes, you can. Refer to the Examples section below to see how you can use it with column values. If you want to add a space or other character in between, you’ll need to add another nested CONCAT function.

 

Can You Use Oracle CONCAT on Rows and Group By Rows?

If you want to concatenate values from multiple rows in Oracle, then you don’t need to use the CONCAT function. In Oracle 11g onwards, you can use the LISTAGG function.

I haven’t included an example here, but when the page for the Oracle LISTAGG function gets published, an example will be included there.

 

Can Oracle CONCAT CLOB Fields?

Yes, you can use Oracle CONCAT on CLOB fields. It can be used on CLOB or NCLOB data types.

Some example scripts use different functions and loops, but with recent versions of Oracle, you can use this function on CLOBs.

 

How Can You Use Oracle CONCAT with Space?

To concatenate two fields together and include a space between them essentially means you’re concatenating three fields:

  • Field 1
  • Space
  • Field 2

To do this, you’ll need to use nested CONCAT functions, to concatenate one field with a space, and then use that result to concatenate with the second field. It can be done in either order.

Refer to the Examples section below for more information.

 

Examples of the Oracle CONCAT Function

Here are some examples of the CONCAT function. I find that examples are the best way for me to learn about code, even with the explanation above.

Example 1

This is a basic example of the CONCAT function.

SELECT CONCAT ('Complete ', 'IT Professional') AS NEW_CONCAT
FROM DUAL;

Result:

NEW_CONCAT
Complete IT Professional

As you can see, the two string values have been joined together.

 

Example 2

This example uses two column values.

SELECT CONCAT (first_name, last_name) AS NEW_CONCAT
FROM customers;

Result:

NEW_CONCAT
JohnSmith
SallyJones
SteveBrown
AdamCooper
JoshThompson
PeterManson
MarkAllan

This shows the first name and last name concatenated, but without a space in between.

 

Example 3

This example shows two strings concatenated, but one has a Unicode value.

SELECT CONCAT('My ', 'Résumé') AS NEW_CONCAT
FROM DUAL;

Result:

NEW_CONCAT
My Résumé

The result actually includes the Unicode characters and doesn’t change them to fit the data type of the first parameter.

 

Example 4

This example uses a CLOB value (full_address) in the concatenation.

SELECT CONCAT(full_address, country) AS NEW_CONCAT
FROM customers;

Result:

NEW_CONCAT
10 Long RoadUSA
50 Market StreetUSA
201 Flinders LaneCanada
14 Wellington RoadUSA
80 Victoria Street
5 Johnson StFrance
8 Smith StreetUK

The address and country are concatenated just like any other string value.

 

Example 5

We can also use double pipes to concatenate values.

SELECT first_name || last_name AS NEW_CONCAT
FROM customers;

Result:

NEW_CONCAT
JohnSmith
SallyJones
SteveBrown
AdamCooper
JoshThompson
PeterManson
MarkAllan

This shows both first_name and last_name concatenated together, in the same way as Example 2.

 

Example 6

This example uses a nested CONCAT function to join three strings together.

SELECT CONCAT(CONCAT(first_name, last_name), country) AS NEW_CONCAT
FROM customers;

Result:

NEW_CONCAT
JohnSmithUSA
SallyJonesUSA
SteveBrownCanada
AdamCooperUSA
JoshThompson
PeterMansonFrance
MarkAllanUK

This result joins the first_name, last_name, and country values together, but without spaces.

 

Example 7

This example joins several strings using nested CONCAT functions, and also includes a space.

SELECT CONCAT(CONCAT(full_address, ', '), country) AS NEW_CONCAT
FROM customers;

Result:

NEW_CONCAT
10 Long Road, USA
50 Market Street, USA
201 Flinders Lane, Canada
14 Wellington Road, USA
80 Victoria Street,
5 Johnson St, France
8 Smith Street, UK

As you can see, the full_address and country values are separated by a comma and a space.

 

Example 8

This example shows many nested CONCAT functions.

SELECT CONCAT(CONCAT(CONCAT(CONCAT(first_name, ' '), last_name), ' - '), full_address) AS NEW_CONCAT
FROM customers;

Result:

NEW_CONCAT
John Smith – 10 Long Road
Sally Jones – 50 Market Street
Steve Brown – 201 Flinders Lane
Adam Cooper – 14 Wellington Road
Josh Thompson – 80 Victoria Street
Peter Manson – 5 Johnson St
Mark Allan – 8 Smith Street

The name is joined together, and then a hyphen, then the full address.

 

Example 9

The same query from Example 8 is done but using pipes instead of the CONCAT function.

SELECT first_name || ' ' || last_name || ' - ' || full_address AS NEW_CONCAT
FROM customers;

Result:

NEW_CONCAT
John Smith – 10 Long Road
Sally Jones – 50 Market Street
Steve Brown – 201 Flinders Lane
Adam Cooper – 14 Wellington Road
Josh Thompson – 80 Victoria Street
Peter Manson – 5 Johnson St
Mark Allan – 8 Smith Street

As you can see, the same result is shown. The first name, last name, and full address are joined together in a much more readable way.

 

Similar Functions

Some functions which are similar to the CONCAT function are:

  • LISTAGG – allows you to order data within a group and concatenate data

 

Lastly, if you enjoy the information and career advice I’ve been providing, sign up to my newsletter below to stay up-to-date on my articles. You’ll also receive a fantastic bonus. Thanks!

Image courtesy of digitalart / FreeDigitalPhotos.net

]]>
http://www.completeitprofessional.com/oracle-concat/feed/ 0
Announcing “Software Developer Academy”http://www.completeitprofessional.com/announcing-software-developer-academy/ http://www.completeitprofessional.com/announcing-software-developer-academy/#comments Thu, 19 Mar 2015 09:45:50 +0000 http://www.completeitprofessional.com/?p=3345 ]]> Announcing "Software Developer Academy"I’ve just made my new online training platform available for the public. Find out more about it in this article.

So, after months of planning and setting up, I’ve finished setting up Software Developer Academy. It’s available at SoftwareDeveloperAcademy.com.

Is this the first you’ve heard about it? If so, read on. If you’re subscribed to my newsletter, you would have been given early access, but this article is still helpful for you.

 

What Is Software Developer Academy?

Software Developer Academy is a new online training platform, or website, developed by Complete IT Professional. I’ve developed a few online courses in the past, and they have all lived in separate domains.

Now, there is the one site that you can access all of my training courses on.

 

Why Did I Create Software Developer Academy?

I did this for many reasons:

  • I wanted to have a single place for me and other students to visit to access all of my training courses, which were spread all over the place before this.
  • Create a consistent look and feel for all courses
  • Save time in the future for any other courses I create
  • Small cost saving
  • Provide access to courses that other students haven’t seen before

 

What Courses Are Currently Available?

At the time of launch, there are five courses available on Software Developer Academy.

These courses have been developed over the last couple of years. I’ve created them all, which means you’ll get support from me directly!

 

Why Should You Be Interested In These Courses?

Well, there are several reasons why these courses may interest you.

You might be looking to improve your career, either by getting a better job, or improving your salary in your current job. There are several courses relating to that.

You might be interested in learning Oracle SQL, and don’t want to go through the inconvenience of in-person training with poor quality instructors and low quality material.

Or, you might want to learn how to design an effective database to improve the way you develop your applications.

Learning new skills is a big way for software developers to improve their careers, and Software Developer Academy is a great way of doing that.

Go check out softwaredeveloperacademy.com now, and see for yourself!

]]>
http://www.completeitprofessional.com/announcing-software-developer-academy/feed/ 0
Ruby on Rails vs PHP – A Comparisonhttp://www.completeitprofessional.com/ruby-on-rails-vs-php/ http://www.completeitprofessional.com/ruby-on-rails-vs-php/#comments Mon, 16 Mar 2015 11:00:06 +0000 http://www.completeitprofessional.com/?p=3332 ]]> Ruby on Rails vs PHP - A ComparisonRuby on Rails and PHP are two very popular ways to create web applications. But how do you choose which one you want to use? Ruby on Rails or PHP? Let’s look at the differences in this article.

What are Ruby on Rails and PHP?

If you’ve spent any time around developers in the last few years, you would have heard of Ruby on Rails. Ruby on Rails is actually a combination of two technologies – Ruby, which is the programming language, and Rails, which is a framework built on top of the Ruby language.

It’s quite a popular way to build websites and web applications these days.

PHP, on the other hand, is a programming language. It doesn’t refer to a framework, although there are many frameworks built on top of PHP.

So, Ruby on Rails vs PHP is not quite a straight comparison. It’s asking which is better – a language, or a language + framework.

But what if you wanted to learn one and wanted to know which one was better? There isn’t really a way to say which one is better overall, as it comes down to your preference and your needs. In this article, I’ll go through some of the pros and cons for each and how they impact both Ruby on Rails and PHP.

 

Learning Curve

The learning curve for PHP is very shallow. This means it’s an easy language to learn. It was one of the first languages that I learnt as part of my software development career, and I didn’t find it too hard to pick up and start writing things that worked.

To write PHP, all you need is a HTML page, a way to translate the PHP code (a Web server) and start adding PHP tags into a PHP file. You don’t need a compiler or any special tools to create this PHP code.

Ruby on Rails, on the other hand, is harder to learn. I’ve seen many tutorials around the Web and many courses on Udemy that show you how to use Ruby on Rails to write a web application pretty easily, but other sources say that Ruby on Rails is actually harder to learn.

Because Ruby is the language and Rails is the framework, to learn Ruby on Rails you actually need to learn the Ruby language as well as the Rails framework. This can cause developers a bit of trouble and makes it hard to learn than PHP.

 

Resources and Getting Help

PHP is one of the most, if not the most, widely used web development languages on the Internet. It has been around since 2004 and has had quite a few iterations and releases of the core functionality. Many of the most popular websites use PHP (such as Facebook) and the most popular CMS, WordPress, is also developed in PHP and used by a lot of websites worldwide (including this site, Complete IT Professional).

As a result, there is a lot of documentation that exists for PHP. The official documentation for PHP is quite good and there are a lot of other websites around that offer PHP help and support.

Let’s compare this to Ruby on Rails resources. They have their own documentation as well which can be useful, but difficult for a first-time programmer to use.

StackOverflow is a common way to get answers for your programming questions. There are a lot more questions related to PHP than to Ruby on Rails. At the time of writing, there are 718,252 questions with a tag of PHP and 196,670 with a tag of ruby-on-rails.

 

Ruby on Rails vs PHP Developers

In general, it’s a lot easier to find a PHP developer for your project than it is to find a Ruby on Rails developer. This could be due to the long-term popularity of PHP and the fact that it is easier to learn. If you’re working on a project where you need to develop in one of these two technologies, you may need to get other developers into your team. The ease of getting other developers may be a factor in making your decision.

The quantity of developers and the ease of learning can also be a negative. Because PHP is so much easier to learn, many people are writing PHP code that is pretty bad quality. It’s hard to maintain, slow, and messy. These developers would then be classes as “PHP developers”, and it can be hard to find a good PHP developer who follows programming principles and not find a low-quality PHP developer. You can be a little more certain when hiring a Ruby on Rails developer that they will be a better quality developer, due to the standards that you need to follow when developing with Ruby on Rails.

If, on the other hand, you’re looking for a job with Ruby on Rails vs PHP, the numbers are quite different. Using Dice.com, as it’s one of the largest websites for IT job searches:

  • 3,021 PHP jobs available
  • 3,779 Ruby on Rails jobs available

According to LinkedIn, there are:

  • 1,830,346 people results when searching for PHP
  • 163,049 people results when searching for Ruby on Rails

This shows that there is a large number of developers who know PHP compared to Ruby on Rails, but there are more jobs available for Ruby on Rails developers. This could be because the popularity of Rails has really taken off recently, and many companies are looking for developers with this technology.

However, as mentioned above, this might not be a fair comparison as PHP is an entire language and Ruby on Rails is a combination of a language and a framework.

 

Quality of Code in Ruby on Rails vs PHP

I mentioned earlier that there is a steep learning curve with Ruby on Rails. As a result, the quality of Ruby on Rails developers overall may be higher, due to inexperienced developers trying to learn PHP and hacking together code just to get it to work. It’s harder (but still possible) to write bad code in Ruby on Rails, and therefore, the quality is generally better.

There are many frameworks out there for PHP which allow different standards for development, and as a result, can ensure that the quality of code is better. But, the quality of the code ultimately comes down to the developer. If you’re a poor web developer, then you’re going to put some code together that might work, but has issues later and breaks in certain situations, and is hard to maintain. If you’re a good developer, your code is going to be efficient, easy to maintain, and relatively bug-free. This is the same for PHP and Ruby on Rails – as in, it doesn’t matter which language you use.

So, while the quality is really dependent on the developer, you’ll find a lot more lower quality PHP developers out there than Ruby on Rails developers, and therefore, more low quality PHP code than Ruby on Rails code.

 

Ruby on Rails vs PHP Conclusion

So, to conclude my analysis of Ruby on Rails vs PHP:

  • PHP is a language, Ruby on Rails is a language (Ruby) with a framework (Rails)
  • PHP is much easier to learn than Ruby on Rails
  • Developers are easier to find for PHP than for Ruby on Rails
  • Both are quite popular for job listings
  • Documentation is more prevalent for PHP than for Ruby on Rails

If you’re looking for a specific technology to learn and your choice is down to these two, then I hope this article has helped you make that decision.

Readers, what has your experience with PHP or Ruby on Rails been like? Have you learnt both? Have you written applications in either of them? Share your thoughts in the comments section below.

Career Action Tip: If you’re interested in learning PHP or Ruby on Rails, decide which technology seems to fit better with you or your project requirements.

Lastly, if you enjoy the information and career advice I’ve been providing, sign up to my newsletter below to stay up-to-date on my articles. You’ll also receive a fantastic bonus. Thanks!

Image courtesy of Stuart Miles / FreeDigitalPhotos.net

]]>
http://www.completeitprofessional.com/ruby-on-rails-vs-php/feed/ 0
Database First Normal Form (1NF) Explainedhttp://www.completeitprofessional.com/first-normal-form/ http://www.completeitprofessional.com/first-normal-form/#comments Thu, 12 Mar 2015 11:00:16 +0000 http://www.completeitprofessional.com/?p=3317 ]]> Database First Normal FormThe process of normalisation on a database involves a concept called “normal forms”. There are three normal forms that are used as part of this process most of the time. Learn what “first normal form” is (or 1NF) in this article.

What Is First Normal Form?

In my recent article on database normalisation, I mentioned that normalisation aims to make the database better by making it more efficient, removing duplicate data, and achieve a few other benefits. This process involves adjusting the database structure to make it adhere to certain rules.

These rules are called normal forms. And the first one is called, you guessed it, “first normal form”.

There’s some history of the concept and some examples on Wikipedia, but frankly, it’s hard to understand for people new to it.

Let’s take a look at an example to help explain this concept.

 

Our Original Database

Let’s say you needed to create a car database, because you were working with a car dealership who sold cars.

Your database might look like this:

Car Sale

Make Model Year Colour Price Sale1 Sale2 Sale3 Sale4
Toyota Camry2013 Red14000 John Smith Alan Johnson Sally Jones
Honda Accord2013 Black12000 Steve Mason
Honda Prelude2012 Blue10000 Jason Hughes John Smith Tina Redmond William Polar
Mitsubishi Lancer2014 Green13000 Matt Warne
Mitsubishi Lancer2014 Black13000 Simon Jones Tina Redmond Michael Wilson

This shows a list of cars, as well as a few sales for each car.

This is the ER diagram (Entity Relationship Diagram) for this table.

First Normal Form phase 1

 

What’s Wrong With This Data?

This database table lists a few car sales, including the details of each car, and the names of a few people who bought these cars. It looks like it makes sense. You can see that three people bought the first car in the list, the Toyota Camry.

You might be asking, why are there four sales columns?

Yes, this is not a good design. Why is this not a good design?

  • What happens if a fifth person buys the car? We would need to add a new column.
  • What happens if one hundred people buy a car? It’s not a good idea to add one hundred columns.
  • Is it good to keep the other fields as empty if a car does not make four sales?
  • What if a car makes no sales? What do we store in those fields?

All of these questions indicate that the table we have is not designed very well.

But how do we fix it?

 

How Do We Fix The Database Table?

We need to ensure one thing to make sure our database is in first normal form:

Each set of columns must uniquely identify a row.

This means that if you combine the values in all columns, it should give a unique representation of the row.

Let’s take a look at our table again.

Make Model Year Colour Price Sale1 Sale2 Sale3 Sale4
Toyota Camry2013 Red14000 John Smith Alan Johnson Sally Jones
Honda Accord2013 Black12000 Steve Mason
Honda Prelude2012 Blue10000 Jason Hughes John Smith Tina Redmond William Polar
Mitsubishi Lancer2014 Green13000 Matt Warne
Mitsubishi Lancer2014 Black13000 Simon Jones Tina Redmond Michael Wilson

If we look at the data, does a combination of all of these columns ensure that a value is unique?

The answer to this is no. Not for the way the data is structured right now.

If you’re not convinced, let’s take a look at the data.

Row #2 says that a 2013 black Honda Accord was purchased for 12000 by Steve Mason. Could someone named Steve Mason also purchase the same model car for the same price? Yes, he could. The same person could come back and purchase another one the next day, or even buy a whole fleet of them.

This rule doesn’t specify how likely something is, it just works out if it’s possible.

Same for row #1 – the Toyota Camry was purchased by three people, which could also happen again.

So, what we need to do is update the table design.

The problem with this design is it’s trying to store two main pieces oæ information – a car make and model, and a sale of a car.

These should be split into two tables.

Car

Make Model Year Colour Price
Toyota Camry2013 Red14000
Honda Accord2013 Black12000
Honda Prelude2012 Blue10000
Mitsubishi Lancer2014 Green13000
Mitsubishi Lancer2014 Black13000

 

Sale

Sale Name
John Smith
Alan Johnson
Sally Jones
Steve Mason
Jason Hughes
John Smith
Tina Redmond
William Polar
Matt Warne
Simon Jones
Tina Redmond
Michael Wilson

Our ERD looks like this:

First Normal Form phase 2

Now we have one table that shows cars, and another that shows sales.

 

Adding Primary Keys

Now we have our two tables. This is good. And it’s a step towards first normal form.

But how do we know who bought what car? We’ve lost that association between the records.

We use something called a primary key. A primary key is a field that is used to uniquely identify the row. The concept is that it is a single field or multiple fields that uniquely identify a row.

We found earlier that the combination of car details and sales was not unique. But now we’ve moved the Sales to a different table, is it now unique?

The car table now shows make, model, year, colour, and price. Is this unique? For our purposes, yes it is. A model and make of car can only have year, colour and price. If this is different, then a new row is needed.

But, in order to link this to the sale table and to identify the row, we need a primary key column. It’s not a good idea to use all of the columns to identify the row when designing your columns and coming up with your queries, which is why we create a new column.

The name you give your column is up to you, but it’s important to be clear and consistent across your database. My personal preference is to name the new primary key column <table_name> ID. So, in this case, it would be Car ID.

Car IDMake Model Year Colour Price
1Toyota Camry2013 Red14000
2Honda Accord2013 Black12000
3Honda Prelude2012 Blue10000
4Mitsubishi Lancer2014 Green13000
5Mitsubishi Lancer2014 Black13000

We now have a unique and easy way to identify a car.

The same thing should be done for sales. We can’t just use the name of the person to uniquely identify a row.

Sale IDSale Name
1John Smith
2Alan Johnson
3Sally Jones
4Steve Mason
5Jason Hughes
6John Smith
7Tina Redmond
8William Polar
9Matt Warne
10Simon Jones
11Tina Redmond
12Michael Wilson

Our ERD now looks like this:

 

First Normal Form phase 3

 

 

How Do We Join Our Tables?

So, we’ve split our tables and given them primary keys. Have we finished with first normal form?

Not yet. It’s probably the largest of the three normal form steps to go through.

We still don’t know which sale was for which car.

Our original data told us the sale names and the cars. But, we’ll need to add a reference in one table to the other table’s column.

In this case, we add a car ID to the sale table, because the car belongs to a sale.

We then add the car ID for that sale into each row, based on our original data.

Sale IDSale NameCar ID
1John Smith1
2Alan Johnson1
3Sally Jones1
4Steve Mason2
5Jason Hughes3
6John Smith3
7Tina Redmond3
8William Polar3
9Matt Warne4
10Simon Jones5
11Tina Redmond5
12Michael Wilson5

This is how our ERD looks with these two tables. We can see that they are now linked using the IDs, and we have a way of storing more sales for a particular car, without adding extra columns.

First Normal Form phase 4

 

Readers, has this explanation helped you understand first normal form? What questions do you have on first normal form or the normalisation process? Share your questions in the comments section below.

Lastly, if you enjoy the information and career advice I’ve been providing, sign up to my newsletter below to stay up-to-date on my articles. You’ll also receive a fantastic bonus. Thanks!

]]>
http://www.completeitprofessional.com/first-normal-form/feed/ 0
Oracle TRIM Function Explained with Exampleshttp://www.completeitprofessional.com/oracle-trim-function/ http://www.completeitprofessional.com/oracle-trim-function/#comments Thu, 05 Mar 2015 11:00:05 +0000 http://www.completeitprofessional.com/?p=3308 ]]> Oracle TRIM FunctionThe Oracle TRIM function is used to remove specific characters from either the beginning or the end of a string value. Learn more about this function and how to use it in this article.

Purpose of the Oracle TRIM Function

The purpose of the TRIM function is to remove characters from the start or the end of a supplied string. It’s often used to remove space characters, such as where users enter an extra space that is not needed.

Both the LTRIM and RTRIM functions are related, but the TRIM removes characters from either the left or right, or both. Let’s have a look at the syntax to see how this happens.

 

Syntax

The syntax of the Oracle TRIM function is:

TRIM ( [ [ LEADING | TRAILING | BOTH ] trim_character FROM ] trim_source )

You can optionally specify one of LEADING, TRAILING or BOTH for this function. You can also specify the trim_character, but if you do, you need the FROM word.

 

Parameters

The parameters of the TRIM function are:

  • LEADING (optional): If you specify LEADING, the function removes the trim_character from the beginning of the trim_source string.
  • TRAILING (optional): If you specify TRAILING, the function removes the trim_character from the end of the trim_source string.
  • BOTH (optional): If you specify BOTH, the function removes the trim_character from the beginning and the end of the trim_source string.
  • trim_character FROM (optional): This is the character to remove from the trim_source string. If this is not specified, then a space is used. If it is a literal value, it needs to be in single quotes.
  • trim_source (mandatory): This is the string value that characters are removed from.

Some additional points to remember for this function:

  • If you don’t specify LEADING, TRAILING, or BOTH, the function performs the same action as though you specified BOTH. As in, it removes characters from the beginning and the end of the string.
  • Both trim_character and trim_source can be any of CHAR, VARCHAR2, NCHAR, NVARCHAR2, CLOB or NCLOB.
  • The function returns a VARCHAR2 data type if the trim_source is a character data type, or LOB if the trim_source is a LOB data type. It is also returned in the same character set as trim_source.
  • You can use the CHR function as the trim_character if needed. For example, using CHR(100).

 

Can Oracle Trim the Last Character?

Yes, this is possible with the TRIM function, but it’s probably better to use the SUBSTR function.

The TRIM function needs you to specify which character to remove, and it removes it from the end of the string. A SUBSTR function can be written to remove the last character from a string.

See some examples of the SUBSTR function here, including an explanation of the SUBSTR function.

 

Can This Function Be Used To Trim Spaces from a String?

Yes, and this is probably the most common usage of the Oracle TRIM function. I’ve used it many times to clean up user input (for example, if users enter their name with a space at the end of it). It’s better for storing in the database, and helpful for doing data comparisons.

To do this, your function could be:

TRIM(trim_value)

This will return the trim_value without any spaces at the end or the beginning, which effectively trims spaces from a string. See the examples below for more on how this is done.

 

How Can Oracle Trim Newline Characters Or Trim a Carriage Return?

Using the TRIM function to remove newline characters or a carriage return can be done with Oracle. This can work if you only have a newline character or only a carriage return, as you can use the CHR function.

TRIM(CHR(10), your_string)

Will remove new line characters.

TRIM(CHR(13), your_string)

Will remove carriage return characters.

CHR(10) returns a new line character and CHR(13) returns a carriage return character.

But what if you have both? Or it is mixed with spaces and tab characters (CHR(9))?

The main issue is that TRIM only removes one type of character – you can only specify a single character for TRIM to remove.

What if you use a recursive TRIM function?

TRIM (CHR(10), TRIM(CHR(13), your_string))

This can work, but it could be slow, especially if you have it inside a loop or a large query.

An approach recommended by users at Stack Overflow is the TRANSLATE function, to translate all occurrences of a string into a space, and then TRIM the string of spaces. See the examples below on how to do this.

You can also use a REGEXP_REPLACE function, which is a bit more flexible but more complicated.

 

Can Oracle Trim The Left Of The String?

Yes, this is done by specifying LEADING in the function parameter. You need to specify a character, so it might be something like this:

TRIM(LEADING ' ' FROM your_string)

This will use the Oracle TRIM function to trim the left of the string.

 

How Can Oracle Trim All Whitespace From A String?

You can use the TRIM function to remove the spaces from the beginning and end of a string.

If you want to include newline and carriage return characters, use the TRANSLATE function as well, as shown in the example below.

You can also use a REGEXP_REPLACE function, which is a bit more flexible but more complicated.

 

How Can Oracle Trim Spaces Between Words?

The Oracle TRIM function does not trim spaces between words. You can use a regular expression with REGEXP_REPLACE to remove occurrences of more than once space. Or, you can use the REPLACE function to remove all spaces between words – but this would result in a single long word.

 

How Can Oracle Trim a Column?

You can use Oracle TRIM on a column name instead of a specific string. You would just specify the column name, as well as your parameters.

If you want to update the values in the column, you would use an UPDATE statement:

UPDATE your_table
SET your_column = TRIM(your_column)
WHERE [conditions];

 

Examples of the TRIM Function

Here are some examples of the TRIM function. I find that examples are the best way for me to learn about code, even with the explanation above.

Example 1

This example removes the trailing spaces from a string.

SELECT TRIM('Jack   ') AS trimmed FROM dual;

Result:

TRIMMED
Jack

The spaces at the end of “Jack   ” are removed.

 

Example 2

This example removes the leading spaces from a string.

SELECT TRIM(' John') AS trimmed FROM dual;

Result:

TRIMMED
John

The spaces at the start of ” John” are removed.

 

Example 3

This example removes the leading and trailing spaces from a string.

SELECT TRIM(' Julie   ') AS trimmed FROM dual;

Result:

TRIMMED
Julie

The spaces at the start and end of ”  Julie  ” are removed.

 

Example 4

This example removes the leading spaces from a string by specifying LEADING.

SELECT TRIM(LEADING ' ' FROM ' Julie   ') AS trimmed FROM dual;

Result:

TRIMMED
Julie

The spaces at the start of ”  Julie  ” are removed, but the spaces at the end remain. You might not be able to see it on the page here unless you highlight the text.

 

Example 5

This example removes the trailing spaces from a string by specifying TRAILING.

SELECT TRIM(TRAILING ' ' FROM ' Julie   ') AS trimmed FROM dual;

Result:

TRIMMED
 Julie

The spaces at the end of ”  Julie  ” are removed, but the spaces at the start remain. You might not be able to see it on the page here unless you highlight the text.

 

Example 6

This example removes the leading and trailing spaces from a string by specifying BOTH.

SELECT TRIM(BOTH ‘ ‘ FROM ‘ Julie   ‘) AS trimmed FROM dual;

Result:

TRIMMED
Julie

The spaces at the start and end of ”  Julie  ” are removed.

 

Example 7

This example removes an underscore from the provided string.

SELECT TRIM(‘_’ FROM ‘Jordan___’) AS trimmed FROM dual;

Result:

TRIMMED
Jordan

 

Example 8

This example converts the newline, carriage return, and tab characters to spaces and removes them from a string.

SELECT 'first line' || CHR(9) || 'after tab' || CHR(10) || 'next line'  || CHR(13) ||  'another line',
 TRIM(
   TRANSLATE(
     TRANSLATE(
       TRANSLATE('first line' || CHR(9) || 'after tab' || CHR(10) || 'next line'  || CHR(13) ||  'another line', CHR(10), ' ')
     , CHR(13), ' ')
   , CHR(09), ' ')
 ) AS trimmed
FROM dual;

Result:

FULL_STRINGTRIMMED
first line after tab

next line
another line

first line after tab next line another line

The newline, carriage return, and tab characters are converted to spaces, and the entire result is then trimmed to ensure there is no spaces either side of the string, which is a possibility if there is a new line at the end of a string.

 

Example 9

This example updates a value in the customers table.

First, let’s see what is in the customers table.

SELECT first_name
 FROM customers
 WHERE customer_id = 123;

Result:

FIRST_NAME
 Jason

Now, let’s update the first_name to remove spaces

UPDATE customers
 SET first_name = TRIM(first_name)
 WHERE customer_id = 123;

Now, let’s have another look at the customers table.

SELECT first_name
 FROM customers
 WHERE customer_id = 123;

Result:

FIRST_NAME
Jason

The space has been removed from this value.  You might not be able to see it on the page here unless you highlight the text.

 

Similar Functions

Some functions which are similar to the Oracle TRIM function are:

  • LTRIM – Trims characters from the left of a string.
  • RTRIM – Trims characters from the right of a string.
  • REPLACE – lets you replace a character with a different character within a string.
  • REGEXP_REPLACE – performs a similar function to REPLACE but uses regular expressions.
  • TRANSLATE – similar to REPLACE but lets you perform several one-to-one replacements inside one function.

Lastly, if you enjoy the information and career advice I’ve been providing, sign up to my newsletter below to stay up-to-date on my articles. You’ll also receive a fantastic bonus. Thanks!

Image courtesy of digitalart / FreeDigitalPhotos.net

]]>
http://www.completeitprofessional.com/oracle-trim-function/feed/ 0
Interview with Tom Henricksenhttp://www.completeitprofessional.com/interview-with-tom-henricksen/ http://www.completeitprofessional.com/interview-with-tom-henricksen/#comments Tue, 03 Mar 2015 11:00:43 +0000 http://www.completeitprofessional.com/?p=3298 ]]> This post is an interview with Tom Henricksen from MyITCareerCoach.com. I recently did an interview for his site, and he has returned the gesture and provided a little about himself.

Interview Q&A

Name: Tom Henricksen

Current Position:  Career Coach at MyITCareerCoach.com and Development Services Manager at Zirous in West Des Moines, IA

IT Background:  I started out in Oracle Forms and Reports at small company in Des Moines, Iowa.  From their I learned JSP/Servlets programming in Java at Iowa Foundation for Medical Care, now Telligen.  Also with a some time at Advanced Technologies Group doing more Java development.  Then I moved to Dice where my job consisted of leading a team of Java developers in an Agile environment.  Now I am at Zirous where I work as a Development Services Manager working on primarily on Oracle software.  I am also a Career Coach at MyITCareerCoach.com where I help people build great IT Careers.  I recently published a book called Cracking the Career Code.

Biggest Failure:  Early in my career I thought I should be able to figure everything out myself.  It doesn’t take long to learn that process won’t work.   Learning to find people and resources to help really will get you much further.   Understanding your team mates strengths and weakness will let you know who to ask when you have a certain problem.

Biggest Success:  I have learned how important communication is in Software Development and in all walks of life.  If you can communicate your idea you won’t get very far.  I have joined Toastmaster a few years ago and it has really helped me gain a better understanding of how to communicate ideas effectively.

Mentor:  My previous boss Mike Last was a great person to learn how to get applications built and deliver high quality products.  He understands the development process and the customer’s desires.

Current Book I am reading:  The Five Dysfunctions of a Team by Patrick Lencioni

Hobbies:  I enjoy biking, reading, home improvement projects and spending time with my family.

 

If you’d like to know more about Tom, visit his site at MyITCareerCoach.com.

]]>
http://www.completeitprofessional.com/interview-with-tom-henricksen/feed/ 0
How To Create a Comprehensive Web Developer Portfoliohttp://www.completeitprofessional.com/web-developer-portfolio/ http://www.completeitprofessional.com/web-developer-portfolio/#comments Mon, 02 Mar 2015 18:57:41 +0000 http://www.completeitprofessional.com/?p=3302 ]]> How To Create A Comprehensive Web Developer PortfolioAs a web developer, a lot of your future work with new clients depends on the work you’ve done with previous clients. One of the best ways to promote your old work is with a portfolio. Let’s see how you can create a comprehensive web developer portfolio that’s easy for you new clients or employers to see.

Why Do You Need A Web Developer Portfolio?

Well, as a web developer, a lot of your work is both public-facing and visual. You create web sites for companies, both large and small, and their websites are often on public display. They could be their main website, e-commerce stores, Intranet sites (which are actually internal), or any sub-sites they have such as blogs.

Because of the public nature of this, it’s very easy for people to ask about your previous work and ask if they can see it.

It’s like a lot of jobs where the work you do is public. A lot of tradespeople (fencers, painters, builders, and so on) have photos of their previous work to show customers.

So, how do you create a portfolio as a web developer to show clients? Is it as easy as giving them a list of websites? Well, I think it’s even easier than that. Let’s see why.

 

Client Websites

The main place for your web developer portfolio is the actual client websites. As a web developer, you should be keeping a list of all of the customers and sites that you have helped build.

It also helps to make a note of what you did on the site.

  • Did you do all of the design and development work yourself?
  • Did you only assist in the development work and the design was done by someone else?
  • Did you build on an existing website by making it faster, more secure, responsive, or some other feature?

This way, when a client or employer goes to one of these sites, you’re able to remember what you did and easily explain it to them.

 

Github

Another place to show your web developer portfolio is on Github.

This code repository can store all of the source code for projects that you have worked on. This can be for both your own projects as well as client projects. However, there may be some rules around storing customer’s website code on Github, so make sure you check with the client about this.

The main reason for storing code on Github is that the code is available for viewing. When you’re going for a job as a web developer, you can refer employers to your Github profile, which they can look up to view your code.

Why would someone want to look at your Github profile when they have the link to the client site?

Well, this is because the link to the client site only shows what the site looks like and what it does. The Github profile will show the source code behind it and how it performs. The employer can see if you’re using best practices and if you’re actually a good web developer.

 

Your Own Website

I think that all developers, especially web developers, should have their own website. It should be used for two things.

Firstly, it should be used as a place you can link to other work that you’ve done in the past, such as other clients’ websites.

Secondly, it should be used as an example of your own abilities as a web developer.

Whether you develop the website from scratch yourself, or use a common framework such as Wordpress with a theme, it’s up to you. But, you should have your own website (ideally with your own domain).

This helps to prove that you’re a competent web developer and are interested in creating web sites.

 

Linking It All Together

So you’ve got your client websites, your Github profile, and your own website. How do you link it all together? How do you make it easy for employers and future clients to see all of this work, and to justify the rate you’re asking for?

I suggest updating your own website to link out to all of these other sites.

Have one central and comprehensive location for your work, which is your own website. Provide a link to your Github profile, so people can see your code.

Then, provide links to each of your client websites. This should be the majority of your site. You can do this by adding screenshots of the sites with titles, descriptions of the work, and links to the site. Or, just links to the site with text. Or, just using images. It’s up to you, as the developer and owner of your site.

Once this is done, all you’ll need to do is provide the one link to your website to any potential employers or clients. This means it’s easier for you, easier for them, and is constantly updated with any new work that you do (which is easier than telling people a list of sites and letting them know when you add a new site).

So, in summary:

  1. Create a Github profile for your code
  2. Create a list of client websites, including what you did for the site
  3. Create your own website with your own domain
  4. Link to all of your work from your own website

 

As a web developer, how do you share your work with others? Do you have a central website, or do you use something else? Share your thoughts in the comments below.

Career Action Tip: Create your own website to be able to link out to your other work.

Lastly, if you enjoy the information and career advice I’ve been providing, sign up to my newsletter below to stay up-to-date on my articles. You’ll also receive a fantastic bonus. Thanks!

 

]]>
http://www.completeitprofessional.com/web-developer-portfolio/feed/ 0
Oracle REPLACE Function with Exampleshttp://www.completeitprofessional.com/oracle-replace/ http://www.completeitprofessional.com/oracle-replace/#comments Thu, 26 Feb 2015 11:00:34 +0000 http://www.completeitprofessional.com/?p=3286 ]]> Oracle REPLACE FunctionThe Oracle REPLACE function is another string manipulation function within Oracle. Learn how to use it and some common examples in this article.

Purpose of the Oracle REPLACE Function

The Oracle REPLACE function is used to replace one text string with another. The text string can be an entire value, or as little as a single character.

 

Syntax

The syntax of the Oracle REPLACE function is:

REPLACE ( whole_string, string_to_replace, [replacement_string])

 

Parameters

The parameters of the REPLACE function are:

  • whole_string (mandatory): This is the string that will be checked for the characters to be replaced. It is usually the longer of all the parameters.
  • string_to_replace (mandatory): This is the string that will be searched for within whole_string.
  • replacement_string (optional): This is the string that will be used to replace occurrences of string_to_replace. If this is not specified, then the Oracle REPLACE function just removes all occurrences of string_to_replace.

Refer to the examples below for more information.

 

Can Oracle Replace a Carriage Return?

Sometimes you want to remove or replace carriage return or new line characters from within string values. This can occur if you are capturing user input and they press Enter to move to a new line, but you want to remove that from your query.

To do that, you need to use either a “carriage return”, a “line feed”, or both. They are done using the CHR function.

The carriage return is checked by using CHR(13), as the number 13 evaluates to the ASCII character for carriage return. Likewise, CHR(10) is a line feed character.
Refer to the example below on how to replace a carriage return with this function.

 

Can Oracle Replace NULL With 0?

Yes, you can. If you want to replace NULL values with zero to use for calculations, for example, Oracle can do this. However, it’s not done with the REPLACE function. It’s done with the NVL function.

A NULL value can exist for a column, and it is the entire value in the column, not part of a larger value. So, if you had NULL in a column and wanted to replace it, a REPLACE(NULL, NULL, ‘x’) would not work as expected.

It’s better to use the NVL function, such as NVL(value_to_check, 0).

 

Can Oracle Replace Multiple Characters?

It can’t be done by itself, but there are a few ways it can be done:

  1. Nested REPLACE statements
  2. Using REGEXP_REPLACE
  3. A custom function

Perhaps the most widely accepted way is to use nested REPLACE statements.

For example, consider this string:

“My first name is (x), my last name is (y), and I’m from (z).”

If you wanted to replace the (x), (y), and (z) values, you would use a nested REPLACE statement:

SELECT REPLACE(REPLACE(REPLACE('My first name is (x), my last name is (y), and I am from (z).', '(x)', first_name), '(y)', last_name), '(z)', country) FROM customers;

As you can see, this can get quite messy if there are many strings to replace.

You can write a custom function to perform this, but that’s outside the scope of this article.

My preferred way is to use REGEXP_REPLACE, which I believe is faster and easier to read. See the REGEXP_REPLACE function definition for examples.

 

Can Oracle Replace Special Characters?

Yes, but you can only use it to remove a single special character for each function.

You could use nested REPLACE statements, but if you’re removing many special characters, this can get messy and slow.

There are two other ways to do this – using REGEXP_REPLACE or TRANSLATE.

SELECT REGEXP_REPLACE(whole_string,'[^[:alnum:]'' '']', NULL) FROM dual;

or

SELECT TRANSLATE(whole_string, '[0-9]#$&&!_','[0-9]') FROM dual;

See the REGEXP_REPLACE and TRANSLATE function definitions for more information.

 

Can Oracle Replace Single Quote?

Yes, it can.

You need to “escape” the single quote character from inside the string you specify. To do this, you need to specify it as four single quotes – two to contain the string, one as an escape character, and one as the single quote.

The third parameter would be what you want to replace it with. This could be a double quote (‘”‘), no value (”), a space (‘ ‘), or something else.

Refer to the examples section below for some actual queries.

 

Can Oracle Replace a String In A Column?

Yes, it can. This is relatively simple to do.

You’ll need to know both the string you’re replacing and the string you’re replacing it with. You would then use an UPDATE statement on the table, and refer to the column.

UPDATE table SET column = REPLACE(column, 'abc', 'def')

This would replace all occurrences of ‘abc’ in the values in the column with a value of ‘def’ inside those values.

See the Examples section below for more information.

 

Examples of the REPLACE Function

Here are some examples of the REPLACE function. I find that examples are the best way for me to learn about code, even with the explanation above.

Example 1

This is a simple REPLACE example.

SELECT 'Today is the 26th of February, 2015' AS ORIGINAL_STRING,
REPLACE('Today is the 26th of February, 2015', 'a', 'X') AS REPLACE_STRING
FROM dual;

Result:

ORIGINAL_STRINGREPLACE_STRING
Today is the 26th of February, 2015TodXy is the 26th of FebruXry, 2015

This replaces the character ‘a’ with an ‘X’, wherever it is found.

 

Example 2

This is another simple REPLACE example.

SELECT 'Today is the 26th of February, 2015' AS ORIGINAL_STRING,
REPLACE('Today is the 26th of February, 2015', 'the', 'probably the') AS REPLACE_STRING
FROM dual;

Result:

ORIGINAL_STRINGREPLACE_STRING
Today is the 26th of February, 2015Today is probably the 26th of February, 2015

As you can see, it replaces the string ‘the’ with the string ‘probably the’

 

Example 3

This example does not provide a parameter for the replacement_string.

SELECT 'Today is the 26th of February, 2015' AS ORIGINAL_STRING,
REPLACE('Today is the 26th of February, 2015', 'th') AS REPLACE_STRING
FROM dual;

Result:

ORIGINAL_STRINGREPLACE_STRING
Today is the 26th of February, 2015Today is e 26 of February, 2015

This string now just removes the occurrences of ‘th’.

 

Example 4

This example shows what happens when the string_to_replace is not found.

SELECT 'Today is the 26th of February, 2015' AS ORIGINAL_STRING,
REPLACE('Today is the 26th of February, 2015', 'X', 'Y') AS REPLACE_STRING
FROM dual;

Result:

ORIGINAL_STRINGREPLACE_STRING
Today is the 26th of February, 2015Today is the 26th of February, 2015

As ‘X’ is not found, no operation to replace it with ‘Y’ is done.

 

Example 5

This example shows what happens when both the whole_string and string_to_replace are the same.

SELECT 'Today is the 26th of February, 2015' AS ORIGINAL_STRING,
REPLACE('Today is the 26th of February, 2015', 'X', 'Y') AS REPLACE_STRING
FROM dual;

Result:

ORIGINAL_STRINGREPLACE_STRING
Today is the 26th of February, 2015(null)

As you can see, the result is exactly the same.

 

Example 6

This example shows how to replace a carriage return character with a space.

SELECT 'Today is the 26th of February, 2015' || CHR(13) AS ORIGINAL_STRING,
REPLACE('Today is the 26th of February, 2015' || CHR(13), CHR(13), ' ') AS REPLACE_STRING
FROM dual;

Result:

ORIGINAL_STRINGREPLACE_STRING
Today is the 26th of February, 2015Today is the 26th of February, 2015

It can be hard to see in this example, but using real data, this would remove the carriage return and replace it with a space.

 

Example 7

This example is similar to the above example, but shows how to replace a carriage return and line feed with a space.

SELECT 'Today is the 26th of February, 2015' || CHR(13) || CHR(10) AS ORIGINAL_STRING,
REPLACE('Today is the 26th of February, 2015' || CHR(13) || CHR(10), CHR(13) || CHR(10), ' ') AS REPLACE_STRING
FROM dual;

Result:

ORIGINAL_STRINGREPLACE_STRING
Today is the 26th of February, 2015Today is the 26th of February, 2015

It can be hard to see in this example, but using real data, this would remove the carriage return and line feed and replace it with a space.

 

Example 8

This example attempts to replace the NULL value with a value of ‘x’.

SELECT NULL AS ORIGINAL_STRING,
REPLACE(NULL, NULL, 'x') AS REPLACE_STRING
FROM dual;

Result:

ORIGINAL_STRINGREPLACE_STRING
(null)(null)

As you can see, it doesn’t work as expected. The better approach is to use NVL(NULL, ‘x’).

 

Example 9

This example uses nested REPACE functions to replace multiple characters

SELECT 'My first name is (x), my last name is (y), and I am from (z).' AS ORIGINAL_STRING,
REPLACE(REPLACE(REPLACE('My first name is (x), my last name is (y), and I am from (z).', '(x)', 'John'), '(y)', 'Smith'), '(z)', 'England') AS REPLACE_STRING
FROM dual;

Result:

ORIGINAL_STRINGREPLACE_STRING
My first name is (x), my last name is (y), and I am from (z).My first name is John, my last name is Smith, and I am from England.

This works as expected, but it’s more efficient to use REGEXP_REPLACE.

 

Example 10

This example shows how to replace a single quote with a double quote. Notice the four single quotes in the string_to_replace parameter, and the single-double-single quotes in the replacement_string parameter.

SELECT 'What''s the date today?' AS ORIGINAL_STRING,
REPLACE('What''s the date today?', '''', '"') AS REPLACE_STRING
FROM dual;

Result:

ORIGINAL_STRINGREPLACE_STRING
What’s the date today?What”s the date today?

As shown, the single quote is replaced with a double quote.

 

Example 11

This example shows how to replace a single quote with nothing, or to remove the single quote from the string.

SELECT 'What''s the date today?' AS ORIGINAL_STRING,
 REPLACE('What''s the date today?', '''') AS REPLACE_STRING
 FROM dual;

Result:

ORIGINAL_STRINGREPLACE_STRING
What’s the date today?Whats the date today?

The single quote is now removed from the string.

 

Example 12

This is an UPDATE statement used to update a column using the REPLACE function.

First, let’s check the customers table

SELECT first_name, last_name FROM customers;

Result:

FIRST_NAMELAST_NAME
JohnSmith
SallyJones
SteveBrown
MarkAllan
AdamCooper
JoshThompson
PeterManson

Now, we run the UPDATE statement to change all occurrences of ‘S’ to ‘W’.

UPDATE customers
SET first_name = REPLACE(first_name, 'S', 'W');

Result:

7 rows updated.

 

Now, let’s check the customers table again.

SELECT first_name, last_name FROM customers;

Result:

FIRST_NAMELAST_NAME
JohnSmith
WallyJones
WteveBrown
MarkAllan
AdamCooper
JoshThompson
PeterManson

Two records have been updated (first name of “Wally” and “Wteve”).

 

Similar Functions

Some functions which are similar to the REPLACE function are:

  • SUBSTR – allows a smaller string to be extracted from a larger string.
  • INSTR – checks one string for the occurrence of another string
  • REGEXP_REPLACE – performs a similar function to REPLACE but uses regular expressions.
  • TRANSLATE – similar to REPLACE but lets you perform several one-to-one replacements inside one function.

Lastly, if you enjoy the information and career advice I’ve been providing, sign up to my newsletter below to stay up-to-date on my articles. You’ll also receive a fantastic bonus. Thanks!

Image courtesy of digitalart / FreeDigitalPhotos.net

]]>
http://www.completeitprofessional.com/oracle-replace/feed/ 0