Home » SQL & PL/SQL » SQL & PL/SQL » lpad
lpad [message #356879] Sun, 02 November 2008 23:54 Go to next message
tamil
Messages: 22
Registered: April 2007
Location: chennai
Junior Member
evaluate the sql statement :

SELECT LPAD(SALARY,10,*)
FROM EMP
WHERE EMP_ID=1001;

If the employee with the EMP_ID 1001 has a salary of 17000, what is displayed?

A. 17000.00
B. 17000*****
C. ****170.00
D. **17000.00
E. an error statement

What is the correct answer because so many dumps had given the result is "C".I can't to accept the result because lpad is a character function and * is come with in the single quote.



Re: lpad [message #356885 is a reply to message #356879] Mon, 03 November 2008 00:17 Go to previous messageGo to next message
user71408
Messages: 585
Registered: November 2007
Location: NE
Senior Member

Hi,

No need to give * in single quotes.
eg : Select lpad(Ename,10,*) from emp;

*****SCOTT = Total Number of Characters=10
******MIKE
*****SMITH
.....

The total number of characters should be 10 and * comes left side of the Given Column name(STRING). So D is the right answer.
if it is not correct plese correct me ...
Please let me know if any concerns.

Thank you.

[Updated on: Mon, 03 November 2008 00:18]

Report message to a moderator

Re: lpad [message #356889 is a reply to message #356885] Mon, 03 November 2008 00:47 Go to previous messageGo to next message
Frank
Messages: 7880
Registered: March 2000
Senior Member
user71408 wrote on Mon, 03 November 2008 07:17
Hi,

No need to give * in single quotes.
eg : Select lpad(Ename,10,*) from emp;



Did you test that?
SQL*Plus: Release 10.2.0.1.0 - Production on Mon Nov 3 07:46:56 2008

Copyright (c) 1982, 2005, Oracle.  All rights reserved.


Connected to:
Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production

SQL> select lpad(ename, 10, *) from emp;
select lpad(ename, 10, *) from emp
                       *
ERROR at line 1:
ORA-00936: missing expression


SQL> select lpad(ename, 10, '*') from emp;

LPAD(ENAME
----------
*****SMITH
*****ALLEN
******WARD
*****JONES
****MARTIN
*****BLAKE
*****CLARK
*****SCOTT
******KING
****TURNER
*****ADAMS
*****JAMES
******FORD
****MILLER

14 rows selected.

Re: lpad [message #356898 is a reply to message #356879] Mon, 03 November 2008 00:57 Go to previous messageGo to next message
Michel Cadot
Messages: 64153
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Quote:
What is the correct answer because so many dumps had given the result is "C".

Paraphrasing Ana:
Quote:
Those who live by the dump, die by the dump.

The answer is... try it by yourself.

Regards
Michel

[Updated on: Mon, 03 November 2008 00:57]

Report message to a moderator

Re: lpad [message #356899 is a reply to message #356885] Mon, 03 November 2008 01:04 Go to previous messageGo to next message
user71408
Messages: 585
Registered: November 2007
Location: NE
Senior Member

user71408 wrote on Mon, 03 November 2008 00:17
Hi,

eg : Select lpad(Ename,10,'*') from emp;

*****SCOTT = Total Number of Characters=10
******MIKE
*****SMITH
.....

The total number of characters should be 10 and * comes left side of the Given Column name(STRING). So D is the right answer.
if it is not correct plese correct me ...
Please let me know if any concerns.

Thank you.


Re: lpad [message #356901 is a reply to message #356899] Mon, 03 November 2008 01:15 Go to previous message
Michel Cadot
Messages: 64153
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
This is NOT a quote. You're lying!

Regards
Michel

[Updated on: Mon, 03 November 2008 01:16]

Report message to a moderator

Previous Topic: help in regard to oracle web connectivity
Next Topic: Improper whaere clause
Goto Forum:
  


Current Time: Sun Dec 11 02:31:18 CST 2016

Total time taken to generate the page: 0.08344 seconds