Home » SQL & PL/SQL » SQL & PL/SQL » update
update [message #600818] Tue, 12 November 2013 17:54 Go to next message
nataliafoster26
Messages: 64
Registered: October 2013
Member
want to update my table
where currency_code is null and inf_src_db='aus'
this is what i have

 
UPDATE PREMIER.S_SALES_CENTER
SET CURRENCY_CODE='USD'
WHERE INF_SRC_DB ='AUS'
AND CURRENCY_CODE=  NULL;





CREATE TABLE PREMIER.S_SALES_CENTER
(
  SALES_CENTER_ID         NUMBER(12)            NOT NULL,
  CASH_DISCOUNT           NUMBER(14,2),
  CURRENCY_CODE           VARCHAR2(3 BYTE),
  MASTER_SALES_CENTER_ID  NUMBER(12),
  DISPATCH_PHONE_NUM      VARCHAR2(20 BYTE),
  INF_SRC_DB              VARCHAR2(3 BYTE)      NOT NULL
)

im i doing the right way, is not working so something is wrong?
Re: update [message #600819 is a reply to message #600818] Tue, 12 November 2013 18:04 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
> is not working so something is wrong?
"not working" is 100% devoid of any actionable detail.
what exactly result when you run posted UPDATE statement?

post results of SQL below
SELECT Count(*) 
FROM   premier.s_sales_center 
WHERE  inf_src_db = 'AUS' 
       AND currency_code = NULL; 
Re: update [message #600820 is a reply to message #600819] Tue, 12 November 2013 18:20 Go to previous messageGo to next message
nataliafoster26
Messages: 64
Registered: October 2013
Member
IT GIVES ME ZERO , WHICH IS WEIRD BECAUSE I SEE SOME THAT ARE NULL
Re: update [message #600821 is a reply to message #600820] Tue, 12 November 2013 18:29 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
post results from SQL below
SELECT INF_SRC_DB, Count(*) 
FROM   premier.s_sales_center 
WHERE  currency_code = NULL; 
GROUP BY    inf_src_db
ORDER BY 1
Re: update [message #600822 is a reply to message #600821] Tue, 12 November 2013 18:32 Go to previous messageGo to next message
nataliafoster26
Messages: 64
Registered: October 2013
Member
I GET INVALID SQL STATEMENT
Re: update [message #600823 is a reply to message #600822] Tue, 12 November 2013 18:34 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
"WHERE currency_code = NULL" is ALWAYS false!
Re: update [message #600824 is a reply to message #600823] Tue, 12 November 2013 18:36 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
SQL> @ssc
SQL> INSERT INTO S_SALES_CENTER (SALES_CENTER_ID,CURRENCY_CODE, INF_SRC_DB)
  2  VALUES(1,NULL,'AUS');

1 row created.

SQL> INSERT INTO S_SALES_CENTER (SALES_CENTER_ID,CURRENCY_CODE, INF_SRC_DB)
  2  VALUES(2,NULL,'AUS');

1 row created.

SQL> INSERT INTO S_SALES_CENTER (SALES_CENTER_ID,CURRENCY_CODE, INF_SRC_DB)
  2  VALUES(3,NULL,'GER');

1 row created.


  1  UPDATE S_SALES_CENTER
  2  SET CURRENCY_CODE='USD'
  3  WHERE INF_SRC_DB ='AUS'
  4* AND CURRENCY_CODE IS  NULL
SQL> /

2 rows updated.


Re: update [message #600825 is a reply to message #600824] Tue, 12 November 2013 18:40 Go to previous messageGo to next message
nataliafoster26
Messages: 64
Registered: October 2013
Member
WHY IS NOT WORKING, THIS IS WEIRD
Re: update [message #600826 is a reply to message #600825] Tue, 12 November 2013 18:41 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
>WHY IS NOT WORKING,
Problem Exists Between Keyboard And Chair!

it worked for me.
See ABOVE!

[Updated on: Tue, 12 November 2013 18:46]

Report message to a moderator

Re: update [message #600827 is a reply to message #600826] Tue, 12 November 2013 18:47 Go to previous messageGo to next message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
It's not working because, as is shown in this thread here, nothing is equal to null.
To find rows where a column is null you have to use IS NULL, not = NULL.
Re: update [message #600829 is a reply to message #600827] Tue, 12 November 2013 19:23 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
>It's not working because, as is shown in this thread here, nothing is equal to null.
"WHERE currency_code = NULL" is ALWAYS false!
>To find rows where a column is null you have to use IS NULL, not = NULL.
4* AND CURRENCY_CODE IS NULL

Is redundancy the best way to teach slow learners?
Re: update [message #600830 is a reply to message #600829] Tue, 12 November 2013 19:48 Go to previous messageGo to next message
nataliafoster26
Messages: 64
Registered: October 2013
Member
THIS IS WHAT I HAVE
UPDATE PREMIER.S_SALES_CENTER
SET CURRENCY_CODE='BPS'
WHERE INF_SRC_DB ='AEU'
AND CURRENCY_CODE IS NULL;
commit;
AND NOT WORKING
Re: update [message #600831 is a reply to message #600830] Tue, 12 November 2013 19:59 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
nataliafoster26 is NOT WORKING!

Please read and follow the forum guidelines, to enable us to help you:

http://www.orafaq.com/forum/t/88153/0/
Re: update [message #600839 is a reply to message #600831] Wed, 13 November 2013 01:13 Go to previous message
Littlefoot
Messages: 21808
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
All day long you've been updating AUS, now you switched to AEU. Is that correct?
Previous Topic: Procedure not running and not even throwing any error
Next Topic: Maximum Date
Goto Forum:
  


Current Time: Thu Apr 25 02:46:20 CDT 2024