Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 27-05-2009
Member
 
Join Date: May 2009
Posts: 15
Insert values to tables in SQL

i had do a table and insert all values in it ..

after that i had alter it and add 2 new columns ( username, password)

now i am trying to add values to these coulmns..

but for each emplouee saparedly..

i mean .. as example :

emp1= CPR: 85236941 , name: salem , phone:123456

i want to insert for him a ( username, password)

i tried :

Quote:
INSERT INTO EMPLOYEE (USERNAME,PASSWORD)
VALUES ('SALEM','123456')
WHERE ECPR= '77102345';
but it was wrong and SQL siad:
ORA-00933: SQL command not properly ended

what to do ??
Reply With Quote
  #2  
Old 27-05-2009
Member
 
Join Date: May 2009
Posts: 1
Re: Insert values to tables in SQL

Hi,
You have altered the table already.
Now you want to add the information for record Username & password for a particular record in a table.
For this you need to fire an update query & not the insert query.

SQL UPDATE Syntax:
Quote:
UPDATE table_name
SET column1=value, column2=value2,...
WHERE some_column=some_value
In your case.

Quote:
UPDATE EMPLOYEE
SET USERNAME='SALEM', PASSWORD='123456'
WHERE ECPR='7710234'
I hope this helps.
Since I am also learning SQL.
Reply With Quote
  #3  
Old 27-05-2009
Member
 
Join Date: Mar 2008
Posts: 227
Re: Insert values to tables in SQL

General format to insert the values in the SQL Table is to INSERT INTO
Code:
Store_Information (store_name, Sales, Date)
VALUES ('Los Angeles', 900, 'Jan-10-1999')
even you have also used the proper convention to use in your program but the only problem which i sees on top is that for the password value also you have inserted single quote which is not required for numbers, try removing quote and try to run the program again.
Reply With Quote
  #4  
Old 27-05-2009
Member
 
Join Date: May 2009
Posts: 15
Re: Insert values to tables in SQL

thax alot bro.NoelDressy..

i had not check it yet.. cause i leave uni. ,, but a think it is a good Suggestion i will check it later.

bro. DIID ..
i tried to but it with and without the single qutes .. and it still refuse entering it .. and the real problem is to insert new values to new columns for a spacific record that had ( CPR = ........) .
Reply With Quote
  #5  
Old 27-05-2009
Member
 
Join Date: Mar 2008
Posts: 227
Re: Insert values to tables in SQL

What all other programs similar to the mentioned above have you tried, have they worked properly? or have the same problem if this is the problem then you need to start it from the scratch, or else you just post here all the program steps and let me check out.
Reply With Quote
  #6  
Old 28-05-2009
Member
 
Join Date: May 2009
Posts: 15
Re: Insert values to tables in SQL

Hi,
bro. i had check this one:

SQL> UPDATE EMPLOYEE
2 SET USERNAME='SALEM',PASSWORD='123456'
3 WHERE ECPR='7710234';

0 rows updated.

and as you can see nothing had updated !!

bro. DIID ,,

i will put my program to you:
CREATE TABLE EMPLOYEE
(ECPR number(9),
NAME VARCHAR2(15),
ADDR VARCHAR2(40) ,
PHONE VARCHAR2(9),
TYPE CHAR(1),
username varchar2(15),
password varchar2(15),

CONSTRAINT EPK PRIMARY KEY (ECPR)
);

ones in red i had add them after inserting data into table.. now i am trying to add data to these coulmns for each employee saparetly..

INSERT INTO EMPLOYEE VALUES
(77102345, 'SALEM', 'SITRA-BAHRAIN', '55-940467', 'M');

and then try the above code to add and it dose not work too :'(
Reply With Quote
  #7  
Old 28-05-2009
Member
 
Join Date: May 2009
Posts: 15
Re: Insert values to tables in SQL



I was putting a wrong CPR NO, so it was not work for me !!

i had do it now.. so thanx alot all of you brothers
Reply With Quote
  #8  
Old 30-05-2009
Member
 
Join Date: Mar 2008
Posts: 227
Re: Insert values to tables in SQL

Hi CS,

Sorry to be little bit late, i read your earlier message then the last one, when i see your earlier message in that your program seems to be very perfect,and it should run, then i went for your last message where you have solved your problem. That's nice, It's good that you solved your query by yourself.

Hope you will post your problem next time when you have doubt.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Insert values to tables in SQL"
Thread Thread Starter Forum Replies Last Post
W32 registry values are not getting matched by the default values Angrzej Networking & Security 5 19-05-2011 12:23 PM
VPN and routing tables Allison Networking & Security 4 25-11-2010 01:02 AM
How to use Tables in Java? Rob Dizzle Software Development 4 11-02-2010 07:04 AM
Subtraction between two SQL tables KADRI Software Development 3 08-12-2009 05:49 PM
SQL - Update via 2 Tables Bantu Software Development 3 19-01-2009 08:39 PM


All times are GMT +5.5. The time now is 12:53 PM.