Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: student needs help with SQL

Re: student needs help with SQL

From: Nuno Guerreiro <nuno-v-guerreiro_at_telecom.pt>
Date: Wed, 22 Apr 1998 09:18:10 GMT
Message-ID: <353db413.65006404@news.telecom.pt>


On Wed, 22 Apr 1998 06:45:57 GMT, ppym_at_vic.bigpond.net.au (Prescott Pym) wrote:

>Can anyone help me out....
>
>for an assignment we have a table called film which stores info about
>films....what i can't figure out is how to use the insert command to insert
>the year made into a date object, ie
>
>insert into film(film_no, film_name, filmmaker_id, date_added, year_made)
>values('1', 'X-Files Movie', '1', '12 May 1998', TO_CHAR(1998, 'YYYY');
>
>we have to store the date as YYYY, I don't know how to do it..
>
>any help appreciated

If you have defined the fields DATE_ADDED and YEAR_MADE with the datatype DATE when creating the table, then whenever you insert records in the table, the datatypes of the values you're inserting for these fields must be DATE too.

Thus you shouldn't use the TO_CHAR function in this context, since it returns a character datatype, not a DATE.

If you have defined the fields as DATE, then you should issue the following insert statement instead:

insert into film(film_no, film_name, filmmaker_id, date_added, year_made)
values('1', 'X-Files Movie', '1', to_date('12 May 1998','DD Month YYYY'), to_date(1998, 'YYYY'));

Good luck,

Nuno Guerreiro Received on Wed Apr 22 1998 - 04:18:10 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US