suman kumar
suman kumar

Reputation: 11

Below is my query in ORACLE which is getting ORA-00917: missing comma error

create table host_details
(
  host_name varchar(200),
  cluster_name varchar(200),
  env_id int,
  stats varchar(30),
  primary_owner int,
  secondary_owner int,
  last_upadted date,
  location varchar(30),
  ip_address float(20),
  instance_name varchar(50),
  app_name varchar(50),
  comments varchar(200)
);


INSERT INTO host_details
    (host_name, env_id, stats, primary_owner, secondary_owner, location,
     ip_address, instance_name, comments)
  VALUES
    ('DOVXLRMGNP01', 9, 'Active', 1, 2, 'denver', 192.10.6.52, 'LRM_PROD',
     'Nothing');

ERROR at line 1: ORA-00917: missing comma

Upvotes: 1

Views: 57

Answers (2)

Darwin von Corax
Darwin von Corax

Reputation: 5246

create table host_details
(
  ...
  ip_address float(20),
  ...
);

but you're trying to insert the value 192.10.6.52 into it. A floating-point value can have only one decimal point.

You need to store an IP address as a string-type, either CHAR(15) or VARCHAR(15). Beyond the problem of multiple periods, a float is meant to store an approximate value, while an IP address is an exact value.

Upvotes: 2

vmachan
vmachan

Reputation: 1682

I think your IP address field is a float and the value you are entering is incorrect.

Try the below, changed ip_address from float to varchar(20)

create table host_details (host_name varchar(200),cluster_name varchar(200),env_id int,stats varchar(30),primary_owner int,secondary_owner int,last_upadted date,location varchar(30),ip_address varchar(20),instance_name varchar(50),app_name varchar(50),comments varchar(200));

INSERT INTO host_details (host_name, env_id,stats, primary_owner, secondary_owner, location, ip_address, instance_name, comments) VALUES ('DOVXLRMGNP01',9,'Active',1,2,'denver','192.10.6.52','LRM_PROD','Nothing');

It worked on SQLFiddle - http://sqlfiddle.com/#!9/c6049/1/0

Upvotes: 2

Related Questions