PL/SQL – Literals

PL/SQL Literals.

A Literal is an explicit numeric, string or Boolean values not represented by an identifiers. For examples, 999,  TRUE, NULL, ‘learndba’ are literal types number, Boolean or string. PL/SQL literals are case sensitive. PL/SQL supports following literals.

S.No Literal Type & Example
1 Numeric Literals

050 78 -14 0 +32767

6.6667 0.0 -12.0 3.14159 +7800.00

6E5 1.0E-8 3.14159e0 -1E38 -9.5e-3

2 Character Literals

‘A’ ‘%’ ‘9’ ‘ ‘ ‘z’ ‘(‘

3 String Literals

‘Hello, world!’

‘Tutorials Point’

’19-NOV-12′

4 BOOLEAN Literals

TRUE, FALSE, and NULL.

5 Date and Time Literals

DATE ‘1978-12-25’;

TIMESTAMP ‘2012-10-29 12:01:01’;

To embed single quotes with in a string literal, place two single quotes to each other as shown in below program.

set SERVEROUTPUT ON;
DECLARE
 message varchar2(20) := 'It''s time to learn';
BEGIN

dbms_output.put_line(message); 
END; 
/
It's time to learn

PL/SQL procedure successfully completed.
Advertisements

Post your Comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s