Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Other Programming Languages (http://www.programmingforums.org/forum38.html)
-   -   Oracle 10g (http://www.programmingforums.org/showthread.php?t=15527)

A.K.Al Shamsi Apr 1st, 2008 3:35 AM

Oracle 10g
 
hi....
could anybody help me???

oracle is driving me to maddness :@...

for project i have to create tables and indetify their primary keys and foreign keys so i entered values for primary keys in this part everything went good...

but for other fields, i couldn't if i typed this code
:


INSERT INTO tbl_lease (lease_name, rental_amount, lease_signdate, begin_date, end_date)
VALUES ('Gardern1', '120 000', '1-Jan-2008', '10-Jan-2008', '10-Jan-2009');

it gave my error for missing comma


and for this code it gave me not enough values
:


INSERT INTO tbl_lease VALUES ('Gardern1', '120 000', '1-Jan-2008', '10-Jan-2008', '10-Jan-2009');



i am lost i have to finish this database soon :'(

Infinite Recursion Apr 1st, 2008 7:59 AM

Re: Oracle 10g
 
What does this return:

desc tbl_lease;

A.K.Al Shamsi Apr 1st, 2008 8:36 AM

Re: Oracle 10g
 
the fields' names and data type

big_k105 Apr 1st, 2008 8:56 AM

Re: Oracle 10g
 
I think IR was looking for you to post the output of desc tbl_lease;

A.K.Al Shamsi Apr 1st, 2008 12:29 PM

Re: Oracle 10g
 
?????????????:?:

Infinite Recursion Apr 1st, 2008 1:06 PM

Re: Oracle 10g
 
Hah. We need to see the results of that 'desc' command in order to help you.

A.K.Al Shamsi Apr 2nd, 2008 2:57 AM

Re: Oracle 10g
 
http://www.moq3.com/img/17012008/OEB22927.bmp

here it is

Infinite Recursion Apr 2nd, 2008 7:48 AM

Re: Oracle 10g
 
Your first problem regarding the missing comma is because the RENTAL_AMOUNT is defined
as "120 000", there is no such value that is a number. You have use a comma or remove the space:
120,000 or 120000. The insert command you listed will still fail after you fix the comma problem,
with your next problem regarding the amount of values.

Your table has 6 fields, you only supply 5 values. My assumption is that you left out the LEASE_NAME
value in your insert statement, so just append that on the end of your insert statement and it will work.

For example:

INSERT INTO tbl_lease (lease_name, rental_amount, lease_signdate, begin_date, end_date)
VALUES ('Gardern1', '120000', '1-Jan-2008', '10-Jan-2008', '10-Jan-2009','Test');

I simply removed the space from the RENTAL_AMOUNT and added a value (Test) for LEASE_NAME.

A.K.Al Shamsi Apr 2nd, 2008 9:29 AM

Re: Oracle 10g
 
first i tried insert command for lease_id to check if it is going to work or not so it worked but when i tried to add other values it didn't work, notice that i selected the fields.... so should i drop the tables and create them again?? would that fix the problem??

Infinite Recursion Apr 2nd, 2008 10:01 AM

Re: Oracle 10g
 
Sorry for my initial posts... they were a bit inaccurate. I missed the part where you were defining which rows you wanted to insert into. I think a large part of your problem is that the numeric you are entering for rental_amount is enclosed in quotes (its not a string, so they need to be removed), the space in the rental_amount still needs to be removed, then you will need to make sure your dates are in the correct format that Oracle expects.

I recreated your table in MySQL and added a line to test...

:

mysql> desc tbl_lease;
+----------------+---------------+------+-----+---------+-------+
| Field          | Type          | Null | Key | Default | Extra |
+----------------+---------------+------+-----+---------+-------+
| LEASE_ID      | char(14)      | NO  |    |        |      |
| RENTAL_AMOUNT  | decimal(10,0) | YES  |    | NULL    |      |
| BEGIN_DATE    | date          | YES  |    | NULL    |      |
| END_DATE      | date          | YES  |    | NULL    |      |
| LEASE_SIGNDATE | date          | YES  |    | NULL    |      |
| LEASE_NAME    | varchar(15)  | YES  |    | NULL    |      |
+----------------+---------------+------+-----+---------+-------+
6 rows in set (0.05 sec)

mysql> INSERT INTO tbl_lease VALUES ('Gardern1', 120000, '2008-01-01', '2008-01-10', '2009-01-10','Test');
Query OK, 1 row affected (0.00 sec)

mysql> select * from tbl_lease;
+----------+---------------+------------+------------+----------------+------------+
| LEASE_ID | RENTAL_AMOUNT | BEGIN_DATE | END_DATE  | LEASE_SIGNDATE | LEASE_NAME |
+----------+---------------+------------+------------+----------------+------------+
| Gardern1 |        120000 | 2008-01-01 | 2008-01-10 | 2009-01-10    | Test      |
+----------+---------------+------------+------------+----------------+------------+
1 row in set (0.00 sec)



All times are GMT -5. The time now is 10:02 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC