Unable to insert date to table [closed] - oracle

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I'm trying to insert a date into oracle table using below
SQL> insert into temp (tst,thistime) values ('test3',TO_DATE('MM/DD/YYYY HH24:MI
:SS','01/01/2014 16:45:45') );
but its giving below error
ERROR at line 1:
ORA-01821: date format not recognized
Below is the description of table
SQL> describe temp;
Name Null? Type
----------------------------------------- -------- ---------------------------
TST VARCHAR2(10)
THISTIME DATE

Use the insert . . . select form of insert:
insert into temp (tst, thistime)
select 'test3', TO_DATE('01/01/2014 16:45:45', 'MM/DD/YYYY HH24:MI:SS')
from dual;
In addition to having the arguments backwards for to_date(), values doesn't evaluate expressions that belong in a select statement.

Related

ORA-00907: missing right parenthesis, What could be the problem? [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 4 years ago.
Improve this question
I try to add a constraint , but it gave me the error
ORA-00907: missing right parenthesis
What could be the problem?
CREATE TABLE "BDCOMEARE"."PILOTE" (
"matrPlt" INTEGER NOT NULL ,
"nomPlt" VARCHAR2(50) ,
"prenomPlt" VARCHAR2(50) ,
"gradePlt" VARCHAR2(100) ,
"adressePlt" VARCHAR2(100) ,
"salairePlt" NUMBER(10,2) ,
"dateEmbauche" DATE ,
PRIMARY KEY ("matrPlt")
)
ALTER TABLE PILOTE ADD CONSTRAINT check_gradePlt
CHECK (gradePlt IN 'commandantBord', 'assistantBord','officier');
Just that you need brackets after IN clause
CONSTRAINT check_gradePlt CHECK (
gradePlt IN ('commandantBord', 'assistantBord', 'officier')
);

invalid trigger specification in oracle [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
DROP TABLE a CASCADE CONSTRAINTS;
CREATE TABLE a(
cyear VARCHAR2(4));
CREATE TRIGGER current_year
BEFORE INSERT ON cyear
FOR EACH ROW SET NEW.year = year(NOW());
EDIT:
I tried this,
CREATE TRIGGER current_year
BEFORE INSERT ON a
FOR EACH ROW
BEGIN
:NEW.cyear = TO_CHAR(SYSDATE, 'YYYY');
END current_year;
I keep getting the PLS-00103 error.
Trigger created on tables, not on columns
In Oracle variables are not assigned with SET
There is no build-in function called NOW in Oracle
NEW and OLD are accessible only in WHEN clause; in other places they should be preceded by colon (:NEW, :OLD)
END keyword is missed at the end (and BEGIN in the beginning of the trigger body)

Why do I get ORA:0922 error:missing or invalid option [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
Whats wrong with the following procedure?? I have checked the code for syntax errors but I m unable to find one.
CREATE OR REPLACE Edit_premium_amt
(
policy_number IN number(4),
new_premium_type IN varchar2(4)
)
IS
discount_amount number(6,2);
premium_amts number(11,2);
policy_amts number(11);
dur number(5);
prem_type varchar2(4);
disc_weigh varchar2(2);
disc_perc number(2);
prem_type_int number(2,1);
BEGIN
prem_type:=new_premium_type;
UPDATE policy SET premium_type=new_premium_type WHERE policy_id=policy_number;
SELECT policy_amt,duration INTO policy_amts,dur WHERE policy_id=policy_number;
SELECT disc_weightage INTO disc_weigh FROM disc_details WHERE duration=dur;
SELECT percent INTO disc_perc FROM disc_calculation WHERE premium_type=prem_type AND
weightage=disc_weigh;
CASE prem_type
WHEN 'HY' THEN prem_type_int:=2.0;
WHEN 'Y' THEN prem_type_int:=1.0;
ELSE prem_type_int:=0.5;
END CASE;
discount_amount:= ((policy_amts)/dur)/prem_type_int))*disc_perc;
premium_amts:=policy_amts-discount_amount;
UPDATE policy SET premium_amt=premium_amts
WHERE policy_id=policy_number;
END Edit_premium_amt;
You must say what you are creating or replacing
In this case CREATE OR REPLACE PROCEDURE Edit_premium_amt............

Trying to create a table, but it comes up with this error [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I am new to mysql and I can't really figure out as to why I keep on getting the missing right parenthesis error from this code:
/*second oracle program */
/*Franklin Tong */
set echo on
spool c:hw3.text
drop table student;
create table student(
snn char(9),
lastname char(10),
firstname char(10),
major char(10),
GPA number(3,2)
DOB date
);
insert into student (111,Smith,Johnny,IS,3.41,5/18/82);
insert into student (102,Smith,Jack,FIN,3.25,3/11/80);
select * from student;
spool off
system returns a message saying:
error at line 7
ora-00907: missing right parathesis
You are missing a ',' after 'GPA number(3,2)'.
You should put a comma ',' after 'GPA number(3,2)'.

Convert Row into columns [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
how can I convert rows of my table as column value
for eg I have a table a
emp id
1
2
3
4
and I want my output as
1 2 3 4
i am also using pivot in oracle and crosstab in postgres but not able to get desired solution as shown above.
Check the listagg function. Note you need at least Oracle 11 for this.
Use this script and change it to your values to get desired results
SELECT * FROM (SELECT emp_id, emp_points
FROM emp_data)
PIVOT (
SUM(emp_points) AS sum_emp_points
FOR (emp_id) IN (1 AS [1], 2 AS [2],3 AS [3],4 AS [4])
);
select * from (select empno from t7) pivot(min(empno) for empno in (1,2,3,4));

Resources