Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Why desired records are not getting added?

PtrikhaJul 10 2014 — edited Jul 17 2014

Hi,

I ran this script and wanted to add records of Argentina World Cup players to the table :

wc_team_details:

/** Package to work with UTL_FILE to write a report to a file.

First run Create entities.sql

Sample run on World Cup Football Teams Names and related data

*/

-- @CreateEntities.sql

CREATE TABLE wc_team_names(wc_team_id NUMBER CONSTRAINT pk_wc_team_name_id PRIMARY KEY ,

wc_team_name VARCHAR2(75) CONSTRAINT nn_wc_team_name NOT NULL,

wc_team_continent VARCHAR2(50) CONSTRAINT nn_wc_continent_name NOT NULL );

CREATE INDEX idx_wc_team_nme ON wc_team_names(wc_team_name);

CREATE TABLE wc_team_details(wc_team_det_id NUMBER CONSTRAINT pk_wc_team_det_id PRIMARY KEY,

wc_player_name VARCHAR2(100)CONSTRAINT nn_wc_plyr_name NOT NULL,

wc_team_id NUMBER CONSTRAINT fk_wc_team_id references wc_team_names(wc_team_id)

);

CREATE INDEX idx_wc_team_det_nmes ON wc_team_details(wc_player_name) REVERSE;

INSERT INTO wc_team_names(wc_team_id,wc_team_name,wc_team_continent) VALUES(1,'Argentina','South America');

INSERT INTO wc_team_names(wc_team_id,wc_team_name,wc_team_continent) VALUES(2,'Germany','Europe');

INSERT INTO wc_team_names(wc_team_id,wc_team_name,wc_team_continent) VALUES(3,'Brazil','South America');

INSERT INTO wc_team_names(wc_team_id,wc_team_name,wc_team_continent) VALUES(4,'Netherlands','Europe');

INSERT INTO wc_team_names(wc_team_id,wc_team_name,wc_team_continent) VALUES(5,'Mexico','North America');

INSERT INTO wc_team_names(wc_team_id,wc_team_name,wc_team_continent) VALUES(6,'Italy','Europe');

INSERT INTO wc_team_names(wc_team_id,wc_team_name,wc_team_continent) VALUES(7,'England','Europe');

INSERT INTO wc_team_names(wc_team_id,wc_team_name,wc_team_continent) VALUES(8,'South Korea','Asia');

INSERT INTO wc_team_names(wc_team_id,wc_team_name,wc_team_continent) VALUES(9,'Algeria','Africa');

INSERT INTO wc_team_names(wc_team_id,wc_team_name,wc_team_continent) VALUES(10,'Australia','Australasia');

INSERT INTO wc_team_names(wc_team_id,wc_team_name,wc_team_continent) VALUES(11,'Belgium','Europe');

INSERT INTO wc_team_names(wc_team_id,wc_team_name,wc_team_continent) VALUES(12,'Switzerland','Europe');

INSERT INTO wc_team_names(wc_team_id,wc_team_name,wc_team_continent) VALUES(13,'Portugal','Europe');

COMMIT;

INSERT INTO wc_team_names(wc_team_id,wc_team_name,wc_team_continent) VALUES(14,'Greece','Europe');

INSERT INTO wc_team_names(wc_team_id,wc_team_name,wc_team_continent) VALUES(15,'Iran','Asia');

INSERT INTO wc_team_names(wc_team_id,wc_team_name,wc_team_continent) VALUES(16,'Japan','Asia');

INSERT INTO wc_team_names(wc_team_id,wc_team_name,wc_team_continent) VALUES(17,'Ivory Coast','Africa');

INSERT INTO wc_team_names(wc_team_id,wc_team_name,wc_team_continent) VALUES(18,'Nigeria','Africa');

INSERT INTO wc_team_names(wc_team_id,wc_team_name,wc_team_continent) VALUES(19,'Ghana','Africa');

INSERT INTO wc_team_names(wc_team_id,wc_team_name,wc_team_continent) VALUES(20,'Costa Rica','North America');

INSERT INTO wc_team_names(wc_team_id,wc_team_name,wc_team_continent) VALUES(21,'USA','North America');

INSERT INTO wc_team_names(wc_team_id,wc_team_name,wc_team_continent) VALUES(22,'Uruguay','South America');

COMMIT;

INSERT INTO wc_team_names(wc_team_id,wc_team_name,wc_team_continent) VALUES(23,'Croatia','Europe');

INSERT INTO wc_team_names(wc_team_id,wc_team_name,wc_team_continent) VALUES(24,'Bosnia-Herzegovina','Europe');

INSERT INTO wc_team_names(wc_team_id,wc_team_name,wc_team_continent) VALUES(25,'Russia','Europe');

INSERT INTO wc_team_names(wc_team_id,wc_team_name,wc_team_continent) VALUES(26,'Colombia','South America');

INSERT INTO wc_team_names(wc_team_id,wc_team_name,wc_team_continent) VALUES(27,'France','Europe');

INSERT INTO wc_team_names(wc_team_id,wc_team_name,wc_team_continent) VALUES(28,'Cameroon','Africa');

INSERT INTO wc_team_names(wc_team_id,wc_team_name,wc_team_continent) VALUES(29,'Spain','Europe');

INSERT INTO wc_team_names(wc_team_id,wc_team_name,wc_team_continent) VALUES(30,'Chile','South America');

INSERT INTO wc_team_names(wc_team_id,wc_team_name,wc_team_continent) VALUES(31,'Ecuador','South America');

INSERT INTO wc_team_names(wc_team_id,wc_team_name,wc_team_continent) VALUES(32,'Honduras','North America');

