ORA-00907: Missing right parenthesis, but why?

Asked

Viewed 307 times

-2

I was already having problems creating this table in relation to time, but finally, with help I managed to solve the problem. In the end I came across another mistake, but I don’t understand why.

Follows the code:

create table horario (
codhorario number (8) primary key,
horainicio DATE to_char (horainicio, 'hh24:mi'),
horafim DATE to_char (horafim, 'hh24:mi'));

My mistake:

ORA-00907: missing right parenthesis

I researched on the internet about and ended up finding that it could be more or less parentheses, but that could also be syntax error. Anyone can help?

  • 1

    Why to call the to_char function when creating a table?

  • Hmm I don’t know exactly how to implement it, I thought it was in this format. How would it be then?

  • You want a field to save hours?

  • This, 2 in the case of start and end. But it seems to_char is in the wrong place.

  • to_char returns a string, but the field is a DATE, then it no longer makes sense. If you want to keep only the hours, there are some alternatives

1 answer

0


The correct would be to store the full date:

create table horario ( codhorario number(8) , horainicio DATE, horafim
DATE );

In case you only wanted it an hour and a minute later. Through select vc you can get the data.

select to_char(horainicio , 'hh24:mi') as horainicio ,
       to_char(horafim, 'hh24:mi') as horafim,
from horario 

Browser other questions tagged

You are not signed in. Login or sign up in order to post.