12.07.2015 Views

Oracle SQL Developer

Oracle SQL Developer

Oracle SQL Developer

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Utilizing the Main Features of PL/<strong>SQL</strong>7.3.6 Using LiteralsA literal is an explicit numeric, character, string, or BOOLEAN value not represented byan identifier. For example, 147 is a numeric literal and FALSE is a BOOLEAN literal.Numeric LiteralsTwo kinds of numeric literals can be used in arithmetic expressions: integers and reals.An integer literal is an optionally signed whole number without a decimal point, suchas +6. A real literal is an optionally signed whole or fractional number with a decimalpoint, such as -3.14159. PL/<strong>SQL</strong> considers a number such as 25. to be real eventhough it has an integral value.Numeric literals cannot contain dollar signs or commas, but can be written usingscientific notation. Simply suffix the number with an E (or e) followed by anoptionally signed integer, such as -9.5e-3. E (or e) stands for times ten to the powerof.Character LiteralsA character literal is an individual character enclosed by single quotes (apostrophes),such as '(' or '7'. Character literals include all the printable characters in thePL/<strong>SQL</strong> character set: letters, numerals, spaces, and special symbols.PL/<strong>SQL</strong> is case sensitive within character literals. For example, PL/<strong>SQL</strong> considers thecharacter literals 'Z' and 'z' to be different. Also, the character literals '0'..'9' arenot equivalent to integer literals but can be used in arithmetic expressions becausethey are implicitly convertible to integers.String LiteralsA character value can be represented by an identifier or explicitly written as a stringliteral, which is a sequence of zero or more characters enclosed by single quotes, suchas 'Hello, world!' and '$1,000,000'. All string literals except the null string ('')have data type CHAR.PL/<strong>SQL</strong> is case sensitive within string literals. For example, PL/<strong>SQL</strong> considers thefollowing string literals 'baker' and 'Baker' to be different:To represent an apostrophe within a string, you can write two single quotes (''),which is not the same as writing a double quote ("). Doubling the quotation markswithin a complicated literal, particularly one that represents a <strong>SQL</strong> statement, can betricky. You can also define your own delimiter characters for the literal. You choose acharacter that is not present in the string, and then do not need to escape other singlequotation marks inside the literal, such as the following string.q'!I'm using the exclamation point for a delimiter here.!'BOOLEAN LiteralsBOOLEAN literals are the predefined values TRUE, FALSE, and NULL. NULL stands for amissing, unknown, or inapplicable value. Remember, BOOLEAN literals are values, notstrings. For example, TRUE is no less a value than the number 25.Datetime LiteralsDatetime literals have various formats depending on the datetime data type, such as'14-SEP-05' or '14-SEP-05 09:24:04 AM'.Example 7–6 shows some examples of the use of literals.PL/<strong>SQL</strong>: Usage Information 7-7

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!