40 pts.
 updating char
update operator set ascii(REVOKFLG)='0' where login like 'ospprov' error missing equal sign.

Software/Hardware used:
ASKED: January 5, 2010  11:59 AM
UPDATED: January 6, 2010  12:50 AM

Answer Wiki:
You are trying to update the result of a function here, and that is not allowed. If you need to apply a function, then you should apply it to the new value you want to assign to the column, not to the column itself.
Last Wiki Answer Submitted:  January 5, 2010  2:31 pm  by  carlosdl   63,535 pts.
All Answer Wiki Contributors:  carlosdl   63,535 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

What database platform are you using?

 64,520 pts.

 

Oracle 10g
OPERATOR is the Object
REVOKFLG is a field that’s of CHAR type. either 0 or 1.
I am trying to update the REVOKFLG which is displayed in ascii as ’0′ (flag uncheck).

SQL> update operator set REVOKFLG=char(0) where login like ‘ospprov’;
update operator set REVOKFLG=char(0) where login like ‘ospprov’
*
ERROR at line 1:
ORA-00936: missing expression

Please how can I update this?

 40 pts.

 
UPDATE operator 
SET REVOKFLG='0' 
WHERE login like ‘ospprov’;

Am I missing something ?

 63,535 pts.

 

I had tried that earlier which actually made me ask questions about this.
Unfortunately when I checked again by querying ( SELECT ascii(REVOKFLG) from OPERATOR where login like ‘ospprov’;) , REVOKFLG is (48) and not (0).

For this I want to know if there is something I am missing?

 40 pts.

 

Yes, you get 48, because 48 is the code for the ’0′ character.

Could you please explain why you need to use

SELECT ASCII(REVOKFLG)

instead of simply:

SELECT REVOKFLG

to get 0 as result ?

There is no printable character for the ascii code 0. This code represents the null character, so I can’t think of a way to get 0 when asking for the ascii code of REVOKFLG.

You can use a number stored in a char column as a number (and not as a character) without any problems (and w/o the need of the ASCII function), or you could use a column of type NUMBER(1) if you feel more comfortable with it.

I’m sure there is something that needs clarification here. Please provide as much deatils as possible about your requirement.

 63,535 pts.