INSERT文のエラーにつきまして質問です。

実現したいこと

SELECT NVL(MONTHS_BETWEEN(SYSDATE, hiredate), SYSDATE) FROM employees;の文でエラーが出ないか確認したいのですが、その文を確認する為のINSERT文のエラーを解決したいです。
お手数ですがご教授お願いできますでしょうか。

前提

実際に確認してみようと思い
emp_id のNUMBER型、 hire_date がDATE型のemp表を作り、適当なデータをINSERTしようとしました。しかし、INSERT文でエラーが出てしまい、SELECT文の確認ができません。

発生している問題・エラーメッセージ

Cause ;The identifier or column name entered was invalid.

Action :Ensure the following: Enter a valid identifier or column name and verify that there are no typos in the identifier or column name. A valid identifier must begin with a letter, be less than or equal to 128 characters, and consist of only alphanumeric characters and the special characters $, _, and #. If it contains other characters, then it must be enclosed in double quotation marks. It must not be a reserved word unless it is enclosed in double quotation marks. If double quotation marks and mixed case were used for a column name when creating the table, then references to that column must use matching case and quotation marks.

該当のソースコード

CREATE TABLE emp( emp_id NUMBER(4) NOT NULL, hire_date DATE ); INSERT INTO emp(emp_id, hire_date) VALUES (1, TO_DATE('19-07-01 00:00:00', 'YY-MM-DD HH24:MI:SS') );

試したこと

VALUES (1, TO_DATE('19-07-01 00:00:00', 'YY-MM-DD HH24:MI:SS') );ではなく、VALUES (1,19-07-01);でデータだけ入れてみましたが、以下のエラーがでました。

Cause An unexpected token was encountered in the SQL statement at or near the position printed in the error message. A token is either a SQL keyword or an identifier. One of the following occurred: You had a typo in your SQL statement. Unsupported syntax was encountered for a clause in the statement. An unsupported clause was encountered in the statement. A string was terminated prematurely leading to the rest of the string to be interpreted as tokens. For example, an apostrophe in the string may be causing it to end prematurely.

参考サイト

https://oreno-it.info/archives/2496

コメントを投稿

0 コメント