Oracle case INSERT statement [message #685546] |
Fri, 04 February 2022 13:00  |
 |
Unclefool
Messages: 65 Registered: August 2021
|
Member |
|
|
I have the following table declaration and I'm trying to use a case statement to INSERT some rows and I'm getting the following error
ORA-00976: Specified pseudocolumn or operator not allowed here.
Can someone please let me know how to rectify the INSERT code.
Thanks in advance to all who answer.
CREATE TABLE T21
(
seq_num NUMBER GENERATED BY DEFAULT AS IDENTITY (START WITH 1) NOT NULL,
num NUMBER(*,0) NOT NULL,
state VARCHAR2(20) NOT NULL
)
PARTITION BY LIST (state) AUTOMATIC
(PARTITION P_CALIFORNIA VALUES ('CALIFORNIA')
);
insert into T21 (num, state) VALUES (LEVEL,
CASE round(dbms_random.value(1,50))
WHEN 1 THEN 'Alabama'
WHEN 2 THEN 'Alaska'
WHEN 3 THEN 'Arizona'
WHEN 4 THEN 'Arkansas'
WHEN 5 THEN 'California'
WHEN 6 THEN 'Colorado'
WHEN 7 THEN 'Connecticut'
WHEN 8 THEN 'Delaware'
WHEN 9 THEN 'Florida'
WHEN 10 THEN 'Georgia'
WHEN 11 THEN 'Hawaii'
WHEN 12 THEN 'Idaho'
WHEN 13 THEN 'Illinois'
WHEN 14 THEN 'Indiana'
WHEN 15 THEN 'Iowa'
WHEN 16 THEN 'Kansas'
WHEN 17 THEN 'Kentucky'
WHEN 18 THEN 'Louisiana'
WHEN 19 THEN 'Maine'
WHEN 20 THEN 'Maryland'
WHEN 21 THEN 'Massachusetts'
WHEN 22 THEN 'Michigan'
WHEN 23 THEN 'Minnesota'
WHEN 24 THEN 'Mississippi'
WHEN 25 THEN 'Missouri'
WHEN 26 THEN 'Montana'
WHEN 27 THEN 'Nebraska'
WHEN 28 THEN 'Nevada'
WHEN 29 THEN 'New Hampshire'
WHEN 30 THEN 'New Jersey'
WHEN 31 THEN 'New Mexico'
WHEN 32 THEN 'New York'
WHEN 33 THEN 'North Carolina'
WHEN 34 THEN 'North Dakota'
WHEN 35 THEN 'Ohio'
WHEN 36 THEN 'Oklahoma'
WHEN 37 THEN 'Oregon'
WHEN 38 THEN 'Pennsylvania'
WHEN 39 THEN 'Rhode Island'
WHEN 40 THEN 'South Carolina'
WHEN 41 THEN 'South Dakota'
WHEN 42 THEN 'Tennessee'
WHEN 43 THEN 'Texas'
WHEN 44 THEN 'Utah'
WHEN 45 THEN 'Vermont'
WHEN 46 THEN 'Virginia'
WHEN 47 THEN 'Washington'
WHEN 48 THEN 'West Virginia'
WHEN 49 THEN 'Wisconsin'
WHEN 50 THEN 'Wyoming'
END AS state)
CONNECT BY LEVEL<=100;
|
|
|
|
|
|
|
|
Re: Oracle case INSERT statement [message #685554 is a reply to message #685550] |
Sat, 05 February 2022 09:14  |
 |
EdStevens
Messages: 1375 Registered: September 2013
|
Senior Member |
|
|
Unclefool wrote on Fri, 04 February 2022 20:03I was looking for a fast and easy way to generate data. In some of my environments we have aitgenerate list PARTITIONs enabled and users are complaining about the PARTITION names.
What do users care about partition names?
Quote:My goal was to generate date than write a procedure to rename the PARTITIONs ie P_IOWA, P_TEXAS... ALOR IF the high_value is a number P_10,P_11.. This is a setup for the real task
Then you should address the real requirement . . .
|
|
|