Oracle SQL: Missing right parenthesis - oracle

I'm migrating a database from mySQL to Oracle SQL but I'm getting a "ORA-00907: missing right parenthesis" error when creating a table. I've tried everything I can think of but still keep getting the same error.
Create table statement:
CREATE TABLE menu
(id int(11) NOT NULL AUTO_INCREMENT,
restaurant_id varchar(30) DEFAULT NULL,
menu_name varchar(30) DEFAULT NULL,
menu_description varchar(500) DEFAULT NULL,
menu_price varchar(30) DEFAULT NULL,
quantity int(11) DEFAULT '1',
PRIMARY KEY (id))
I think the problem is with the PRIMARY KEY as it's only table with PRIMARY KEYs that I get the error on. Apologies if this is an obvious question, I'm new to Oracle SQL. Thanks in advance!

Oracle != MySQL:
CREATE TABLE menu
( id number(11,0) GENERATED AS IDENTITY, --IDENTITY <=> AUTO_INCREMENT
restaurant_id varchar2(30) DEFAULT NULL, --VARCHAR2 instead of VARCHAR
menu_name varchar2(30) DEFAULT NULL,
menu_description varchar2(500) DEFAULT NULL,
menu_price varchar2(30) DEFAULT NULL,
quantity number(11,0) DEFAULT '1', --NUMBER(11,0) instead of INT(11)
PRIMARY KEY (id)
);

Related

Unable to extract JDBC value for position `3`

