View the Exhibit and examine the structure of the CUSTOMERS table.
In the CUSTOMERS table, the CUST_LAST_NAME column contains the values ‘Anderson’ and ‘Ausson’.
You issue the following query:
SQL> SELECT LOWER(REPLACE(TRIM(‘son’ FROM cust_last_name),’An’,’O’))
FROM CUSTOMERS
WHERE LOWER(cust_last_name) LIKE ‘a%n’;
What would be the outcome?
A.
‘Oder’ and ‘Aus’
B.
an error because the TRIM function specified is not valid
C.
an error because the LOWER function specified is not valid
D.
an error because the REPLACE function specified is not valid
I test and it works to me on this way:
SQL> select lower ( replace (trim ( ‘s’ from LAST_NAME ), ‘e’, ‘i’ )) from employees WHERE LOWER (LAST_NAME)like ‘we%’;
LOWER(REPLACE(TRIM(‘S’FRO
————————-
wii
TRIM doesnt work with more that 1 char.
Vote for your explanation.
with tt as(
select ‘Anderson’ cust_last_name from dual union
select ‘Ausson’ cust_last_name from dual
)select LOWER(REPLACE(TRIM(‘son’ FROM cust_last_name),’An’,’O’)) from tt;
You can test !
ORA-30001: trim set should have only one character
Cause: Trim set contains more or less than 1 character. This is not allowed in TRIM function.
Action: Change trim set to have only 1 character.
option A is correct… TRIM function specified is valid…!!!!!!!!
TRIM Syntax
Purpose
TRIM enables you to trim leading or trailing characters (or both) from a character string. If trim_character or trim_source is a character literal, then you must enclose it in single quotes.
•If you specify LEADING, then Oracle Database removes any leading characters equal to trim_character.
•If you specify TRAILING, then Oracle removes any trailing characters equal to trim_character.
•If you specify BOTH or none of the three, then Oracle removes leading and trailing characters equal to trim_character.
•If you do not specify trim_character, then the default value is a blank space.
•If you specify only trim_source, then Oracle removes leading and trailing blank spaces.
•The function returns a value with datatype VARCHAR2. The maximum length of the value is the length of trim_source.
•If either trim_source or trim_character is null, then the TRIM function returns null.
Both trim_character and trim_source can be any of the datatypes CHAR, VARCHAR2, NCHAR, NVARCHAR2, CLOB, or NCLOB. The string returned is of VARCHAR2 datatype if trim_source is a character datatype and a LOB if trim_source is a LOB datatype. The return string is in the same character set as trim_source
i am not getting the rite answer….could anybody explain???
see Eric Sacramento’s Answer above!
You get ORA-30001 if you want to specifiy more than one trim_char!
Your post this morning is wrong, your posting of how trim works is unhelpful.
Only this question is valid and hereby (hopefully) answered!
It would be cool if you’d only post that an answer is “right” if you have actually tested it!
the answer is B. Trim set contains more than 1 character. This is not
allowed in TRIM function.
ORA-30001: trim set should have only one character
30001. 00000 – “trim set should have only one character”
*Cause: Trim set contains more or less than 1 character. This is not
allowed in TRIM function.