COMMIT ;

/** Team Details Population  */

DECLARE

  TYPE playerNames IS TABLE OF VARCHAR2(75);

  v_counter number :=1;

  names playerNames := playerNames('Sergio Romero','Agustín Orión','Mariano Andújar','Ezequiel Garay','Hugo Campagnaro','Pablo Zabaleta','Martín Demichelis','Marcos Rojo','Federico Fernández','José María Basanta','Fernando Gago',

'Lucas Biglia','Ángel di María','Enzo Pérez','Maxi Rodríguez','Augusto Fernández','Javier Mascherano',

'Ricardo Álvarez','Gonzalo Higuaín','Lionel Messi','Rodrigo Palacio','Sergio Agüero','Ezequiel Lavezzi')

;

BEGIN

      FOR plnames IN names.FIRST .. names.LAST

LOOP

      INSERT INTO wc_team_details(wc_team_det_id ,

      wc_player_name ,

      wc_team_id )

      VALUES

   (v_counter,

   plnames,

   1);

   -- Increment the counter

   v_counter :=v_counter+1 ;

END LOOP;

      COMMIT ;

END;

/

However, I get this result:

anonymous block completed

WC_TEAM_DET_ID WC_PLAYER_NAME                                                                                       WC_TEAM_ID

-------------- ---------------------------------------------------------------------------------------------------- ----------

             1 1                                                                                                             1

             2 2                                                                                                             1

             3 3                                                                                                             1

             4 4                                                                                                             1

             5 5                                                                                                             1

             6 6                                                                                                             1

             7 7                                                                                                             1

             8 8                                                                                                             1

             9 9                                                                                                             1

            10 10                                                                                                            1

            11 11                                                                                                            1

            12 12                                                                                                            1

            13 13                                                                                                            1

            14 14                                                                                                            1

            15 15                                                                                                            1

            16 16                                                                                                            1

            17 17                                                                                                            1

            18 18                                                                                                            1

            19 19                                                                                                            1

            20 20                                                                                                            1

            21 21                                                                                                            1

            22 22                                                                                                            1

            23 23                                                                                                            1

23 rows selected

Why is this happening? Why has wc_player_name not having player names and is instead having player ids?

This post has been answered by David Berger on Jul 10 2014
Jump to Answer

Comments

John Thorton

4130935 wrote:

Hello

I just did an upgrade from 12.1 to 12.2 using dbua however I realized that compatible parameter is still set 12.1.0.2.0 although it was upgraded to 12.2

Why didnt dbua change this parameter ? Is it because the flashback was on ?

Oracle  did NOT change COMPATIBLE parameter because it assumed that since you explicitly set it (as opposed to taking Oracle default), that you wanted it set to 12.1.0.2 & left it for you to change it. Problem Exists Between Keyboard And Chair.

TK03

Hi John,

Does it mean that any upgrades with dbua, the compatible parameter will always be same ? DBUA will never change that parameter

John Thorton

4130935 wrote:

Hi John,

Does it mean that any upgrades with dbua, the compatible parameter will always be same ? DBUA will never change that parameter

IMO, you are asking the WRONG question.

What does DBUA do when COMPATIBLE is NOT set to any value & the upgrade is performed?

TK03

Compatible is set to 12.1.0.2

After the upgrade with dbua

It is still same.

I thought dbua will change it 12.2.0.1 once the upgrade is finished

John Thorton

4130935 wrote:

Compatible is set to 12.1.0.2

After the upgrade with dbua

It is still same.

I thought dbua will change it 12.2.0.1 once the upgrade is finished

Oracle & reality demonstrated that you thought wrongly.

yoonas

Hi,

You should have spent little more time reading upgrade guide, it has well depth of information.

When to Set the COMPATIBLE Initialization Parameter in Oracle Database

When to Set the COMPATIBLE Initialization Parameter in Oracle Database

Oracle recommends increasing the COMPATIBLE parameter only after you have completed testing the upgraded database.

After the upgrade is complete, you can increase the setting of the COMPATIBLE initialization parameter to the maximum level for Oracle Database 12c. However, after you increase the COMPATIBLE parameter, you cannot subsequently downgrade the database.

Regards,

Yoonas

TK03

1-) does it mean that once i increase the COMPATIBLE parameter, I can never downgrade the database ?

2-) Assume I enabled flashback database before the upgrade and after the upgrade I increased the COMPATIBLE parameter.  Can i still flashback database to before upgrade state ?

dvohra21

To downgrade, first decrease the COMPATIBLE parameter.

John Thorton

dvohra21 wrote:

To downgrade, first decrease the COMPATIBLE parameter.

What happens when a feature that exists in the higher version (& has been used)  does NOT exist in the lower version & attempt a downgrade?

TK03

Hi John,

so once i increase the COMPATIBLE parameter, there is no way to downgrade ?

yoonas

What Is Oracle Database Compatibility?

Downgrading Oracle Database to an Earlier Release

6 Downgrading Oracle Database to an Earlier Release

For supported releases of Oracle Database, you can downgrade a database to the release from which you last upgraded. For example, if you recently upgraded from release 11.2.0.4 to Oracle Database 12c, and you did not change the compatible initialization parameter to 12.1 or higher, then you can downgrade to release 11.2.0.4. If your Oracle Database 12c is release 12.1.0.2, and you did not change the compatible initialization parameter to 12.1.0.2, then you can downgrade to release 12.1.0.1 and so forth.

dvohra21

Seems like not.

"You cannot downgrade a database once you have set the compatible initialization parameter to 12.1.0.2."

1 - 12
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Aug 14 2014
Added on Jul 10 2014
6 comments
379 views