I am switching from MYSQL to ORACLE.
I have JPA Authentication setup like this:
#Override
#Transactional(readOnly = true)
public UserDetails loadUserByUsername(String email) throws UsernameNotFoundException {
AppUser user = userRepository.findByUseremailIgnoreCase(email);
With MySQL all works fine. But for Oracle, during login using JPA authentication I am getting this exception.
org.springframework.security.authentication.InternalAuthenticationServiceException: Unable to extract JDBC value for position `3`
Followed by these exceptions:
Caused by: org.springframework.orm.jpa.JpaSystemException: Unable to extract JDBC value for position `3`
Caused by: java.sql.SQLException: Invalid conversion requested
Caused by: java.lang.IllegalArgumentException: Timestamp format must be yyyy-mm-dd hh:mm:ss[.fffffffff]
Any clue what I am missing and where to debug?
My table structure is as per below:
create table CONTENTPLUSPLUS.app_user (
id NUMBER GENERATED ALWAYS as IDENTITY(START with 1 INCREMENT by 1) NOT NULL,
useremail VARCHAR(150) NOT NULL,
userpassword VARCHAR(150) NOT NULL,
useruuid VARCHAR(50) NOT NULL,
userfirstname VARCHAR(150) NOT NULL,
userlastname VARCHAR(150) NOT NULL,
userenabled NUMBER(1) DEFAULT 0 NOT NULL,
created_by VARCHAR(150) NOT NULL,
created_date VARCHAR(150) NOT NULL,
modified_by VARCHAR(150) NOT NULL,
modified_date VARCHAR(150) NOT NULL,
CONSTRAINT appuser_pk PRIMARY KEY (id), UNIQUE (useremail, useruuid));
create table CONTENTPLUSPLUS.app_role(
id NUMBER GENERATED ALWAYS as IDENTITY(START with 1 INCREMENT by 1) NOT NULL,
name VARCHAR(150) NOT NULL,
CONSTRAINT approle_pk PRIMARY KEY (id),UNIQUE (name));
CREATE TABLE CONTENTPLUSPLUS.app_department (
id NUMBER GENERATED ALWAYS as IDENTITY(START with 1 INCREMENT by 1) NOT NULL,
departmentuuid VARCHAR(150),
departmentheadname varchar(255) NOT NULL,
departmentheademail varchar(255) NOT NULL,
departmentname varchar(255) NOT NULL,
userid NUMBER NOT NULL,
created_by VARCHAR(150) NOT NULL,
created_date VARCHAR(150) NOT NULL,
modified_by VARCHAR(150) NOT NULL,
modified_date VARCHAR(150) NOT NULL,
CONSTRAINT appdepartment_pk PRIMARY KEY (id),UNIQUE (departmentname, departmentuuid));
CREATE TABLE CONTENTPLUSPLUS.app_user_department (
userid NUMBER NOT NULL,
departmentid NUMBER NOT NULL
);
ALTER TABLE CONTENTPLUSPLUS.app_user_department ADD CONSTRAINT FK_AUSERDEPTUSERID FOREIGN KEY (userid) REFERENCES app_user (id);
ALTER TABLE CONTENTPLUSPLUS.app_user_department ADD CONSTRAINT FK_AUSERDEPTDEPTID FOREIGN KEY (departmentid) REFERENCES app_department (id);
ALTER TABLE CONTENTPLUSPLUS.app_department ADD CONSTRAINT FK_AUSERUSERID FOREIGN KEY (userid) REFERENCES app_user (id);
CREATE TABLE CONTENTPLUSPLUS.app_user_role (
id NUMBER GENERATED ALWAYS as IDENTITY(START with 1 INCREMENT by 1) NOT NULL,
userid NUMBER NOT NULL,
roleid NUMBER NOT NULL,
CONSTRAINT appuserrole_pk PRIMARY KEY (id));
ALTER TABLE CONTENTPLUSPLUS.app_user_role ADD CONSTRAINT FK_AURUSERID FOREIGN KEY (userid) REFERENCES app_user (id);
ALTER TABLE CONTENTPLUSPLUS.app_user_role ADD CONSTRAINT FK_AURROLEID FOREIGN KEY (roleid) REFERENCES app_role (id);
Below is the query which gets fired during the login operation (shows up only for MySQL):
Hibernate:
select
a1_0.id,
a1_0.created_by,
a1_0.created_date,
a1_0.modified_by,
a1_0.modified_date,
a1_0.useremail,
a1_0.userenabled,
a1_0.userfirstname,
a1_0.userlastname,
a1_0.userpassword,
a1_0.useruuid
from
app_user a1_0
where
upper(a1_0.useremail)=upper(?)
Hibernate:
select
r1_0.userid,
r1_1.id,
r1_1.name
from
app_user_role r1_0
join
app_role r1_1
on r1_1.id=r1_0.roleid
where
r1_0.userid=?
You map Date in Java with VARCHAR2 in SQL: bad idea. You probably get lucky with the default conversion format of TS and the locale in MySQL: back to my first comment... look at the SQL Office Hours session code...

ORA-00903: invalid table name when Creating Table

Please help. I'm not sure what is happening. I even tried to drop table but still unsuccessful.
CREATE TABLE 'customer' (
'customer_id' int NOT NULL AUTO_INCREMENT,
'type' varchar(45) NOT NULL,
'name' varchar(45) NOT NULL,
'cut_off' int NOT NULL,
PRIMARY KEY ('customer_id')
)
Error starting at line : 1 in command -
CREATE TABLE 'customer' (
'customer_id' int NOT NULL AUTO_INCREMENT,
'type' varchar(45) NOT NULL,
'name' varchar(45) NOT NULL,
'cut_off' tinyint NOT NULL,
PRIMARY KEY ('customer_id')
)
Error report -
ORA-00903: invalid table name
00903. 00000 - "invalid table name"
*Cause:
*Action:
Column and table names should be without quotes.
Refer to create table query https://docs.oracle.com/cd/B28359_01/server.111/b28310/tables003.htm#ADMIN11004
There are multiple issues in your code.
Names of table and columns should not be wrapped in single quotes.
AUTO_INCREMENT keyword is not allowed. It should be implemented differently in oracle.
NOT NULL is not needed on PK column. It is implicit.
Corrected code:
CREATE TABLE customer (
customer_id int GENERATED always as IDENTITY,
type varchar(45) NOT NULL,
name varchar(45) NOT NULL,
cut_off int NOT NULL,
primary key(customer_id)
);

Name already existing error in SQL Developer

I got some help last night on this code but now I am getting a different error. My professor is STILL not answering me so I am coming to you guys. Here is the code:
--Create Volunteer Supervisor
CREATE TABLE Volunteer_Supervisor
(
PH_Person_ID Number(10) NOT NULL,
EM_Person_ID Number(10) NOT NULL,
VO_Person_ID Number(10) NOT NULL,
End_Date Date NOT NULL,
Begin_Date Date NOT NULL,
Hours_Worked Number(4) NULL,
PWork_Unit_ID Number(4) NULL,
PRIMARY KEY (PWork_Unit_ID),
CONSTRAINT CCPHPersonID_FK FOREIGN KEY (PH_Person_ID) References Physician (PH_Person_ID),
CONSTRAINT CCEMPersonID_FK FOREIGN KEY (EM_Person_ID) References Employee (EM_Person_ID),
CONSTRAINT CCVOPersonID_FK FOREIGN KEY (VO_Person_ID) References Volunteer (VO_Person_ID),
CONSTRAINT CCPWorkUnitID_PK FOREIGN KEY (PWork_Unit_ID) References Work_Unit (PWork_Unit_ID)
);
Now I have changed the names but still getting this error:
Error report -
ORA-00955: name is already used by an existing object
00000 - "name is already used by an existing object"
*Cause:
*Action:
What am I missing?
If you are sure that no such table Volunteer_Supervisor exists, You may try below code -
CREATE TABLE Volunteer_Supervisor
(
PH_Person_ID Number(10) NOT NULL,
EM_Person_ID Number(10) NOT NULL,
VO_Person_ID Number(10) NOT NULL,
End_Date Date NOT NULL,
Begin_Date Date NOT NULL,
Hours_Worked Number(4) NULL,
PWork_Unit_ID Number(4) NULL,
PRIMARY KEY (PWork_Unit_ID),
FOREIGN KEY (PH_Person_ID) References Physician (PH_Person_ID),
FOREIGN KEY (EM_Person_ID) References Employee (EM_Person_ID),
FOREIGN KEY (VO_Person_ID) References Volunteer (VO_Person_ID),
FOREIGN KEY (PWork_Unit_ID) References Work_Unit (PWork_Unit_ID)
);

Pentaho Initialization Exception Error _0014 on starting Pentaho 6.1

I'm trying to install Pentaho BA on CentOS 7 with Java 1.8
I downloaded the Community Edition 6.1.0.1-196. I run ./start-pentaho.sh and after correcting some bugs, everything worked.
Then I decided to Use Oracle as Repository and by following this guide : https://help.pentaho.com/Documentation/5.4/0F0/0K0/040/0C0#title
I change some files.
When I changed Hibernate and Quartz everything were fine. Then I modified Jackrabbit ( repository.xml ) and context.xml and the error came up:
ERROR [org.pentaho.platform.util.logging.Logger] misc-org.pentaho.platform.engine.core.system.PentahoSystem: org.pentaho.platform.api.engine.PentahoSystemException: PentahoSystem.ERROR_0014 - Error while trying to execute startup sequence for org.pentaho.platform.engine.services.connection.datasource.dbcp.DynamicallyPooledDatasourceSystemListener
org.pentaho.platform.api.engine.PentahoSystemException: org.pentaho.platform.api.engine.PentahoSystemException: PentahoSystem.ERROR_0014 - Error while trying to execute startup sequence for org.pentaho.platform.engine.services.connection.datasource.dbcp.DynamicallyPooledDatasourceSystemListener
Now it's not even starting and the page looks like the image.
What did I put on the repository, or better what I changed is the password and the url.
I changed the url from jdbc:oracle:thin:#localhost:1521/XE to jdbc:oracle:thin:#hostname:port/servername or jdbc:oracle:thin:#hostname:port:servername but none of them are working.
Before that, I create the repository and the 3 user as explained in the guide:
--THIS USER IS SPECIFIC TO THE DATABASE WHERE THIS SCRIPT IS TO BE RUN AND
--IT SHOULD BE A USER WITH DBA PRIVS.
--AND ALSO #pentaho should be replaced with the correct instance name
--
--NOTE: run create_repository_ora.sql before running this script, which
-- creates the pentaho_tablespace
-- conn admin/password#pentaho
drop user quartz cascade;
create tablespace pentaho_tablespace
logging
datafile 'ptho_ts.dbf'
size 32m
autoextend on
next 32m maxsize 2048m
extent management local;
create user quartz identified by "password" default tablespace pentaho_tablespace quota unlimited on pentaho_tablespace temporary tablespace temp quota 5M on system;
grant create session, create procedure, create table to quartz;
--CREATE QUARTZ TABLES
CONN quartz/password
CREATE TABLE QRTZ5_JOB_DETAILS
(
JOB_NAME VARCHAR2(200) NOT NULL,
JOB_GROUP VARCHAR2(200) NOT NULL,
DESCRIPTION VARCHAR2(250) NULL,
JOB_CLASS_NAME VARCHAR2(250) NOT NULL,
IS_DURABLE VARCHAR2(1) NOT NULL,
IS_VOLATILE VARCHAR2(1) NOT NULL,
IS_STATEFUL VARCHAR2(1) NOT NULL,
REQUESTS_RECOVERY VARCHAR2(1) NOT NULL,
JOB_DATA BLOB NULL,
PRIMARY KEY (JOB_NAME,JOB_GROUP)
);
CREATE TABLE QRTZ5_JOB_LISTENERS
(
JOB_NAME VARCHAR2(200) NOT NULL,
JOB_GROUP VARCHAR2(200) NOT NULL,
JOB_LISTENER VARCHAR2(200) NOT NULL,
PRIMARY KEY (JOB_NAME,JOB_GROUP,JOB_LISTENER),
FOREIGN KEY (JOB_NAME,JOB_GROUP)
REFERENCES QRTZ5_JOB_DETAILS(JOB_NAME,JOB_GROUP)
);
CREATE TABLE QRTZ5_TRIGGERS
(
TRIGGER_NAME VARCHAR2(200) NOT NULL,
TRIGGER_GROUP VARCHAR2(200) NOT NULL,
JOB_NAME VARCHAR2(200) NOT NULL,
JOB_GROUP VARCHAR2(200) NOT NULL,
IS_VOLATILE VARCHAR2(1) NOT NULL,
DESCRIPTION VARCHAR2(250) NULL,
NEXT_FIRE_TIME number(13) NULL,
PREV_FIRE_TIME number(13) NULL,
PRIORITY NUMBER(13) NULL,
TRIGGER_STATE varchar2(16) NOT NULL,
TRIGGER_TYPE varchar2(8) NOT NULL,
START_TIME number(13) NOT NULL,
END_TIME number(13) NULL,
CALENDAR_NAME VARCHAR2(200) NULL,
MISFIRE_INSTR number(2) NULL,
JOB_DATA BLOB NULL,
PRIMARY KEY (TRIGGER_NAME,TRIGGER_GROUP),
FOREIGN KEY (JOB_NAME,JOB_GROUP)
REFERENCES QRTZ5_JOB_DETAILS(JOB_NAME,JOB_GROUP)
);
CREATE TABLE QRTZ5_SIMPLE_TRIGGERS
(
TRIGGER_NAME VARCHAR2(200) NOT NULL,
TRIGGER_GROUP VARCHAR2(200) NOT NULL,
REPEAT_COUNT number(7) NOT NULL,
REPEAT_INTERVAL number(12) NOT NULL,
TIMES_TRIGGERED NUMBER(10) NOT NULL,
PRIMARY KEY (TRIGGER_NAME,TRIGGER_GROUP),
FOREIGN KEY (TRIGGER_NAME,TRIGGER_GROUP)
REFERENCES QRTZ5_TRIGGERS(TRIGGER_NAME,TRIGGER_GROUP)
);
CREATE TABLE QRTZ5_CRON_TRIGGERS
(
TRIGGER_NAME VARCHAR2(200) NOT NULL,
TRIGGER_GROUP VARCHAR2(200) NOT NULL,
CRON_EXPRESSION VARCHAR2(120) NOT NULL,
TIME_ZONE_ID varchar2(80),
PRIMARY KEY (TRIGGER_NAME,TRIGGER_GROUP),
FOREIGN KEY (TRIGGER_NAME,TRIGGER_GROUP)
REFERENCES QRTZ5_TRIGGERS(TRIGGER_NAME,TRIGGER_GROUP)
);
CREATE TABLE QRTZ5_BLOB_TRIGGERS
(
TRIGGER_NAME VARCHAR2(200) NOT NULL,
TRIGGER_GROUP VARCHAR2(200) NOT NULL,
BLOB_DATA BLOB NULL,
PRIMARY KEY (TRIGGER_NAME,TRIGGER_GROUP),
FOREIGN KEY (TRIGGER_NAME,TRIGGER_GROUP)
REFERENCES QRTZ5_TRIGGERS(TRIGGER_NAME,TRIGGER_GROUP)
);
CREATE TABLE QRTZ5_TRIGGER_LISTENERS
(
TRIGGER_NAME VARCHAR2(200) NOT NULL,
TRIGGER_GROUP VARCHAR2(200) NOT NULL,
TRIGGER_LISTENER VARCHAR2(200) NOT NULL,
PRIMARY KEY(TRIGGER_NAME,TRIGGER_GROUP,TRIGGER_LISTENER),
FOREIGN KEY (TRIGGER_NAME,TRIGGER_GROUP)
REFERENCES QRTZ5_TRIGGERS(TRIGGER_NAME,TRIGGER_GROUP)
);
CREATE TABLE QRTZ5_CALENDARS
(
CALENDAR_NAME VARCHAR2(200) NOT NULL,
CALENDAR BLOB NOT NULL,
PRIMARY KEY (CALENDAR_NAME)
);
CREATE TABLE QRTZ5_PAUSED_TRIGGER_GRPS
(
TRIGGER_GROUP VARCHAR2(200) NOT NULL,
PRIMARY KEY (TRIGGER_GROUP)
);
CREATE TABLE QRTZ5_FIRED_TRIGGERS
(
ENTRY_ID varchar2(95) NOT NULL,
TRIGGER_NAME VARCHAR2(200) NOT NULL,
TRIGGER_GROUP VARCHAR2(200) NOT NULL,
IS_VOLATILE varchar2(1) NOT NULL,
INSTANCE_NAME VARCHAR2(200) NOT NULL,
FIRED_TIME number(13) NOT NULL,
PRIORITY NUMBER(13) NOT NULL,
STATE varchar2(16) NOT NULL,
JOB_NAME VARCHAR2(200) NULL,
JOB_GROUP VARCHAR2(200) NULL,
IS_STATEFUL varchar2(1) NULL,
REQUESTS_RECOVERY varchar2(1) NULL,
PRIMARY KEY (ENTRY_ID)
);
CREATE TABLE QRTZ5_SCHEDULER_STATE
(
INSTANCE_NAME VARCHAR2(200) NOT NULL,
LAST_CHECKIN_TIME number(13) NOT NULL,
CHECKIN_INTERVAL number(13) NOT NULL,
PRIMARY KEY (INSTANCE_NAME)
);
CREATE TABLE QRTZ5_LOCKS
(
LOCK_NAME varchar2(40) NOT NULL,
PRIMARY KEY (LOCK_NAME)
);
INSERT INTO QRTZ5_LOCKS values('TRIGGER_ACCESS');
INSERT INTO QRTZ5_LOCKS values('JOB_ACCESS');
INSERT INTO QRTZ5_LOCKS values('CALENDAR_ACCESS');
INSERT INTO QRTZ5_LOCKS values('STATE_ACCESS');
INSERT INTO QRTZ5_LOCKS values('MISFIRE_ACCESS');
create index idx_QRTZ5_j_req_recovery on QRTZ5_job_details(REQUESTS_RECOVERY);
create index idx_QRTZ5_t_next_fire_time on QRTZ5_triggers(NEXT_FIRE_TIME);
create index idx_QRTZ5_t_state on QRTZ5_triggers(TRIGGER_STATE);
create index idx_QRTZ5_t_nft_st on QRTZ5_triggers(NEXT_FIRE_TIME,TRIGGER_STATE);
create index idx_QRTZ5_t_volatile on QRTZ5_triggers(IS_VOLATILE);
create index idx_QRTZ5_ft_trig_name on QRTZ5_fired_triggers(TRIGGER_NAME);
create index idx_QRTZ5_ft_trig_group on QRTZ5_fired_triggers(TRIGGER_GROUP);
create index idx_QRTZ5_ft_trig_nm_gp on QRTZ5_fired_triggers(TRIGGER_NAME,TRIGGER_GROUP);
create index idx_QRTZ5_ft_trig_volatile on QRTZ5_fired_triggers(IS_VOLATILE);
create index idx_QRTZ5_ft_trig_inst_name on QRTZ5_fired_triggers(INSTANCE_NAME);
create index idx_QRTZ5_ft_job_name on QRTZ5_fired_triggers(JOB_NAME);
create index idx_QRTZ5_ft_job_group on QRTZ5_fired_triggers(JOB_GROUP);
create index idx_QRTZ5_ft_job_stateful on QRTZ5_fired_triggers(IS_STATEFUL);
create index idx_QRTZ5_ft_job_req_recovery on QRTZ5_fired_triggers(REQUESTS_RECOVERY);
commit;
Still bumped into this problem with Pentaho 7.1.
After some digging it looks like the real error is logged in tomcat/logs/pentaho.log (truncated on every start) and not catalina.out.
org.apache.jackrabbit.core.config.ConfigurationException: Duplicate configuration element DataStore in Repository.
Solution is to make sure you only have 1 instance of DataStore class, 1 instance of PersistanceManger class etc in pentaho-solutions/system/jackrabbit/repository.xml.
Make sure to comment out all instances of following classes (which are there by default):
<DataStore class="org.apache.jackrabbit.core.data.FileDataStore"/>
<FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
<PersistenceManager class="org.apache.jackrabbit.core.persistence.pool.H2PersistenceManager">
When you edit repository destination from default one to a new one make sure a user that is will be used to connect to a database is able to perform DDL instruction like create table or view and so on.
When starting platform tries to create repository from scratch for the first time after a config changes. If it is not able to connect/create repository - it will just not start as you see on a screenshot. It just will not work without a repository.
All oracle connection string syntax is described here as for Oracle jdbc driver - will be used under the hood. And of course you have to have jdbc driver jar in class-path.

Error Code: 1064. You have an error in your SQL syntax; check the manual

--
-- Table structure for table artist
CREATE TABLE artist (
id int(11) NOT NULL AUTO_INCREMENT,
name varchar(255) NOT NULL,
PRIMARY KEY (id)
);
--
-- Dumping data for table artist
INSERT INTO artist VALUES (1,'Bing Crosby'),(2,'Bill Haley & His Comets'),(3,'Elvis Presley'),(4,'The Beatles'),(5,'Queen'),(6,'Culture Club'),(7,'ABBA'),(8,'The Jackson 5');
--
-- Table structure for table song
CREATE TABLE song (
id int(11) NOT NULL AUTO_INCREMENT,
title varchar(255) NOT NULL,
artist_id int(11) NOT NULL,
duration int(11) NOT NULL,
PRIMARY KEY (id)
);
--
-- Dumping data for table song
INSERT INTO song VALUES (1,'Fernando',7,257),(2,'Hound Dog',3,136),(3,'White Christmas',1,186),(4,'I Want to Hold Your Hand',4,148),(5,'Waterloo',7,169),(6,'Rock Around the Clock',2,134),(7,'Blue Suede Shoes',3,118),(8,'She Loves You',4,142),(9,'Bohemian Rhapsody',5,356),(10,'Are You Lonesome Tonight?',3,189),(11,'Hey Jude',4,431),(12,'Another One Bites the Dust',5,216);
I am getting following error:
Error Code: 1064. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'id int(11) NOT NULL AUTO_INCREMENT, `name

Resources