I am using eclipse and following http://www.eclipse.org/articles/article.php?file=Article-EclipseDbWebapps/index.html and it all works fine except when I try to run my own sql code.
Here it is:
CREATE TABLE honscores (
idhonscores INTEGER PRIMARY KEY GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1),
Name varchar(25) NOT NULL,
Characters VARCHAR(25) NOT NULL,
Kills integer(11) NOT NULL,
Deaths integer(11) NOT NULL,
Assists integer(11) NOT NULL,
XPM integer(11) NOT NULL,
CK integer(11) NOT NULL);
Any help will be appreciated.
Here is the error message :
Syntax error: Encountered "(" at line 5, column 20.
Elapsed Time: 0 hr, 0 min, 0 sec, 0 ms.
CREATE TABLE app.honscores ( //schema name is before the table name
idhonscores INTEGER PRIMARY KEY GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1),
Name varchar(25) NOT NULL,
Characters VARCHAR(25) NOT NULL,
Kills integer NOT NULL,
Deaths integer NOT NULL,
Assists integer NOT NULL,
XPM integer NOT NULL,
CK integer NOT NULL
);
Im pretty sure this is how I fixed it
Related
Is there a way to retrieve the list of distribution column(s) info from the Azure Synapse JDBC drivers? I can do most of it but stuck on the WITH DISTRIBUTION WITH clause(s) part at the bottom.
For example, I just need something basic to re-create a DDL like so:
IF EXISTS(SELECT 1 FROM sys.objects WHERE [type]='U' AND [name] = 'AZURE_TEST'
AND SCHEMA_NAME(schema_id) = 'dbo')
DROP TABLE [dbo].[AZURE_TEST]
GO
CREATE TABLE [dbo].[AZURE_TEST] (
BIGINT1 BIGINT NOT NULL,
BOOLEAN1 BIT NOT NULL,
BYTEINT1 TINYINT NOT NULL PRIMARY KEY NONCLUSTERED NOT ENFORCED,
CHAR1 CHAR(1) NULL,
CHAR2 CHAR(10) NULL,
CHARACTER_VARYING1 VARCHAR(10) NULL,
CHARACTER1 CHAR(1) NOT NULL,
CHARACTER2 CHAR(10) NULL,
DATE1 DATE NULL,
DOUBLE_PRECISION1 FLOAT(15) NULL,
INTEGER1 INTEGER NULL,
INTERVAL1 VARCHAR(50) NULL,
NATIONAL_CHARACTER_VARYING2 NVARCHAR(10) NULL,
NUMERIC1 NUMERIC(18, 0) NULL,
NUMERIC2 NUMERIC(10, 0) NOT NULL,
NUMERIC3 NUMERIC(10, 2) NULL,
REAL1 REAL NULL,
SMALLINT1 SMALLINT NULL,
TIME1 TIME NULL,
TIMESTAMP1 DATETIME2 NULL
)
WITH
(
DISTRIBUTION = HASH ( [BIGINT1] ),
CLUSTERED COLUMNSTORE INDEX
)
GO
You can retrieve the columns used for the DISTRIBUTION for a given table by running the next sql:
SELECT c.name FROM sys.columns AS c
INNER JOIN sys.tables AS t ON t.object_id = c.object_id
INNER JOIN sys.schemas AS s ON s.schema_id = t.schema_id
INNER JOIN sys.pdw_column_distribution_properties AS d ON t.object_id = d.object_id AND d.column_id = c.column_id
WHERE t.name = 'table_name' AND s.name = 'schema_name' AND d.distribution_ordinal <> 0;
I am trying to implement post request using spring data jpa. I am trying to add new room in room table with some values. Some of the column from room table are not null I set that with default. But when I am inserting I am getting error as violates not-null constraint.
RoomService class
// Add new Room Details
public String addNewRoom(#RequestBody RoomInformation roomInfo) {
Room roomRecord = new Room();
if(roomInfo.nCampusId != 0)
roomRecord.nCampusId = roomInfo.nCampusId;
if(roomInfo.nBuildId != 0)
roomRecord.nBuildId=roomInfo.nBuildId;
if(roomInfo.nCRTCodeId !=0)
roomRecord.nCRTCodeId=roomInfo.nCRTCodeId;
roomRecord.nInstId=roomInfo.nInstId;
roomRecord.sRoomNumber=roomInfo.sRoomNumber;
roomRecord.sRoomDesc=roomInfo.sRoomDesc;
roomRecord.nArea=roomInfo.nArea;
roomRecord.sFloor=roomInfo.sFloor;
roomRecord.bIsActive= true;
roomRepository.save(roomRecord);
return "New room added sucessfully";
}
Room Table
CREATE TABLE public.room
(
nroom_id numeric(18,0) NOT NULL DEFAULT nextval('room_seq'::regclass),
ncampus_id numeric(18,0),
nbuild_id numeric(18,0),
ninst_id numeric(18,0) NOT NULL DEFAULT 0,
sfloor character varying(10) COLLATE pg_catalog."default",
sroom_number character varying(10) COLLATE pg_catalog."default",
sroom_desc character varying(255) COLLATE pg_catalog."default",
scomments text COLLATE pg_catalog."default",
daccepted_date timestamp(3) without time zone,
ssurveyor character varying(255) COLLATE pg_catalog."default",
narea integer,
ncrt_code_id numeric(18,0),
ncmn_room_bln smallint,
nunvalidated_bln smallint,
sbfr_field character varying(50) COLLATE pg_catalog."default",
ntemp_room_id numeric(18,0),
bis_active boolean NOT NULL DEFAULT false,
bis_jointuse boolean NOT NULL DEFAULT false,
sstations_desc character varying(25) COLLATE pg_catalog."default",
ddeleted_on timestamp(3) without time zone,
ndeleted_by numeric(18,0),
bis_incluster boolean NOT NULL DEFAULT false,
bis_service_center_activity boolean NOT NULL DEFAULT false,
service_center_comments text COLLATE pg_catalog."default",
CONSTRAINT pk_roomdeails PRIMARY KEY (nroom_id),
)
Error at console
Null value in column "bis_jointuse" violates not-null constraint
Detail: Failing row contains (1203521, 270, 11135, 106, 0, 10, abc, null, null, null, 22, 2122, null, null, null, null, t, null, null, null, null, null, null, null).
You need to skip column or provide DEFAULT keyword instead of explicit NULL:
INSERT INTO tab(col1,...,bis_jointuse)
VALUES (22, ..., DEFAULT);
-- skipping column
INSERT INTO tab(col1,...)
VALUES (22,...);
Those values are not null in table that I set with default value. But default value is not taking when I am trying to insert.
As far I as know only Oracle supports such construct: DEFAULT Values On Explicit NULLs
In the previous section we saw default values are only used when a column is not referenced in an insert statement. If the column is referenced, even when supplying the value NULL, the default value is not used. Oracle 12c allows you to modify this behaviour using the ON NULL clause in the default definition.
CREATE TABLE t2 (
col1 NUMBER DEFAULT 1,
col2 NUMBER DEFAULT ON NULL 2,
description VARCHAR2(30)
);
Hai all I am currently doing a project for a hospital clinical lab. I have come across a problem while fetching data from database. The problem is as follows.
I have 2 category of tests namely Single test and Profile test. The master table of tests contain both the category of tests.
MASTER TABLE of TESTS(LAB_TEST_SERVICES)
CREATE TABLE LAB_TEST_SERVICES (inttestid bigint identity NOT NULL IDENTITY,
testid varchar(15) NOT NULL, testname varchar(255) NOT NULL, cptdesc varchar(300),
splinstr varchar(300), tstabbr varchar(25), reordertime numeric(15),
tstduration numeric(15), autocancel numeric(15), minbiltime numeric(15),
status int NOT NULL, maxbiltime numeric(15), PRIMARY KEY (inttestid));
The type and category of test is stored in following table
LAB_SERVICES_TYPE
CREATE TABLE LAB_SERVICES_TYPE (inttypeid bigint identity NOT NULL IDENTITY,
inttestid bigint NOT NULL, testtype varchar(25), visitype int NOT NULL,
appgendr char(2) NOT NULL, PRIMARY KEY (inttypeid));
If the test comes under single test category, I need to fill the details to the columns of following tables namely LAB_SPECIMEN_MAPPING,LAB_PARAMETER_MAPPING and LAB_TEST_LOCATION.
LAB_SPECIMEN_MAPPING
CREATE TABLE LAB_SPECIMEN_MAPPING (inttestspcid bigint identity NOT NULL IDENTITY,
inttestid bigint NOT NULL, intspcid bigint NOT NULL, intcontid bigint NOT NULL,
volcol numeric(15, 3) NOT NULL, volreq numeric(15, 3) NOT NULL,
status int NOT NULL, PRIMARY KEY (inttestspcid));
LAB_PARAMETER_MAPPING
CREATE TABLE LAB_PARAMETER_MAPPING (intparaid bigint identity NOT NULL IDENTITY,
inttestid bigint NOT NULL, paraname varchar(255) NOT NULL,
parseq numeric(15, 3) NOT NULL, resulttype varchar(30), shortname varchar(30),
mand int NOT NULL, derived int NOT NULL, status int NOT NULL,
PRIMARY KEY (intparaid));
LAB_TEST_LOCATION
CREATE TABLE LAB_TEST_LOCATION (intlocid bigint identity NOT NULL IDENTITY,
intlabid bigint NOT NULL, inttestid bigint NOT NULL, status int NOT NULL,
PRIMARY KEY (intlocid));
And if the test comes under Profile Test category then I need to fill the details to the columns of following table namely LAB_PROFILE_TEST_LIST. Here for each profile test I am mapping a single test to it.
LAB_PROFILE_TEST_LIST
CREATE TABLE LAB_PROFILE_TEST_LIST (intproftestid int identity NOT NULL IDENTITY,
intprotestid int NOT NULL, intsintestid int NOT NULL, PRIMARY KEY (intproftestid));
I had done the following code to find the name of test which is mapped ie for single test if it is mapped then the testid(inttestid from LAB_TEST_SERVICES) will be inserted in LAB_SPECIMEN_MAPPING,LAB_PARAMETER_MAPPING and LAB_TEST_LOCATION or if the test is profile test the testid(inttestid from LAB_TEST_SERVICES) will be inserted in LAB_PROFILE_TEST_LIST.
The tests which is mapped ( both single & profile test).(My contribution to my problem).
SELECT *
FROM LAB_TEST_SERVICES lts
WHERE EXISTS
(SELECT lsm.inttestid
FROM LAB_SPECIMEN_MAPPING lsm
WHERE lsm.status = 1
AND lts.inttestid = lsm.inttestid)
AND EXISTS
(SELECT ltl.inttestid
FROM LAB_TEST_LOCATION ltl
WHERE ltl.status = 1
AND lts.inttestid = ltl.inttestid)
AND EXISTS
(SELECT lptr.intprotestid
FROM LAB_PROFILE_TEST_LIST lptr WHERE lts.inttestid = lptr.intprotestid)
So when I tried to do this no tests appear because I know that there will be no tests having both the characteristics of Single and Profile tests. I had done so many things but cant find a solution. Kindly help me to find out the details tests which is mapped both single and profile.I am using Java, Hibernate and SQL SERVER. Thanks in advance
I'm trying to import a CSV table via Netbeans for my Java application.
However, when I try to import values from a CSV file, I get a file type error. It works if I make all the values VARCHARs, but this is inefficient, especially for the short strings of characters that I use.
Here's the CSV file:
GameID,GameName,Developer,Engine,PublishYear,Rating
1,Bioshock Infinite,Irrational Games,Unreal Engine 3,2013,10
2,Hitman: Absolution,IO Interactive,Glacier 2,2012,9
3,Killing Floor,Tripwire Interactive,Unreal Engine 2,2009,7
4,Half-Life 2,Valve,Source,2004,7
5,ESV Skyrim,Bethesda Softworks,Creation Engine,2011,8
6,Batman: Arkham City,Rocksteady Studios,Unreal Engine 3,2011,8
7,Portal 2,Valve,Source,2011,8
8,The Witcher 2,CD Projekt RED,REDengine,2011,9
9,Assassin's Creed 2,Ubisoft,Anvil,2010,8
10,Garry's Mod,Facepunch Studios,Source,2004,6
11,GRID 2,Codemasters,EGO 3.0,2013,7
12,Hotline Miami,Dennaton Games,Game Maker,2012,8
13,Just Cause 2,Avalanche Studios,Avalanche Engine 2.0,2010,7
14,Watch Dogs,Ubisoft,Disrupt,2014,8
15,Deus Ex,Ion Storm,Unreal Engine 1,2000,7
16,Trine 2,Frozenbyte,Proprietary,2011,6
And here's the table creation statement:
CREATE TABLE tblGames (
GameID INTEGER NOT NULL,
GameName VARCHAR(30) NOT NULL,
Developer VARCHAR(30) NOT NULL,
Engine VARCHAR(30) NOT NULL,
PublishYear VARCHAR(20) NOT NULL,
Rating SMALLINT NOT NULL,
PRIMARY KEY (GameID)
);
And here's the import statement:
CALL SYSCS_UTIL.SYSCS_IMPORT_TABLE (
null,
'TBLGAMES',
'D:\OneDrive\Documents\Topic 9\CSV\tblGames.csv',
',', null, null, 0
)
And this is a copy of the error I get:
Error code 30000, SQL state XIE0R: Import error on line 1 of file D:\OneDrive\Documents\Topic 9\CSV\tblGames.csv: Invalid character string format for type INTEGER.
Error code 99999, SQL state 22018: Invalid character string format for type INTEGER.
Now, as I see it, all the GameID values are integers and the ratings are all SMALLINT, so how could there be an error like this?
I have a good insert statement which has 9 parameters, but for some reason iBatis generates only 6 for a particular object. For all other it generates 9, as it should.
Could it be the fact that all params are NULL ?
?,?,?,?,?,null,?,null,null,null,null,null,?,?,?,null,null
OK:
Parameters: [[B#132b63e, [B#5ac911, [B#468066, xxxxxxxxxxxxxxxx, null, null, 0, 0, 0]
NOK:
Parameters: [null, null, null, null, null, null]
And the error is as you expected:
Missing IN or OUT parameters at index 7
INSERT 17 COLUMNS INTO SOME_TABLE VALUES (
#id#,
#someObj.id#,
#someOtherObj.id#,
#aProperty#,
#anotherProperty#,
null,
#yetAnotherProperty#,
null,
null,
null,
null,
null,
#prop1#,
#prop2#,
#prop3#,
null,
null)
someObj and someOtherObj are NULL. Also my app uses cglib for lazy loading, so some enhances might be present, don't know if it affects something.
You could do this:
INSERT 17 COLUMNS INTO SOME_TABLE VALUES (
#id#,
<isNotNull property="someObj">
#someObj.id#,
</isNotNull>
<isNull property="someObj">
NULL,
</isNull>
<isNotNull property="someOtherObj">
#someOtherObj.id#,
</isNotNull>
<isNull property="someObj">
NULL,
</isNull>
#aProperty#,
#anotherProperty#,
null,
#yetAnotherProperty#,
null,
null,
null,
null,
null,
#prop1#,
#prop2#,
#prop3#,
null,
null)