The SQL Error: ORA-00904: : invalid identifier is probably being caused because your FOREIGN KEYs are referencing a column that does not exist - check that the column names are spelt correctly and that should solve it (and then your CREATE TABLE statement will work).
CREATE TABLE ArtistMember (
user_ID INT PRIMARY KEY
);
CREATE TABLE FollowerMember (
user_ID INT PRIMARY KEY
);
CREATE TABLE pledge (
pledge_ID INT CONSTRAINT XPKPledge PRIMARY KEY,
pledge_endDate DATE NULL,
pledge_startDate DATE NULL,
pledge_amount DECIMAL(9,2) NULL CONSTRAINT Currency_1322638346 CHECK (pledge_amount >= 0),
artist_userID INT NOT NULL CONSTRAINT gets REFERENCES ArtistMember (user_ID),
follower_userID INT NOT NULL CONSTRAINT makes REFERENCES FollowerMember (user_ID)
);
INSERT INTO ArtistMember VALUES ( 85275 );
INSERT INTO FollowerMember VALUES( 88128 );
INSERT INTO pledge VALUES(
559,
NULL, -- Use NULL and not 'NULL'
DATE '2016-02-01', -- Use a Date literal and not a string literal
3850,
85275,
88128
);
If you just use the string in '1-FEB-2016' then Oracle will implicitly try to convert the string literal using the TO_DATE() function with the NLS_DATE_FORMAT session parameter as the format mask. If they match then it will work but this is a client variable so can be changed and then the query will break without the code having changed (and be a pain to debug). The simple answer is to ensure that you compare date value by either using TO_DATE() and specifying the format mask (as per the query above) or to use an ANSI date literal DATE '2016-02-01' (which is independent of the NLS settings).
The SQL Error: ORA-00904: : invalid identifier is probably being caused because your FOREIGN KEYs are referencing a column that does not exist - check that the column names are spelt correctly and that should solve it (and then your CREATE TABLE statement will work).
CREATE TABLE ArtistMember (
user_ID INT PRIMARY KEY
);
CREATE TABLE FollowerMember (
user_ID INT PRIMARY KEY
);
CREATE TABLE pledge (
pledge_ID INT CONSTRAINT XPKPledge PRIMARY KEY,
pledge_endDate DATE NULL,
pledge_startDate DATE NULL,
pledge_amount DECIMAL(9,2) NULL CONSTRAINT Currency_1322638346 CHECK (pledge_amount >= 0),
artist_userID INT NOT NULL CONSTRAINT gets REFERENCES ArtistMember (user_ID),
follower_userID INT NOT NULL CONSTRAINT makes REFERENCES FollowerMember (user_ID)
);
INSERT INTO ArtistMember VALUES ( 85275 );
INSERT INTO FollowerMember VALUES( 88128 );
INSERT INTO pledge VALUES(
559,
NULL, -- Use NULL and not 'NULL'
DATE '2016-02-01', -- Use a Date literal and not a string literal
3850,
85275,
88128
);
If you just use the string in '1-FEB-2016' then Oracle will implicitly try to convert the string literal using the TO_DATE() function with the NLS_DATE_FORMAT session parameter as the format mask. If they match then it will work but this is a client variable so can be changed and then the query will break without the code having changed (and be a pain to debug). The simple answer is to ensure that you compare date value by either using TO_DATE() and specifying the format mask (as per the query above) or to use an ANSI date literal DATE '2016-02-01' (which is independent of the NLS settings).
Insert an empty string '' to a NUMBER column, Oracle will insert NULL.
For example, col_2 has data type is date field or number(12,0) (any datatype what not date field), SQL statement set NULL value for col_2 like this:
insert into foo (col_1, col_2) values ('abc', '');
or
insert into foo (col_1, col_2) values ('abc', NULL);
(it is NULL, not 'NULL' or "NULL")
Videos
Hello everyone, I just can't figure out the, as I guess, very easy solution to my problem. (the worst part is, I didn't find anything good / related via google for example).
I want to insert data into a table2, IF, ond only IF a specific Value from #table 1 is NOT NULL. If this Value is NULL, I don't want to insert anything at all.
Like:
CASE #table1.value is not null THEN
Insert into table2 (values) select * from table1
ELSE 'do nothing'
END
But it is not working. can anybody point my into the right direction please ? :)