Sql Query is running fine in one database but running from long in other

Hi All,
Please advice me on below:
One query is running fine on 11gr2 database with having 2GB SGA and cost of the running query is 15, but the same query is running from long time in other database having same 2GB SGA.
Below is teh Query:
SELECT CDU.USER_NAME, DECODE(:B2 , 'QUEUE','begin
dbms_aqadm.grant_queue_privilege(''ALL'','''||:B1
||''','''||CDU.USER_NAME||''',true); end;', 'grant '||DECODE(:B2 ,
'TABLE','SELECT,INSERT,UPDATE,DELETE'||DECODE(CDU.ADMIN,'Y',',REFERENCES
',''), 'VIEW',DECODE(:B3 ,NULL,'SELECT','SELECT,INSERT,UPDATE,DELETE'||D
ECODE(CDU.ADMIN,'Y',',REFERENCES','')), 'TYPE','EXECUTE',
'SEQUENCE','SELECT', 'EXECUTE')||' on
'||PACK_UTILS.GET_SCHEMA_OWNER||'.'||:B1 ||' to
"'||CDU.USER_NAME||'"'||DECODE(CDU.ADMIN,'Y',' WITH GRANT OPTION',''))
AS GRANT_SOURCE, 'create or replace synonym
"'||CDU.USER_NAME||'"."'||:B1 ||'" for
"'||PACK_UTILS.GET_SCHEMA_OWNER||'"."'||:B1 ||'"' AS SYNONYM_SOURCE,
NVL2( S.TABLE_NAME, 'Y', 'N' ) SYNONYM_EXISTS FROM CD_USERS CDU,
ALL_SYNONYMS S, ALL_USERS U WHERE :B2 IN
('TYPE','TABLE','VIEW','FUNCTION','PROCEDURE','PACKAGE','SEQUENCE','QUEU
E','SYNONYM') AND CDU.USER_TYPE = 'S' AND CDU.USER_NAME = U.USERNAME
AND CDU.USER_NAME = S.OWNER AND :B1 = S.TABLE_NAME
Please advise me as application team is chasing me like anything. what I can find out is that Cost is different in both databases.

Sorry forr Late reply friends..
below are the Explian plans for both databases:
                                                  BAD database
PLAN_TABLE_OUTPUT
SQL_ID  3bp3rynsds42r, child number 0
SELECT CDU.USER_NAME, DECODE(:B2 , 'QUEUE','begin
dbms_aqadm.grant_queue_privilege(''ALL'','''||:B1
||''','''||CDU.USER_NAME||''',true); end;', 'grant '||DECODE(:B2 ,
'TABLE','SELECT,INSERT,UPDATE,DELETE'||DECODE(CDU.ADMIN,'Y',',REFERENCES
',''), 'VIEW',DECODE(:B3 ,NULL,'SELECT','SELECT,INSERT,UPDATE,DELETE'||D
ECODE(CDU.ADMIN,'Y',',REFERENCES','')), 'TYPE','EXECUTE',
'SEQUENCE','SELECT', 'EXECUTE')||' on
'||PACK_UTILS.GET_SCHEMA_OWNER||'.'||:B1 ||' to
"'||CDU.USER_NAME||'"'||DECODE(CDU.ADMIN,'Y',' WITH GRANT OPTION',''))
PLAN_TABLE_OUTPUT
AS GRANT_SOURCE, 'create or replace synonym
"'||CDU.USER_NAME||'"."'||:B1 ||'" for
"'||PACK_UTILS.GET_SCHEMA_OWNER||'"."'||:B1 ||'"' AS SYNONYM_SOURCE,
NVL2( S.TABLE_NAME, 'Y', 'N' ) SYNONYM_EXISTS FROM CD_USERS CDU,
ALL_SYNONYMS S, ALL_USERS U WHERE :B2 IN
('TYPE','TABLE','VIEW','FUNCTION','PROCEDURE','PACKAGE','SEQUENCE','QUEU
E','SYNONYM') AND CDU.USER_TYPE = 'S' AND CDU.USER_NAME = U.USERNAME
AND CDU.USER_NAME = S.OWNER AND :B1 = S.TABLE_NAME
Plan hash value: 2404940060
PLAN_TABLE_OUTPUT
| Id  | Operation                                            | Name               | Rows  | Bytes |TempSpc| Cost (%CPU)| Time     |
|   0 | SELECT STATEMENT                                     |                    |       |       |       |    94 (100)|          |
|*  1 |  FILTER                                              |                    |       |       |       |            |          |
|*  2 |   HASH JOIN                                          |                    |    81 |  6723 |       |    94   (0)| 00:00:01 |
|   3 |    NESTED LOOPS OUTER                                |                    |    81 |  6480 |       |    91   (0)| 00:00:01 |
|*  4 |     HASH JOIN                                        |                    |    81 |  3726 |       |    10   (0)| 00:00:01 |
|*  5 |      HASH JOIN                                       |                    |   137 |  3699 |       |     7   (0)| 00:00:01 |
|   6 |       TABLE ACCESS FULL                              | TS$                |     7 |    21 |       |     3   (0)| 00:00:01 |
|*  7 |       TABLE ACCESS FULL                              | USER$              |   137 |  3288 |       |     4   (0)| 00:00:01 |
PLAN_TABLE_OUTPUT
|*  8 |      TABLE ACCESS FULL                               | CD_USERS           |    82 |  1558 |       |     3   (0)| 00:00:01 |
|   9 |     VIEW                                             | ALL_SYNONYMS       |     1 |    34 |       |     1   (0)| 00:00:01 |
|  10 |      SORT UNIQUE                                     |                    |       |       |       |            |          |
|  11 |       UNION-ALL PARTITION                            |                    |       |       |       |            |          |
|* 12 |        FILTER                                        |                    |       |       |       |            |          |
|  13 |         NESTED LOOPS                                 |                    |     1 |   116 |       |    60   (0)| 00:00:01 |
|  14 |          NESTED LOOPS                                |                    |     1 |    94 |       |    59   (0)| 00:00:01 |
|  15 |           NESTED LOOPS                               |                    |    12 |   684 |       |    23   (0)| 00:00:01 |
|  16 |            TABLE ACCESS BY INDEX ROWID               | USER$              |     1 |    19 |       |     1   (0)| 00:00:01 |
|* 17 |             INDEX UNIQUE SCAN                        | I_USER1            |     1 |       |       |     0   (0)|          |
|  18 |            TABLE ACCESS BY INDEX ROWID               | SYN$               |    12 |   456 |       |    22   (0)| 00:00:01 |
PLAN_TABLE_OUTPUT
|* 19 |             INDEX SKIP SCAN                          | I_SYN2             |    12 |       |       |    12   (0)| 00:00:01 |
|* 20 |           TABLE ACCESS BY INDEX ROWID                | OBJ$               |     1 |    37 |       |     3   (0)| 00:00:01 |
|* 21 |            INDEX RANGE SCAN                          | I_OBJ1             |     1 |       |       |     2   (0)| 00:00:01 |
|* 22 |          INDEX RANGE SCAN                            | I_USER2            |     1 |    22 |       |     1   (0)| 00:00:01 |
|* 23 |         FIXED TABLE FULL                             | X$KZSPR            |    17 |   119 |       |     0   (0)|          |
|* 24 |         FILTER                                       |                    |       |       |       |            |          |
|* 25 |          FILTER                                      |                    |       |       |       |            |          |
|  26 |           NESTED LOOPS                               |                    |    27 |  2430 |       |     6   (0)| 00:00:01 |
|  27 |            NESTED LOOPS                              |                    |     1 |    78 |       |     4   (0)| 00:00:01 |
|  28 |             NESTED LOOPS                             |                    |     1 |    56 |       |     3   (0)| 00:00:01 |
|  29 |              TABLE ACCESS BY INDEX ROWID             | USER$              |     1 |    19 |       |     1   (0)| 00:00:01 |
PLAN_TABLE_OUTPUT
|* 30 |               INDEX UNIQUE SCAN                      | I_USER1            |     1 |       |       |     0   (0)|          |
|* 31 |              INDEX RANGE SCAN                        | I_OBJ5             |     1 |    37 |       |     2   (0)| 00:00:01 |
|* 32 |             INDEX RANGE SCAN                         | I_USER2            |     1 |    22 |       |     1   (0)| 00:00:01 |
|* 33 |            INDEX RANGE SCAN                          | I_OBJAUTH1         |    28 |   336 |       |     2   (0)| 00:00:01 |
|* 34 |          FIXED TABLE FULL                            | X$KZSRO            |     1 |     3 |       |     0   (0)|          |
|  35 |          NESTED LOOPS                                |                    |     1 |    30 |       |     3   (0)| 00:00:01 |
|* 36 |           INDEX SKIP SCAN                            | I_USER2            |     1 |    20 |       |     1   (0)| 00:00:01 |
|* 37 |           INDEX RANGE SCAN                           | I_OBJ4             |     1 |    10 |       |     2   (0)| 00:00:01 |
|  38 |         NESTED LOOPS                                 |                    |     1 |    30 |       |     3   (0)| 00:00:01 |
|* 39 |          INDEX SKIP SCAN                             | I_USER2            |     1 |    20 |       |     1   (0)| 00:00:01 |
|* 40 |          INDEX RANGE SCAN                            | I_OBJ4             |     1 |    10 |       |     2   (0)| 00:00:01 |
PLAN_TABLE_OUTPUT
|* 41 |        FILTER                                        |                    |       |       |       |            |          |
|  42 |         NESTED LOOPS                                 |                    |     1 |   129 |       |  4301   (2)| 00:00:39 |
|  43 |          NESTED LOOPS                                |                    |     1 |   129 |       |  4301   (2)| 00:00:39 |
|  44 |           NESTED LOOPS                               |                    |     1 |    91 |       |  4299   (2)| 00:00:39 |
|  45 |            NESTED LOOPS                              |                    |     1 |    69 |       |  4298   (2)| 00:00:39 |
|  46 |             NESTED LOOPS                             |                    |     2 |    64 |       |  4292   (2)| 00:00:39 |
|  47 |              TABLE ACCESS BY INDEX ROWID             | USER$              |     1 |    19 |       |     1   (0)| 00:00:01 |
|* 48 |               INDEX UNIQUE SCAN                      | I_USER1            |     1 |       |       |     0   (0)|          |
|  49 |              VIEW                                    | _ALL_SYNONYMS_TREE |     2 |    26 |       |  4291   (2)| 00:00:39 |
|* 50 |               CONNECT BY NO FILTERING WITH START-WITH|                    |       |       |       |            |          |
|* 51 |                FILTER                                |                    |       |       |       |            |          |
PLAN_TABLE_OUTPUT
|* 52 |                 HASH JOIN                            |                    | 18370 |  2080K|       |  4291   (2)| 00:00:39 |
|  53 |                  INDEX FULL SCAN                     | I_USER2            |   207 |  4554 |       |     1   (0)| 00:00:01 |
|* 54 |                  HASH JOIN                           |                    | 18370 |  1686K|       |  4290   (2)| 00:00:39 |
|  55 |                   TABLE ACCESS FULL                  | USER$              |   207 |  3933 |       |     4   (0)| 00:00:01 |
|* 56 |                   HASH JOIN                          |                    |  2922K|   209M|    18M|  4269   (1)| 00:00:39 |
|* 57 |                    INDEX FAST FULL SCAN              | I_OBJ2             |   387K|    13M|       |  1323   (1)| 00:00:12 |
|  58 |                    TABLE ACCESS FULL                 | SYN$               |   400K|    14M|       |   566   (2)| 00:00:06 |
|  59 |                 NESTED LOOPS                         |                    |     1 |    30 |       |     3   (0)| 00:00:01 |
|* 60 |                  INDEX SKIP SCAN                     | I_USER2            |     1 |    20 |       |     1   (0)| 00:00:01 |
|* 61 |                  INDEX RANGE SCAN                    | I_OBJ4             |     1 |    10 |       |     2   (0)| 00:00:01 |
|* 62 |                FILTER                                |                    |       |       |       |            |          |
PLAN_TABLE_OUTPUT
|  63 |                 TABLE ACCESS BY INDEX ROWID          | SYN$               |     1 |    38 |       |     3   (0)| 00:00:01 |
|* 64 |                  INDEX UNIQUE SCAN                   | I_SYN1             |     1 |       |       |     2   (0)| 00:00:01 |
|* 65 |                 FILTER                               |                    |       |       |       |            |          |
|* 66 |                  FILTER                              |                    |       |       |       |            |          |
|  67 |                   NESTED LOOPS                       |                    |    27 |  2430 |       |     6   (0)| 00:00:01 |
|  68 |                    NESTED LOOPS                      |                    |     1 |    78 |       |     4   (0)| 00:00:01 |
|  69 |                     NESTED LOOPS                     |                    |     1 |    56 |       |     3   (0)| 00:00:01 |
|  70 |                      TABLE ACCESS BY INDEX ROWID     | USER$              |     1 |    19 |       |     1   (0)| 00:00:01 |
|* 71 |                       INDEX UNIQUE SCAN              | I_USER1            |     1 |       |       |     0   (0)|          |
|* 72 |                      INDEX RANGE SCAN                | I_OBJ5             |     1 |    37 |       |     2   (0)| 00:00:01 |
|* 73 |                     INDEX RANGE SCAN                 | I_USER2            |     1 |    22 |       |     1   (0)| 00:00:01 |
PLAN_TABLE_OUTPUT
|* 74 |                    INDEX RANGE SCAN                  | I_OBJAUTH1         |    28 |   336 |       |     2   (0)| 00:00:01 |
|* 75 |                  FIXED TABLE FULL                    | X$KZSRO            |     1 |     3 |       |     0   (0)|          |
|  76 |                  NESTED LOOPS                        |                    |     1 |    30 |       |     3   (0)| 00:00:01 |
|* 77 |                   INDEX SKIP SCAN                    | I_USER2            |     1 |    20 |       |     1   (0)| 00:00:01 |
|* 78 |                   INDEX RANGE SCAN                   | I_OBJ4             |     1 |    10 |       |     2   (0)| 00:00:01 |
|* 79 |                 FIXED TABLE FULL                     | X$KZSPR            |    17 |   119 |       |     0   (0)|          |
|* 80 |             TABLE ACCESS BY INDEX ROWID              | OBJ$               |     1 |    37 |       |     3   (0)| 00:00:01 |
|* 81 |              INDEX RANGE SCAN                        | I_OBJ1             |     1 |       |       |     2   (0)| 00:00:01 |
|* 82 |            INDEX RANGE SCAN                          | I_USER2            |     1 |    22 |       |     1   (0)| 00:00:01 |
|* 83 |           INDEX UNIQUE SCAN                          | I_SYN1             |     1 |       |       |     1   (0)| 00:00:01 |
|* 84 |          TABLE ACCESS BY INDEX ROWID                 | SYN$               |     1 |    38 |       |     2   (0)| 00:00:01 |
PLAN_TABLE_OUTPUT
|  85 |         NESTED LOOPS                                 |                    |     1 |    30 |       |     3   (0)| 00:00:01 |
|* 86 |          INDEX SKIP SCAN                             | I_USER2            |     1 |    20 |       |     1   (0)| 00:00:01 |
|* 87 |          INDEX RANGE SCAN                            | I_OBJ4             |     1 |    10 |       |     2   (0)| 00:00:01 |
|  88 |    TABLE ACCESS FULL                                 | TS$                |     7 |    21 |       |     3   (0)| 00:00:01 |
Predicate Information (identified by operation id):
   1 - filter((:B2='TYPE' OR :B2='TABLE' OR :B2='VIEW' OR :B2='FUNCTION' OR :B2='PROCEDURE' OR :B2='PACKAGE' OR
              :B2='SEQUENCE' OR :B2='QUEUE' OR :B2='SYNONYM'))
PLAN_TABLE_OUTPUT
   2 - access("U"."TEMPTS#"="TTS"."TS#")
   4 - access("CDU"."USER_NAME"="U"."NAME")
   5 - access("U"."DATATS#"="DTS"."TS#")
   7 - filter("U"."TYPE#"=1)
   8 - filter("CDU"."USER_TYPE"='S')
  12 - filter(((INTERNAL_FUNCTION("O"."SPARE3") OR ("S"."NODE" IS NULL AND  IS NOT NULL) OR  IS NOT NULL) AND
              (("O"."TYPE#"<>4 AND "O"."TYPE#"<>5 AND "O"."TYPE#"<>7 AND "O"."TYPE#"<>8 AND "O"."TYPE#"<>9 AND "O"."TYPE#"<>10 AND
              "O"."TYPE#"<>11 AND "O"."TYPE#"<>12 AND "O"."TYPE#"<>13 AND "O"."TYPE#"<>14 AND "O"."TYPE#"<>22 AND "O"."TYPE#"<>87 AND
              "O"."TYPE#"<>88) OR BITAND("U"."SPARE1",16)=0 OR (SYS_CONTEXT('userenv','current_edition_name')='ORA$BASE' AND
              "U"."TYPE#"<>2) OR ("U"."TYPE#"=2 AND "U"."SPARE2"=TO_NUMBER(SYS_CONTEXT('userenv','current_edition_id'))) OR  IS NOT
              NULL)))
PLAN_TABLE_OUTPUT
  17 - access("U"."NAME"="CDU"."USER_NAME")
  19 - access("S"."NAME"=:B1)
       filter("S"."NAME"=:B1)
  20 - filter("O"."SPARE3"="U"."USER#")
  21 - access("O"."OBJ#"="S"."OBJ#" AND "O"."TYPE#"=5)
       filter("O"."TYPE#"=5)
  22 - access("O"."OWNER#"="U"."USER#")
  23 - filter((((-"KZSPRPRV")=(-45) OR (-"KZSPRPRV")=(-47) OR (-"KZSPRPRV")=(-48) OR (-"KZSPRPRV")=(-49) OR
              (-"KZSPRPRV")=(-50)) AND "INST_ID"=USERENV('INSTANCE')))
  24 - filter((("BA"."GRANTOR#"=USERENV('SCHEMAID') OR  IS NOT NULL) AND (("O"."TYPE#"<>4 AND "O"."TYPE#"<>5 AND
              "O"."TYPE#"<>7 AND "O"."TYPE#"<>8 AND "O"."TYPE#"<>9 AND "O"."TYPE#"<>10 AND "O"."TYPE#"<>11 AND "O"."TYPE#"<>12 AND
PLAN_TABLE_OUTPUT
              "O"."TYPE#"<>13 AND "O"."TYPE#"<>14 AND "O"."TYPE#"<>22 AND "O"."TYPE#"<>87 AND "O"."TYPE#"<>88) OR
              BITAND("U"."SPARE1",16)=0 OR (INTERNAL_FUNCTION("O"."TYPE#") AND
              ((SYS_CONTEXT('userenv','current_edition_name')='ORA$BASE' AND "U"."TYPE#"<>2) OR ("U"."TYPE#"=2 AND
              "U"."SPARE2"=TO_NUMBER(SYS_CONTEXT('userenv','current_edition_id'))) OR  IS NOT NULL)))))
  25 - filter(:B1 IS NULL)
  30 - access("BU"."NAME"=:B1)
  31 - access("BU"."USER#"="O"."SPARE3" AND "O"."NAME"=:B1)
  32 - access("O"."OWNER#"="U"."USER#")
  33 - access("BA"."OBJ#"="O"."OBJ#")
  34 - filter("KZSROROL"=:B1)
  36 - access("U2"."TYPE#"=2 AND "U2"."SPARE2"=TO_NUMBER(SYS_CONTEXT('userenv','current_edition_id')))
PLAN_TABLE_OUTPUT
       filter(("U2"."TYPE#"=2 AND "U2"."SPARE2"=TO_NUMBER(SYS_CONTEXT('userenv','current_edition_id'))))
  37 - access("O2"."DATAOBJ#"=:B1 AND "O2"."TYPE#"=88 AND "O2"."OWNER#"="U2"."USER#")
  39 - access("U2"."TYPE#"=2 AND "U2"."SPARE2"=TO_NUMBER(SYS_CONTEXT('userenv','current_edition_id')))
       filter(("U2"."TYPE#"=2 AND "U2"."SPARE2"=TO_NUMBER(SYS_CONTEXT('userenv','current_edition_id'))))
  40 - access("O2"."DATAOBJ#"=:B1 AND "O2"."TYPE#"=88 AND "O2"."OWNER#"="U2"."USER#")
  41 - filter((("O"."TYPE#"<>4 AND "O"."TYPE#"<>5 AND "O"."TYPE#"<>7 AND "O"."TYPE#"<>8 AND "O"."TYPE#"<>9 AND
              "O"."TYPE#"<>10 AND "O"."TYPE#"<>11 AND "O"."TYPE#"<>12 AND "O"."TYPE#"<>13 AND "O"."TYPE#"<>14 AND "O"."TYPE#"<>22 AND
              "O"."TYPE#"<>87 AND "O"."TYPE#"<>88) OR BITAND("U"."SPARE1",16)=0 OR
              (SYS_CONTEXT('userenv','current_edition_name')='ORA$BASE' AND "U"."TYPE#"<>2) OR ("U"."TYPE#"=2 AND
              "U"."SPARE2"=TO_NUMBER(SYS_CONTEXT('userenv','current_edition_id'))) OR  IS NOT NULL))
  48 - access("U"."NAME"="CDU"."USER_NAME")
PLAN_TABLE_OUTPUT
  50 - access("S"."BASE_SYN_ID"=PRIOR NULL)
       filter( IS NOT NULL)
  51 - filter((("O"."TYPE#"<>4 AND "O"."TYPE#"<>5 AND "O"."TYPE#"<>7 AND "O"."TYPE#"<>8 AND "O"."TYPE#"<>9 AND
              "O"."TYPE#"<>10 AND "O"."TYPE#"<>11 AND "O"."TYPE#"<>12 AND "O"."TYPE#"<>13 AND "O"."TYPE#"<>14 AND "O"."TYPE#"<>22 AND
              "O"."TYPE#"<>87 AND "O"."TYPE#"<>88) OR BITAND("U"."SPARE1",16)=0 OR
              (SYS_CONTEXT('userenv','current_edition_name')='ORA$BASE' AND "U"."TYPE#"<>2) OR ("U"."TYPE#"=2 AND
              "U"."SPARE2"=TO_NUMBER(SYS_CONTEXT('userenv','current_edition_id'))) OR  IS NOT NULL))
  52 - access("O"."OWNER#"="U"."USER#")
  54 - access("S"."OWNER"="BU"."NAME" AND "BU"."USER#"="O"."SPARE3")
  56 - access("S"."NAME"="O"."NAME")
  57 - filter("O"."TYPE#"=5)
PLAN_TABLE_OUTPUT
  60 - access("U2"."TYPE#"=2 AND "U2"."SPARE2"=TO_NUMBER(SYS_CONTEXT('userenv','current_edition_id')))
       filter(("U2"."TYPE#"=2 AND "U2"."SPARE2"=TO_NUMBER(SYS_CONTEXT('userenv','current_edition_id'))))
  61 - access("O2"."DATAOBJ#"=:B1 AND "O2"."TYPE#"=88 AND "O2"."OWNER#"="U2"."USER#")
  62 - filter(( IS NOT NULL OR ("S"."NODE" IS NULL AND  IS NOT NULL)))
  64 - access("S"."OBJ#"=:B1)
  65 - filter((("BA"."GRANTOR#"=USERENV('SCHEMAID') OR  IS NOT NULL) AND (("O"."TYPE#"<>4 AND "O"."TYPE#"<>5 AND
              "O"."TYPE#"<>7 AND "O"."TYPE#"<>8 AND "O"."TYPE#"<>9 AND "O"."TYPE#"<>10 AND "O"."TYPE#"<>11 AND "O"."TYPE#"<>12 AND
              "O"."TYPE#"<>13 AND "O"."TYPE#"<>14 AND "O"."TYPE#"<>22 AND "O"."TYPE#"<>87 AND "O"."TYPE#"<>88) OR
              BITAND("U"."SPARE1",16)=0 OR (INTERNAL_FUNCTION("O"."TYPE#") AND
              ((SYS_CONTEXT('userenv','current_edition_name')='ORA$BASE' AND "U"."TYPE#"<>2) OR ("U"."TYPE#"=2 AND
              "U"."SPARE2"=TO_NUMBER(SYS_CONTEXT('userenv','current_edition_id'))) OR  IS NOT NULL)))))
PLAN_TABLE_OUTPUT
  66 - filter(:B1 IS NULL)
  71 - access("BU"."NAME"=:B1)
  72 - access("BU"."USER#"="O"."SPARE3" AND "O"."NAME"=:B1)
  73 - access("O"."OWNER#"="U"."USER#")
  74 - access("BA"."OBJ#"="O"."OBJ#")
  75 - filter("KZSROROL"=:B1)
  77 - access("U2"."TYPE#"=2 AND "U2"."SPARE2"=TO_NUMBER(SYS_CONTEXT('userenv','current_edition_id')))
       filter(("U2"."TYPE#"=2 AND "U2"."SPARE2"=TO_NUMBER(SYS_CONTEXT('userenv','current_edition_id'))))
  78 - access("O2"."DATAOBJ#"=:B1 AND "O2"."TYPE#"=88 AND "O2"."OWNER#"="U2"."USER#")
  79 - filter((((-"KZSPRPRV")=(-45) OR (-"KZSPRPRV")=(-47) OR (-"KZSPRPRV")=(-48) OR (-"KZSPRPRV")=(-49) OR
              (-"KZSPRPRV")=(-50)) AND "INST_ID"=USERENV('INSTANCE')))
PLAN_TABLE_OUTPUT
  80 - filter("O"."SPARE3"="U"."USER#")
  81 - access("O"."OBJ#"="ST"."SYN_ID" AND "O"."TYPE#"=5)
       filter("O"."TYPE#"=5)
  82 - access("O"."OWNER#"="U"."USER#")
  83 - access("S"."OBJ#"="ST"."SYN_ID")
       filter("O"."OBJ#"="S"."OBJ#")
  84 - filter("S"."NAME"=:B1)
  86 - access("U2"."TYPE#"=2 AND "U2"."SPARE2"=TO_NUMBER(SYS_CONTEXT('userenv','current_edition_id')))
       filter(("U2"."TYPE#"=2 AND "U2"."SPARE2"=TO_NUMBER(SYS_CONTEXT('userenv','current_edition_id'))))
  87 - access("O2"."DATAOBJ#"=:B1 AND "O2"."TYPE#"=88 AND "O2"."OWNER#"="U2"."USER#")
209 rows selected
==============================================================================================
                                                                 Good one
PLAN_TABLE_OUTPUT
SQL_ID  3bp3rynsds42r, child number 0
SELECT CDU.USER_NAME, DECODE(:B2 , 'QUEUE','begin
dbms_aqadm.grant_queue_privilege(''ALL'','''||:B1
||''','''||CDU.USER_NAME||''',true); end;', 'grant '||DECODE(:B2 ,
'TABLE','SELECT,INSERT,UPDATE,DELETE'||DECODE(CDU.ADMIN,'Y',',REFERENCES
',''), 'VIEW',DECODE(:B3 ,NULL,'SELECT','SELECT,INSERT,UPDATE,DELETE'||D
ECODE(CDU.ADMIN,'Y',',REFERENCES','')), 'TYPE','EXECUTE',
'SEQUENCE','SELECT', 'EXECUTE')||' on
'||PACK_UTILS.GET_SCHEMA_OWNER||'.'||:B1 ||' to
"'||CDU.USER_NAME||'"'||DECODE(CDU.ADMIN,'Y',' WITH GRANT OPTION',''))
PLAN_TABLE_OUTPUT
AS GRANT_SOURCE, 'create or replace synonym
"'||CDU.USER_NAME||'"."'||:B1 ||'" for
"'||PACK_UTILS.GET_SCHEMA_OWNER||'"."'||:B1 ||'"' AS SYNONYM_SOURCE,
NVL2( S.TABLE_NAME, 'Y', 'N' ) SYNONYM_EXISTS FROM CD_USERS CDU,
ALL_SYNONYMS S, ALL_USERS U WHERE :B2 IN
('TYPE','TABLE','VIEW','FUNCTION','PROCEDURE','PACKAGE','SEQUENCE','QUEU
E','SYNONYM') AND CDU.USER_TYPE = 'S' AND CDU.USER_NAME = U.USERNAME
AND CDU.USER_NAME = S.OWNER AND :B1 = S.TABLE_NAME
Plan hash value: 2146531909
PLAN_TABLE_OUTPUT
| Id  | Operation                                          | Name               | Rows  | Bytes |TempSpc| Cost (%CPU)| Time     |
|   0 | SELECT STATEMENT                                   |                    |       |       |       |    15 (100)|          |
|*  1 |  FILTER                                            |                    |       |       |       |            |          |
|   2 |   NESTED LOOPS OUTER                               |                    |     3 |   273 |       |    15   (0)| 00:00:01 |
|   3 |    NESTED LOOPS                                    |                    |     3 |   153 |       |    12   (0)| 00:00:01 |
|   4 |     NESTED LOOPS                                   |                    |     3 |   144 |       |     9   (0)| 00:00:01 |
|   5 |      NESTED LOOPS                                  |                    |     3 |   135 |       |     6   (0)| 00:00:01 |
|*  6 |       TABLE ACCESS FULL                            | USER$              |    55 |  1375 |       |     4   (0)| 00:00:01 |
|*  7 |       TABLE ACCESS BY INDEX ROWID                  | CD_USERS           |     1 |    20 |       |     1   (0)| 00:00:01 |
PLAN_TABLE_OUTPUT
|*  8 |        INDEX UNIQUE SCAN                           | I1_CD_USERS        |     1 |       |       |     0   (0)|          |
|   9 |      TABLE ACCESS CLUSTER                          | TS$                |     1 |     3 |       |     1   (0)| 00:00:01 |
|* 10 |       INDEX UNIQUE SCAN                            | I_TS#              |     1 |       |       |     0   (0)|          |
|  11 |     TABLE ACCESS CLUSTER                           | TS$                |     1 |     3 |       |     1   (0)| 00:00:01 |
|* 12 |      INDEX UNIQUE SCAN                             | I_TS#              |     1 |       |       |     0   (0)|          |
|  13 |    VIEW                                            | ALL_SYNONYMS       |     1 |    40 |       |     1   (0)| 00:00:01 |
|  14 |     SORT UNIQUE                                    |                    |       |       |       |            |          |
|  15 |      UNION-ALL PARTITION                           |                    |       |       |       |            |          |
|* 16 |       FILTER                                       |                    |       |       |       |            |          |
|  17 |        NESTED LOOPS                                |                    |     1 |   116 |       |    19   (0)| 00:00:01 |
|  18 |         NESTED LOOPS                               |                    |     1 |    94 |       |    18   (0)| 00:00:01 |
PLAN_TABLE_OUTPUT
|  19 |          NESTED LOOPS                              |                    |     1 |    56 |       |    15   (0)| 00:00:01 |
|  20 |           TABLE ACCESS BY INDEX ROWID              | USER$              |     1 |    20 |       |     1   (0)| 00:00:01 |
|* 21 |            INDEX UNIQUE SCAN                       | I_USER1            |     1 |       |       |     0   (0)|          |
|  22 |           TABLE ACCESS BY INDEX ROWID              | SYN$               |     1 |    36 |       |    14   (0)| 00:00:01 |
|* 23 |            INDEX SKIP SCAN                         | I_SYN2             |     1 |       |       |    12   (0)| 00:00:01 |
|* 24 |          TABLE ACCESS BY INDEX ROWID               | OBJ$               |     1 |    38 |       |     3   (0)| 00:00:01 |
|* 25 |           INDEX RANGE SCAN                         | I_OBJ1             |     1 |       |       |     2   (0)| 00:00:01 |
|* 26 |         INDEX RANGE SCAN                           | I_USER2            |     1 |    22 |       |     1   (0)| 00:00:01 |
|* 27 |        FIXED TABLE FULL                            | X$KZSPR            |    17 |   119 |       |     0   (0)|          |
|* 28 |        FILTER                                      |                    |       |       |       |            |          |
|* 29 |         FILTER                                     |                    |       |       |       |            |          |
PLAN_TABLE_OUTPUT
|  30 |          NESTED LOOPS                              |                    |     3 |   279 |       |     5   (0)| 00:00:01 |
|  31 |           NESTED LOOPS                             |                    |     1 |    80 |       |     4   (0)| 00:00:01 |
|  32 |            NESTED LOOPS                            |                    |     1 |    58 |       |     3   (0)| 00:00:01 |
|  33 |             TABLE ACCESS BY INDEX ROWID            | USER$              |     1 |    20 |       |     1   (0)| 00:00:01 |
|* 34 |              INDEX UNIQUE SCAN                     | I_USER1            |     1 |       |       |     0   (0)|          |
|* 35 |             INDEX RANGE SCAN                       | I_OBJ5             |     1 |    38 |       |     2   (0)| 00:00:01 |
|* 36 |            INDEX RANGE SCAN                        | I_USER2            |     1 |    22 |       |     1   (0)| 00:00:01 |
|* 37 |           INDEX RANGE SCAN                         | I_OBJAUTH1         |     3 |    39 |       |     1   (0)| 00:00:01 |
|* 38 |         FIXED TABLE FULL                           | X$KZSRO            |     1 |     3 |       |     0   (0)|          |
|  39 |         NESTED LOOPS                               |                    |     1 |    32 |       |     3   (0)| 00:00:01 |
|* 40 |          INDEX SKIP SCAN                           | I_USER2            |     1 |    20 |       |     1   (0)| 00:00:01 |
PLAN_TABLE_OUTPUT
|* 41 |          INDEX RANGE SCAN                          | I_OBJ4             |     1 |    12 |       |     2   (0)| 00:00:01 |
|  42 |        NESTED LOOPS                                |                    |     1 |    32 |       |     3   (0)| 00:00:01 |
|* 43 |         INDEX SKIP SCAN                            | I_USER2            |     1 |    20 |       |     1   (0)| 00:00:01 |
|* 44 |         INDEX RANGE SCAN                           | I_OBJ4             |     1 |    12 |       |     2   (0)| 00:00:01 |
|* 45 |       FILTER                                       |                    |       |       |       |            |          |
|  46 |        NESTED LOOPS                                |                    |     1 |   129 |       |  1065   (1)| 00:00:13 |
|  47 |         NESTED LOOPS                               |                    |     1 |   107 |       |  1064   (1)| 00:00:13 |
|  48 |          NESTED LOOPS                              |                    |     1 |    69 |       |  1061   (1)| 00:00:13 |
|  49 |           NESTED LOOPS                             |                    |     2 |    66 |       |  1059   (1)| 00:00:13 |
|  50 |            TABLE ACCESS BY INDEX ROWID             | USER$              |     1 |    20 |       |     1   (0)| 00:00:01 |
|* 51 |             INDEX UNIQUE SCAN                      | I_USER1            |     1 |       |       |     0   (0)|          |
PLAN_TABLE_OUTPUT
|  52 |            VIEW                                    | _ALL_SYNONYMS_TREE |     2 |    26 |       |  1058   (1)| 00:00:13 |
|* 53 |             CONNECT BY NO FILTERING WITH START-WITH|                    |       |       |       |            |          |
|* 54 |              FILTER                                |                    |       |       |       |            |          |
|* 55 |               HASH JOIN                            |                    |   705 | 81780 |       |  1058   (1)| 00:00:13 |
|  56 |                INDEX FULL SCAN                     | I_USER2            |   124 |  2728 |       |     1   (0)| 00:00:01 |
|* 57 |                HASH JOIN                           |                    |   705 | 66270 |       |  1057   (1)| 00:00:13 |
|  58 |                 TABLE ACCESS FULL                  | USER$              |   124 |  2480 |       |     4   (0)| 00:00:01 |
|* 59 |                 HASH JOIN                          |                    | 66964 |  4839K|  2232K|  1052   (1)| 00:00:13 |
|  60 |                  TABLE ACCESS FULL                 | SYN$               | 47615 |  1673K|       |    78   (2)| 00:00:01 |
|* 61 |                  INDEX FAST FULL SCAN              | I_OBJ5             | 47862 |  1776K|       |   752   (1)| 00:00:10 |
|  62 |               NESTED LOOPS                         |                    |     1 |    32 |       |     3   (0)| 00:00:01 |
PLAN_TABLE_OUTPUT
|* 63 |                INDEX SKIP SCAN                     | I_USER2            |     1 |    20 |       |     1   (0)| 00:00:01 |
|* 64 |                INDEX RANGE SCAN                    | I_OBJ4             |     1 |    12 |       |     2   (0)| 00:00:01 |
|* 65 |              FILTER                                |                    |       |       |       |            |          |
|  66 |               TABLE ACCESS BY INDEX ROWID          | SYN$               |     1 |    36 |       |     2   (0)| 00:00:01 |
|* 67 |                INDEX UNIQUE SCAN                   | I_SYN1             |     1 |       |       |     1   (0)| 00:00:01 |
|* 68 |               FILTER                               |                    |       |       |       |            |          |
|* 69 |                FILTER                              |                    |       |       |       |            |          |
|  70 |                 NESTED LOOPS                       |                    |     3 |   279 |       |     5   (0)| 00:00:01 |
|  71 |                  NESTED LOOPS                      |                    |     1 |    80 |       |     4   (0)| 00:00:01 |
|  72 |                   NESTED LOOPS                     |                    |     1 |    58 |       |     3   (0)| 00:00:01 |
|  73 |                    TABLE ACCESS BY INDEX ROWID     | USER$              |     1 |    20 |       |     1   (0)| 00:00:01 |
PLAN_TABLE_OUTPUT
|* 74 |                     INDEX UNIQUE SCAN              | I_USER1            |     1 |       |       |     0   (0)|          |
|* 75 |                    INDEX RANGE SCAN                | I_OBJ5             |     1 |    38 |       |     2   (0)| 00:00:01 |
|* 76 |                   INDEX RANGE SCAN                 | I_USER2            |     1 |    22 |       |     1   (0)| 00:00:01 |
|* 77 |                  INDEX RANGE SCAN                  | I_OBJAUTH1         |     3 |    39 |       |     1   (0)| 00:00:01 |
|* 78 |                FIXED TABLE FULL                    | X$KZSRO            |     1 |     3 |       |     0   (0)|          |
|  79 |                NESTED LOOPS                        |                    |     1 |    32 |       |     3   (0)| 00:00:01 |
|* 80 |                 INDEX SKIP SCAN                    | I_USER2            |     1 |    20 |       |     1   (0)| 00:00:01 |
|* 81 |                 INDEX RANGE SCAN                   | I_OBJ4             |     1 |    12 |       |     2   (0)| 00:00:01 |
|* 82 |               FIXED TABLE FULL                     | X$KZSPR            |    17 |   119 |       |     0   (0)|          |
|* 83 |           TABLE ACCESS BY INDEX ROWID              | SYN$               |     1 |    36 |       |     1   (0)| 00:00:01 |
|* 84 |            INDEX UNIQUE SCAN                       | I_SYN1             |     1 |       |       |     0   (0)|          |
PLAN_TABLE_OUTPUT
|* 85 |          TABLE ACCESS BY INDEX ROWID               | OBJ$               |     1 |    38 |       |     3   (0)| 00:00:01 |
|* 86 |           INDEX RANGE SCAN                         | I_OBJ1             |     1 |       |       |     2   (0)| 00:00:01 |
|* 87 |         INDEX RANGE SCAN                           | I_USER2            |     1 |    22 |       |     1   (0)| 00:00:01 |
|  88 |        NESTED LOOPS                                |                    |     1 |    32 |       |     3   (0)| 00:00:01 |
|* 89 |         INDEX SKIP SCAN                            | I_USER2            |     1 |    20 |       |     1   (0)| 00:00:01 |
|* 90 |         INDEX RANGE SCAN                           | I_OBJ4             |     1 |    12 |       |     2   (0)| 00:00:01 |
Predicate Information (identified by operation id):
PLAN_TABLE_OUTPUT
   1 - filter((:B2='TYPE' OR :B2='TABLE' OR :B2='VIEW' OR :B2='FUNCTION' OR :B2='PROCEDURE' OR :B2='PACKAGE' OR
              :B2='SEQUENCE' OR :B2='QUEUE' OR :B2='SYNONYM'))
   6 - filter("U"."TYPE#"=1)
   7 - filter("CDU"."USER_TYPE"='S')
   8 - access("CDU"."USER_NAME"="U"."NAME")
  10 - access("U"."DATATS#"="DTS"."TS#")
  12 - access("U"."TEMPTS#"="TTS"."TS#")
  16 - filter(((INTERNAL_FUNCTION("O"."SPARE3") OR ("S"."NODE" IS NULL AND  IS NOT NULL) OR  IS NOT NULL) AND
              (("O"."TYPE#"<>4 AND "O"."TYPE#"<>5 AND "O"."TYPE#"<>7 AND "O"."TYPE#"<>8 AND "O"."TYPE#"<>9 AND "O"."TYPE#"<>10 AND
              "O"."TYPE#"<>11 AND "O"."TYPE#"<>12 AND "O"."TYPE#"<>13 AND "O"."TYPE#"<>14 AND "O"."TYPE#"<>22 AND "O"."TYPE#"<>87 AND
              "O"."TYPE#"<>88) OR BITAND("U"."SPARE1",16)=0 OR (SYS_CONTEXT('userenv','current_edition_name')='ORA$BASE' AND
PLAN_TABLE_OUTPUT
              "U"."TYPE#"<>2) OR ("U"."TYPE#"=2 AND "U"."SPARE2"=TO_NUMBER(SYS_CONTEXT('userenv','current_edition_id'))) OR  IS NOT
              NULL)))
  21 - access("U"."NAME"="CDU"."USER_NAME")
  23 - access("S"."NAME"=:B1)
       filter("S"."NAME"=:B1)
  24 - filter("O"."SPARE3"="U"."USER#")
  25 - access("O"."OBJ#"="S"."OBJ#" AND "O"."TYPE#"=5)
       filter("O"."TYPE#"=5)
  26 - access("O"."OWNER#"="U"."USER#")
  27 - filter((((-"KZSPRPRV")=(-45) OR (-"KZSPRPRV")=(-47) OR (-"KZSPRPRV")=(-48) OR (-"KZSPRPRV")=(-49) OR
              (-"KZSPRPRV")=(-50)) AND "INST_ID"=USERENV('INSTANCE')))
PLAN_TABLE_OUTPUT
  28 - filter((("BA"."GRANTOR#"=USERENV('SCHEMAID') OR  IS NOT NULL) AND (("O"."TYPE#"<>4 AND "O"."TYPE#"<>5 AND
              "O"."TYPE#"<>7 AND "O"."TYPE#"<>8 AND "O"."TYPE#"<>9 AND "O"."TYPE#"<>10 AND "O"."TYPE#"<>11 AND "O"."TYPE#"<>12 AND
              "O"."TYPE#"<>13 AND "O"."TYPE#"<>14 AND "O"."TYPE#"<>22 AND "O"."TYPE#"<>87 AND "O"."TYPE#"<>88) OR
              BITAND("U"."SPARE1",16)=0 OR (INTERNAL_FUNCTION("O"."TYPE#") AND
              ((SYS_CONTEXT('userenv','current_edition_name')='ORA$BASE' AND "U"."TYPE#"<>2) OR ("U"."TYPE#"=2 AND
              "U"."SPARE2"=TO_NUMBER(SYS_CONTEXT('userenv','current_edition_id'))) OR  IS NOT NULL)))))
  29 - filter(:B1 IS NULL)
  34 - access("BU"."NAME"=:B1)
  35 - access("BU"."USER#"="O"."SPARE3" AND "O"."NAME"=:B1)
  36 - access("O"."OWNER#"="U"."USER#")
  37 - access("BA"."OBJ#"="O"."OBJ#")
PLAN_TABLE_OUTPUT
  38 - filter("KZSROROL"=:B1)
  40 - access("U2"."TYPE#"=2 AND "U2"."SPARE2"=TO_NUMBER(SYS_CONTEXT('userenv','current_edition_id')))
       filter(("U2"."TYPE#"=2 AND "U2"."SPARE2"=TO_NUMBER(SYS_CONTEXT('userenv','current_edition_id'))))
  41 - access("O2"."DATAOBJ#"=:B1 AND "O2"."TYPE#"=88 AND "O2"."OWNER#"="U2"."USER#")
  43 - access("U2"."TYPE#"=2 AND "U2"."SPARE2"=TO_NUMBER(SYS_CONTEXT('userenv','current_edition_id')))
       filter(("U2"."TYPE#"=2 AND "U2"."SPARE2"=TO_NUMBER(SYS_CONTEXT('userenv','current_edition_id'))))
  44 - access("O2"."DATAOBJ#"=:B1 AND "O2"."TYPE#"=88 AND "O2"."OWNER#"="U2"."USER#")
  45 - filter((("O"."TYPE#"<>4 AND "O"."TYPE#"<>5 AND "O"."TYPE#"<>7 AND "O"."TYPE#"<>8 AND "O"."TYPE#"<>9 AND
              "O"."TYPE#"<>10 AND "O"."TYPE#"<>11 AND "O"."TYPE#"<>12 AND "O"."TYPE#"<>13 AND "O"."TYPE#"<>14 AND "O"."TYPE#"<>22 AND
              "O"."TYPE#"<>87 AND "O"."TYPE#"<>88) OR BITAND("U"."SPARE1",16)=0 OR
              (SYS_CONTEXT('userenv','current_edition_name')='ORA$BASE' AND "U"."TYPE#"<>2) OR ("U"."TYPE#"=2 AND
PLAN_TABLE_OUTPUT
              "U"."SPARE2"=TO_NUMBER(SYS_CONTEXT('userenv','current_edition_id'))) OR  IS NOT NULL))
  51 - access("U"."NAME"="CDU"."USER_NAME")
  53 - access("S"."BASE_SYN_ID"=PRIOR NULL)
       filter( IS NOT NULL)
  54 - filter((("O"."TYPE#"<>4 AND "O"."TYPE#"<>5 AND "O"."TYPE#"<>7 AND "O"."TYPE#"<>8 AND "O"."TYPE#"<>9 AND
              "O"."TYPE#"<>10 AND "O"."TYPE#"<>11 AND "O"."TYPE#"<>12 AND "O"."TYPE#"<>13 AND "O"."TYPE#"<>14 AND "O"."TYPE#"<>22 AND
              "O"."TYPE#"<>87 AND "O"."TYPE#"<>88) OR BITAND("U"."SPARE1",16)=0 OR
              (SYS_CONTEXT('userenv','current_edition_name')='ORA$BASE' AND "U"."TYPE#"<>2) OR ("U"."TYPE#"=2 AND
              "U"."SPARE2"=TO_NUMBER(SYS_CONTEXT('userenv','current_edition_id'))) OR  IS NOT NULL))
  55 - access("O"."OWNER#"="U"."USER#")
  57 - access("S"."OWNER"="BU"."NAME" AND "BU"."USER#"="O"."SPARE3")
PLAN_TABLE_OUTPUT
  59 - access("S"."NAME"="O"."NAME")
  61 - filter("O"."TYPE#"=5)
  63 - access("U2"."TYPE#"=2 AND "U2"."SPARE2"=TO_NUMBER(SYS_CONTEXT('userenv','current_edition_id')))
       filter(("U2"."TYPE#"=2 AND "U2"."SPARE2"=TO_NUMBER(SYS_CONTEXT('userenv','current_edition_id'))))
  64 - access("O2"."DATAOBJ#"=:B1 AND "O2"."TYPE#"=88 AND "O2"."OWNER#"="U2"."USER#")
  65 - filter(( IS NOT NULL OR ("S"."NODE" IS NULL AND  IS NOT NULL)))
  67 - access("S"."OBJ#"=:B1)
  68 - filter((("BA"."GRANTOR#"=USERENV('SCHEMAID') OR  IS NOT NULL) AND (("O"."TYPE#"<>4 AND "O"."TYPE#"<>5 AND
              "O"."TYPE#"<>7 AND "O"."TYPE#"<>8 AND "O"."TYPE#"<>9 AND "O"."TYPE#"<>10 AND "O"."TYPE#"<>11 AND "O"."TYPE#"<>12 AND
              "O"."TYPE#"<>13 AND "O"."TYPE#"<>14 AND "O"."TYPE#"<>22 AND "O"."TYPE#"<>87 AND "O"."TYPE#"<>88) OR
              BITAND("U"."SPARE1",16)=0 OR (INTERNAL_FUNCTION("O"."TYPE#") AND
PLAN_TABLE_OUTPUT
              ((SYS_CONTEXT('userenv','current_edition_name')='ORA$BASE' AND "U"."TYPE#"<>2) OR ("U"."TYPE#"=2 AND
              "U"."SPARE2"=TO_NUMBER(SYS_CONTEXT('userenv','current_edition_id'))) OR  IS NOT NULL)))))
  69 - filter(:B1 IS NULL)
  74 - access("BU"."NAME"=:B1)
  75 - access("BU"."USER#"="O"."SPARE3" AND "O"."NAME"=:B1)
  76 - access("O"."OWNER#"="U"."USER#")
  77 - access("BA"."OBJ#"="O"."OBJ#")
  78 - filter("KZSROROL"=:B1)
  80 - access("U2"."TYPE#"=2 AND "U2"."SPARE2"=TO_NUMBER(SYS_CONTEXT('userenv','current_edition_id')))
       filter(("U2"."TYPE#"=2 AND "U2"."SPARE2"=TO_NUMBER(SYS_CONTEXT('userenv','current_edition_id'))))
  81 - access("O2"."DATAOBJ#"=:B1 AND "O2"."TY

Similar Messages

  • Same exact update runs fine in one db but causes ORA-00904 in another

    I have an update statement that runs fine in one db but causes "" error in another. The two databases table structures are the same. I checked for synonyms and reserved words on BASE and COMPANY_ID but did not come up with anything. The db where it is working is 10.2. The db where it is not working is 10.1.
    Here is the statement:
    1 UPDATE t_company base
    2 SET (company_name, company_name_sid, company_name_lco, canonical_name,
    3 short_name, short_name2) =
    4 (SELECT company_name, source_id, company_name_lco, canonical_name,
    5 short_name, short_name2
    6 FROM t_auth_company comp
    7 WHERE comp.company_id = base.company_id
    8 AND source_id =
    9 (SELECT source_id
    10 FROM (SELECT auth.source_id, trumping_order
    11 FROM t_auth_company auth,
    12 t_trumping_rule rl
    13 WHERE auth.company_id = base.company_id
    14 AND auth.company_name IS NOT NULL
    15 AND rl.source_id = auth.source_id
    16 AND rl.attribute_id = 'abc'
    17 ORDER BY rl.trumping_order)
    18 WHERE ROWNUM = 1))
    19 WHERE
    20 (-- The company has been updated
    21 company_id IN (
    22 SELECT company_id
    23 FROM t_auth_company auth
    24 WHERE auth.company_name_lco >= sysdate
    25 OR auth.company_id_lco >= sysdate)
    26 OR
    27 ( -- The trumping rule for the attribute has been changed
    28 SELECT MAX(last_changed_on)
    29 FROM t_trumping_rule rl
    30 WHERE rl.attribute_id = 'abc' ) >= sysdate
    31 )
    32 -- The company has been merged
    33 AND 1 < (SELECT COUNT (*)
    34 FROM t_auth_company auth
    35* WHERE auth.company_id = base.company_id)
    SQL> /
    WHERE auth.company_id = base.company_id
    ERROR at line 13:
    ORA-00904: "BASE"."COMPANY_ID": invalid identifier
    Thank You
    Boris

    Thank you for responding. It is syntactically working in the 10.2 database. Please, see this:
    SQL> UPDATE t_company base
    2 SET (company_name, company_name_sid, company_name_lco, canonical_name,
    3 short_name, short_name2) =
    4 (SELECT company_name, source_id, company_name_lco, canonical_name,
    5 short_name, short_name2
    6 FROM t_auth_company comp
    7 WHERE comp.company_id = base.company_id
    8 AND source_id =
    9 (SELECT source_id
    10 FROM (SELECT auth.source_id, trumping_order
    11 FROM t_auth_company auth,
    12 t_trumping_rule rl
    13 WHERE auth.company_id = base.company_id
    14 AND auth.company_name IS NOT NULL
    15 AND rl.source_id = auth.source_id
    16 AND rl.attribute_id = 'abc'
    17 ORDER BY rl.trumping_order)
    18 WHERE ROWNUM = 1))
    19 WHERE
    20 (-- The company has been updated
    21 company_id IN (
    22 SELECT company_id
    23 FROM t_auth_company auth
    24 WHERE auth.company_name_lco >= sysdate
    25 OR auth.company_id_lco >= sysdate)
    26 OR
    27 ( -- The trumping rule for the attribute has been changed
    28 SELECT MAX(last_changed_on)
    29 FROM t_trumping_rule rl
    30 WHERE rl.attribute_id = 'abc' ) >= sysdate
    31 )
    32 -- The company has been merged
    33 AND 1 < (SELECT COUNT (*)
    34 FROM t_auth_company auth
    35 WHERE auth.company_id = base.company_id)
    36 /
    0 rows updated.
    SQL>
    The table structures are as follows:
    CREATE TABLE RTCR_UCDB.T_AUTH_COMPANY
    AUTH_COMPANY_ID NUMBER(22),
    SOURCE_ID NUMBER(3) NOT NULL,
    LD_COMPANY_ID NUMBER(22),
    SOURCE_COMPANY_ID VARCHAR2(150 BYTE),
    MATCH_DECISION NUMBER(1) DEFAULT 0 NOT NULL,
    MATCH_DECISION_LCO DATE DEFAULT sysdate,
    COMPANY_ID NUMBER(22),
    COMPANY_ID_LCO DATE,
    COMPANY_NAME VARCHAR2(150 BYTE),
    COMPANY_NAME_LCO DATE DEFAULT sysdate,
    CANONICAL_NAME VARCHAR2(150 BYTE),
    SHORT_NAME VARCHAR2(150 BYTE),
    SHORT_NAME2 VARCHAR2(150 BYTE),
    URL VARCHAR2(150 BYTE),
    URL_LCO DATE DEFAULT sysdate,
    NURL VARCHAR2(150 BYTE),
    PRIMARY_SIC VARCHAR2(150 BYTE),
    PRIMARY_SIC_LCO DATE DEFAULT sysdate,
    PRIMARY_TICKER VARCHAR2(15 BYTE),
    PRIMARY_TICKER_LCO DATE DEFAULT sysdate,
    EXCHANGE_ID VARCHAR2(60 BYTE),
    EXCHANGE_ID_LCO DATE DEFAULT sysdate,
    NEXCHANGE_ID VARCHAR2(60 BYTE),
    ADDRESS VARCHAR2(150 BYTE),
    ADDRESS_LCO DATE DEFAULT sysdate,
    NADDRESS VARCHAR2(150 BYTE),
    NADDRESS_CONTAINS VARCHAR2(150 BYTE),
    CITY VARCHAR2(150 BYTE),
    CITY_LCO DATE DEFAULT sysdate,
    NCITY VARCHAR2(150 BYTE),
    STATE VARCHAR2(150 BYTE),
    STATE_LCO DATE DEFAULT sysdate,
    NSTATE VARCHAR2(150 BYTE),
    POSTAL_CODE VARCHAR2(15 BYTE),
    POSTAL_CODE_LCO DATE DEFAULT sysdate,
    NPOSTAL_CODE VARCHAR2(15 BYTE),
    COUNTRY_ID VARCHAR2(10 BYTE),
    COUNTRY_ID_LCO DATE DEFAULT sysdate,
    NCOUNTRY_ID VARCHAR2(10 BYTE),
    TELEPHONE VARCHAR2(60 BYTE),
    TELEPHONE_LCO DATE DEFAULT sysdate,
    NPHONE VARCHAR2(60 BYTE),
    PHONE_7D VARCHAR2(60 BYTE),
    PHONE_AREA VARCHAR2(60 BYTE),
    FAX VARCHAR2(60 BYTE),
    FAX_LCO DATE DEFAULT sysdate,
    NFAX VARCHAR2(60 BYTE),
    GW_COMPANY_ID VARCHAR2(150 BYTE),
    GW_COMPANY_ID_LCO DATE DEFAULT sysdate,
    CIK_NUMBER VARCHAR2(150 BYTE),
    CIK_NUMBER_LCO DATE DEFAULT sysdate,
    IRS_EIN VARCHAR2(150 BYTE),
    IRS_EIN_LCO DATE DEFAULT sysdate,
    MIN_DATA_FLAG VARCHAR2(1 BYTE) DEFAULT 'N' NOT NULL,
    OBSOLETE_FLAG VARCHAR2(1 BYTE) DEFAULT 'N' NOT NULL,
    OBSOLETE_FLAG_LCO DATE,
    LAST_CHANGED_BY VARCHAR2(50 BYTE) DEFAULT user NOT NULL,
    LAST_CHANGED_ON DATE DEFAULT sysdate NOT NULL,
    CREATED_ON DATE NOT NULL
    CREATE TABLE RTCR_UCDB.T_TRUMPING_RULE
    SOURCE_ID NUMBER(3) NOT NULL,
    ATTRIBUTE_ID NUMBER(5) NOT NULL,
    TRUMPING_ORDER NUMBER(3),
    LAST_CHANGED_BY VARCHAR2(50 BYTE) DEFAULT USER,
    LAST_CHANGED_ON DATE DEFAULT sysdate
    CREATE TABLE RTCR_UCDB.T_COMPANY
    COMPANY_ID NUMBER(22),
    COMPANY_NAME VARCHAR2(150 BYTE),
    COMPANY_NAME_SID NUMBER(3),
    COMPANY_NAME_LCO DATE,
    CANONICAL_NAME VARCHAR2(150 BYTE),
    SHORT_NAME VARCHAR2(150 BYTE),
    SHORT_NAME2 VARCHAR2(150 BYTE),
    URL VARCHAR2(150 BYTE),
    URL_SID NUMBER(3),
    URL_LCO DATE,
    NURL VARCHAR2(150 BYTE),
    PRIMARY_SIC VARCHAR2(150 BYTE),
    PRIMARY_SIC_SID NUMBER(3),
    PRIMARY_SIC_LCO DATE,
    PRIMARY_TICKER VARCHAR2(15 BYTE),
    PRIMARY_TICKER_SID NUMBER(3),
    PRIMARY_TICKER_LCO DATE,
    EXCHANGE_ID VARCHAR2(60 BYTE),
    EXCHANGE_ID_SID NUMBER(3),
    EXCHANGE_ID_LCO DATE,
    NEXCHANGE_ID VARCHAR2(60 BYTE),
    ADDRESS VARCHAR2(150 BYTE),
    ADDRESS_SID NUMBER(3),
    ADDRESS_LCO DATE,
    NADDRESS VARCHAR2(150 BYTE),
    CITY VARCHAR2(150 BYTE),
    CITY_SID NUMBER(3),
    CITY_LCO DATE,
    NCITY VARCHAR2(150 BYTE),
    STATE VARCHAR2(150 BYTE),
    STATE_SID NUMBER(3),
    STATE_LCO DATE,
    NSTATE VARCHAR2(150 BYTE),
    POSTAL_CODE VARCHAR2(15 BYTE),
    POSTAL_CODE_SID NUMBER(3),
    POSTAL_CODE_LCO DATE,
    NPOSTAL_CODE VARCHAR2(15 BYTE),
    COUNTRY_ID VARCHAR2(10 BYTE),
    COUNTRY_ID_SID NUMBER(3),
    COUNTRY_ID_LCO DATE,
    NCOUNTRY_ID VARCHAR2(10 BYTE),
    TELEPHONE VARCHAR2(60 BYTE),
    TELEPHONE_SID NUMBER(3),
    TELEPHONE_LCO DATE,
    NPHONE VARCHAR2(60 BYTE),
    PHONE_7D VARCHAR2(60 BYTE),
    PHONE_AREA VARCHAR2(60 BYTE),
    FAX VARCHAR2(60 BYTE),
    FAX_SID NUMBER(3),
    FAX_LCO DATE,
    NFAX VARCHAR2(60 BYTE),
    GW_COMPANY_ID VARCHAR2(150 BYTE),
    GW_COMPANY_ID_SID NUMBER(3),
    GW_COMPANY_ID_LCO DATE,
    CIK_NUMBER VARCHAR2(150 BYTE),
    CIK_NUMBER_SID NUMBER(3),
    CIK_NUMBER_LCO DATE,
    IRS_EIN VARCHAR2(150 BYTE),
    IRS_EIN_SID NUMBER(3),
    IRS_EIN_LCO DATE,
    LAST_CHANGED_BY VARCHAR2(50 BYTE) DEFAULT user NOT NULL,
    LAST_CHANGED_ON DATE DEFAULT sysdate NOT NULL,
    CREATED_ON DATE NOT NULL
    )

  • Follwing query fails on one database, but the same works on other Database

    Hi,
    The following SQL fails on one database with ORA-01722 but the same works on other database.
    SQL> SELECT i.version, d.name, i.instance_name, i.host_name
    FROM v$instance i, v$database d, v$parameter p 2
    3 WHERE p.name = 'instance_number'
    4 AND DECODE(p.value, 0, 1, p.value) = i.instance_number;
    AND DECODE(p.value, 0, 1, p.value) = i.instance_number
    ERROR at line 4:
    ORA-01722: invalid number
    both databases are at same version (10.2.0.1) both are on same machine.
    Initailly I suspected NLS settings, I am surprised to see NLS settings are also same on both the databases.
    Any thoughts why is it happening

    Thanks for the reply
    Yes, i know that i am comparing varchar against number.
    bu there is no way that the database where the query is working has correct types on both sides as the tables are standard oracle dictionary tables.
    Yes, i tried this earlier, it works
    AND DECODE(p.value, '0', '1', p.value) = to_char(i.instance_number)
    it is very weired to see that error, i feel it something else that causing the trouble.

  • Query running fine in one environment but failing in other environment

    Hi,
    I have a query which i am trying to execute in two different environments.
    Test :- Oracle Database 11g Release 11.2.0.1.0 - 64bit Production
    Prod:- Oracle Database 11g Release 11.2.0.1.0 - 64bit Production
    Now query executes finely in one environment and fails in other environment.
    It gives following error.
    ORA-01861: literal does not match format string
    01861. 00000 - "literal does not match format string"
    The query is too long and contains CHAR-DATE and DATE-CHAR conversions.
    The same query works fine on TEST environment and and fails on PROD environment.
    Any help related to it would be appreciated.
    Thanks,
    Mahesh

    MaheshGx wrote:
    Hi,
    I have a query which i am trying to execute in two different environments.
    Test :- Oracle Database 11g Release 11.2.0.1.0 - 64bit Production
    Prod:- Oracle Database 11g Release 11.2.0.1.0 - 64bit Production
    Now query executes finely in one environment and fails in other environment.
    It gives following error.
    ORA-01861: literal does not match format string
    01861. 00000 - "literal does not match format string"
    The query is too long and contains CHAR-DATE and DATE-CHAR conversions.
    The same query works fine on TEST environment and and fails on PROD environment.
    Any help related to it would be appreciated.
    Thanks,
    MaheshThat's called a bug. One caused by the person who developed the code. They relied on implicit conversion between strings and dates when
    production quality code will always use to_char and to_date functions with a format mask.

  • I have an imac g4 purchased Dec 2003 runnung OS 10.5.8.  It runs fine with airport off, but when I turn airport on it freezes with the black page,  "restart by holding power key . . ."  I swapped the airport extreme card with the one in my ibook G4 (purch

    i have an imac g4 purchased Dec 2003 runnung OS 10.5.8.  It runs fine with airport off, but when I turn airport on it freezes with the black page,  "restart by holding power key . . ."  I swapped the airport extreme card with the one in my ibook G4 (purchased same date and running same OS).  No change in operation.
    I am running wifi from verizon.  Recently changed from mifi2200 to jetpak 4620 in a 3G location.  Ibook running fine, desktop freezes.  If I can boot desktop in safe mode and get airport turned off in time. then I can reboot regularly and imac runs flawlessly with no wireless.Have run disk utilities and TechTool Pro rebuild etc, but nothing has worked.  How do I fine the culprit?

    the power logix thing was really sad. apple changed so much after 10.4.8 that there wasn't a viable way to patch the software.
    That statement is precisely why I don't believe in blindly updating the OS, especially in a non-standard machine.
    We can't expect third parties to support us forever, and it is shameful to break something that works fine, except that we updated the OS....
    I think that any upgrade or modification to a machine or the OS greatly increases the risk of trouble or incompatibility with current configuration and "new" system files.
    After all, the component or software could only be tested as far as the current OS version when the component or software was released.
    Beyond that, we are all "beta testing".
    Following a beta tester protocol, and applying updates to a cloned system drive first, is a prudent way to approach updates, and not only for older, heavily modified machines.
    After 10.4.8 and moreso with Leopard, the focus is primarily on Intel architecture, not PPC architecture.
    Like it or not, we are all updating to the abyss of the extinction of our machines, unless we can be satisfied with the last stable version of OS that works well with our hardware and software.
    I wish they would include the latest pkgs at least with software update.
    Yes, having individual packages, rather than lump "OS X 10.x.x" updates would be nice.
    This way, one could update as one sees fit. That is to say, for example, fix the Quicktime, but leave my Network alone, etc., etc.
    In all fairness, Apple does provide for some breakdown of updates, but I believe there is much room for improvement, especially, as you point out, with regard to the core services portion of the OS.
    Until then, I'll leave Software Update disabled.......

  • SQL Query to get Project Plan Name and Resource Name from Reporting database of Project Server 2007

    Can you please help me to write an SQL Query to get Project Plan Name and Resource Name from Reporting database of Project Server 2007. Thanks!!

    Refer
    http://gallery.technet.microsoft.com/projectserver/Server-20072010-SQL-Get-a99d4bc6
    SELECT
    dbo.MSP_EpmAssignment_UserView.ProjectUID,
    dbo.MSP_EpmAssignment_UserView.TaskUID,
    dbo.MSP_EpmProject_UserView.ProjectName,
    dbo.MSP_EpmTask_UserView.TaskName,
    dbo.MSP_EpmAssignment_UserView.ResourceUID,
    dbo.MSP_EpmResource_UserView.ResourceName,
    dbo.MSP_EpmResource_UserView.ResourceInitials
    INTO #TempTable
    FROM dbo.MSP_EpmAssignment_UserView INNER JOIN
    dbo.MSP_EpmProject_UserView ON dbo.MSP_EpmAssignment_UserView.ProjectUID = dbo.MSP_EpmProject_UserView.ProjectUID INNER JOIN
    dbo.MSP_EpmTask_UserView ON dbo.MSP_EpmAssignment_UserView.TaskUID = dbo.MSP_EpmTask_UserView.TaskUID INNER JOIN
    dbo.MSP_EpmResource_UserView ON dbo.MSP_EpmAssignment_UserView.ResourceUID = dbo.MSP_EpmResource_UserView.ResourceUID
    SELECT
    ProjectUID,
    TaskUID,
    ProjectName,
    TaskName,
    STUFF((
    SELECT ', ' + ResourceInitials
    FROM #TempTable
    WHERE (TaskUID = Results.TaskUID)
    FOR XML PATH (''))
    ,1,2,'') AS ResourceInitialsCombined,
    STUFF((
    SELECT ', ' + ResourceName
    FROM #TempTable
    WHERE (TaskUID = Results.TaskUID)
    FOR XML PATH (''))
    ,1,2,'') AS ResourceNameCombined
    FROM #TempTable Results
    GROUP BY TaskUID,ProjectUID,ProjectName,TaskName
    DROP TABLE #TempTable
    -Prashanth

  • Hi in my sql query i applied like condition (like '%TEST') but it is taking long time

    Hi in my sql query i applied like condition (like '%TEST') but it is taking long time. I applied indexes also,but still i'm facing the same problem. In my databse nearly 2,00,000 records their.

    Hi Manikandan
    Is there a difference in performance between running the query in BEx and WebI?
    have you aggregates in place on the BEx side of things?
    When you say its taking too long to open the report, have you a variable screen coming up for the report and is that what is taking the time or is it the report execution.
    With regards
    Gill

  • ANT Deployment issue. works fine in one environment but fails in other

    Hi,
    Ant script is working fine in Dev environment but is failing in the other environment. Somehow the BPEL server is not able to pick the latest deployed process , due to this the dependent BPEL processes are failing. If we restart the server , it moves forward and then fails at the point where it couldn’t find reference to the processes deployed after restart. Restarting the server at every failed interval will deploy all the BPEL processes which is not the solution.
    example : we have BPEL Processes say A, B, C, D and E. A,B are independent processes C is dependent on A, D is independent and E is dependent on D. So I have Ant script to deploy in A,B,C,D,E order. Now I run the Ant Script: It deploys A,B processes and Fails at C saying it couldn't find the process A.wsdl(But A is deployed). So if i restart now it recognizes A and B are deployed so C is also deployed succesfully it also deploys D as it is Independent but fails at E. If i restart the server E is also deployed.
    The Environment is clustered.
    Any suggestion to make my Ant script to run at a go will be highly appreciated
    Thanks
    Krishna

    Hi KrishnaBhaskarla,
    I have something related to ant script, Can you please provide me the steps for deploying applications using ant script.
    Regards
    Kumar

  • Scheduled tasks run fine at first then stop running

    This has been an ongoing issue with every Server 2012 machine that we have running tasks (a buddy of mine has the same issue with 2008 R2).  At first the task will run fine as it should but then out of the blue it will simply stop running.  The
    last run time could be months ago and the next run time will be the normal scheduled time to run.  Last run result is always 0x0.  There is also nothing in the history tab as I assume it's been too long ago since the last time it ran.
    I can't figure out what's keeping these tasks from properly triggering and running.  Now before anyone starts going down a list of settings I should check that I might have goofed up, remember, these run fine at first and which jobs stop running properly
    are completely random.  Also, some of these tasks are Microsoft generated tasks like Windows Backup:
    This happens on MS tasks as well as my own tasks that run fine at first but then just stop.  The only fix on a per task basis that I've been able to come up with is to delete the job and create it from scratch where it will then work forever or get
    stuck.  It's completely random.
    I would greatly appreciate any help on this matter as it's driving me absolutely nuts.

    Hi,
    In order to solve the problem more efficiently I need to clarify some information.
    Are there any errors about the scheduled tasks?
    Here are some links below that could be helpful to you:
    Troubleshooting Task Scheduler
    http://technet.microsoft.com/en-us/library/cc721846.aspx
    Scheduled task not running on Windows Server 2008 but working on Windows XP
    http://social.technet.microsoft.com/Forums/windowsserver/en-US/46a867a0-8432-4b90-abe3-9a5661d1b276/scheduled-task-not-running-on-windows-server-2008-but-working-on-windows-xp
    Task Scheduler did not run on the planned time. (Windows Server 2008 SP2)
    http://social.technet.microsoft.com/Forums/windowsserver/en-US/d817535a-0210-47e9-a0fe-3c6dbf38b777/task-scheduler-did-not-run-on-the-planned-time-windows-server-2008-sp2
    scheduled task not work good on windows server 2008
    http://social.technet.microsoft.com/Forums/windowsserver/en-US/f7baffb3-be5e-4d2d-953d-160e258089e9/scheduled-task-not-work-good-on-windows-server-2008
    Use the Windows Server 2012 Essentials Log Collector
    http://technet.microsoft.com/en-us/library/jj206706.aspx
    Best Regards,
    Amy Wang

  • I can't seem to run my Playlist under Yahoo Music.. it runs fine with IE 9 but not Firefox 4 .... any idea why?

    I can't seem to run my Playlist under Yahoo Music.. it runs fine with IE 9 but not Firefox 4 .... any idea why? I can run a single song just not my playlist.
    Thanks.

    Had this problem for quite a while but found a work-a-round. I click anywhere in the text I want to delete and insert any character. I am then able to block and delete any text I want to. It's been working great.

  • The tools on Adobe Photoshop Elements 9 seemed to have frozen. The crop symbol is 3 of the symbols nest to each other. The hand move tool is not one hand but 3 next to each other. Other tools won't work at all. Really nice!

    Ya, okay ! I use a number of PSE programs, one of which is PSE 9. The tools for some reason seem to have frozen. When I use the move tool I don't get just one hand but 3 hand symbols all next to each other. Same thing with the crop tool, I don't get one symbol but 3 all next to each other. There are a couple of tools that just don't work at all.  It's like the PSE 9 got hit with some virus or sorts. Oh well, live and learn.  Trying to get through to tech service is next to impossible.

    Have you seen this other thread you started about this problem?
    Photoshop Elements 9 is messed up.
    Did you use Barbara's fix?
    It would be less confusing if you only posted this question once, not three times:
    HOW DO I RESET ALL THE TOOLS IN PSE 9 ? THE CURSOR IS REALLY MESSED UP AND DOES NOT WORK WITH THE TOOLS. I TOUCH THE HAND AND I GET 3 HANDS, I TRY TO USE THE CROP AND I GET 3 SMALL CIRCLES.  THE CURSOR IS REALLY MESSED UP. DO I HAVE TO GET ANOTHER PSE 9 ?
    Photoshop Elements 9 is messed up.
    The tools on Adobe Photoshop Elements 9 seemed to have frozen. The crop symbol is 3 of the symbols nest to each other. The hand move tool is not one hand but 3 next to each other. Other tools won't work at all. Really nice!

  • Can anyone explain why the code compiles on one database but not another?

    I have two databases, both running 10.2.0.4, same hardware/OS platform.
    On one database, this code compiles just fine, on the second database, I get errors as shown below:
    SQL> SET SERVEROUTPUT ON SIZE 1000000;
    SQL>
    SQL> create or replace procedure testproc as
    2 vCount number;
    3 vCmd varchar2(2048);
    4 vLastName varchar2(30);
    5 vFirstName varchar2(30);
    6 vPK integer := 0;
    7 vSortLN varchar2(30);
    8 vSortFN varchar2(30);
    9 cursor cPERSON is
    10 select LastName,
    11 FirstName
    12 from GENERIC.PERSON
    13 order by LastName, FirstName;
    14 BEGIN
    15 select count(*) into vCount from USER_OBJECTS where object_name = 'ML4TEMPPERSON';
    16
    17 IF (vCount = 0) THEN
    18 /* NOTE: Omit semi-colon from command. */
    19 vCmd := 'create table ML4TEMPPERSON (PK integer not null, LastName varchar2(30), SortLN varchar2(30), FirstName varchar2(30), SortFN varchar2(30))';
    20 Execute Immediate vCmd;
    21 vCmd := 'alter table ML4TEMPPERSON add (constraint XPKML4TEMPPERSON PRIMARY KEY (PK))';
    22 Execute Immediate vCmd;
    23 END IF;
    24
    25 delete from ML4TEMPPERSON;
    26
    27 for P in cPERSON
    28 loop
    29 vLastName := rpad(P.LastName, 30, ' ');
    30 vFirstName := rpad(P.FirstName, 30, ' ');
    31 vSortLN := vLastName;
    32 vSortFN := vFirstName;
    33 DBMS_OUTPUT.PUT_LINE(vLastName || ', ' || vFirstName);
    34 vPK := vPK+1;
    35 INSERT into ML4TEMPPERSON
    36 ( PK, LastName, SortLN, FirstName, SortFN)
    37 values
    38 (vPK, vLastName, vSortLN, vFirstName, vSortFN);
    39 end loop;
    40 IF (vPK > 0) THEN
    41 COMMIT;
    42 END IF;
    43 END;
    44 /
    Warning: Procedure created with compilation errors.
    SQL> show errors
    Errors for PROCEDURE TESTPROC:
    LINE/COL ERROR
    25/3 PL/SQL: SQL Statement ignored
    25/15 PL/SQL: ORA-00942: table or view does not exist
    35/7 PL/SQL: SQL Statement ignored
    35/19 PL/SQL: ORA-00942: table or view does not exist
    SQL>

    Your table ML4TEMPPERSON doesn't exist in your second database, and you want do delete ans insert, may be in first database the table ML4TEMPPERSON exist
    Try this code. /* Formatted on 2009/05/21 09:10 (Formatter Plus v4.8.8) */
    SET SERVEROUTPUT ON SIZE 1000000;
    CREATE OR REPLACE PROCEDURE testproc
    AS
       vcount       NUMBER;
       vcmd         VARCHAR2 (2048);
       vlastname    VARCHAR2 (30);
       vfirstname   VARCHAR2 (30);
       vpk          INTEGER         := 0;
       vsortln      VARCHAR2 (30);
       vsortfn      VARCHAR2 (30);
       CURSOR cperson
       IS
          SELECT   lastname, firstname
              FROM generic.person
          ORDER BY lastname, firstname;
    BEGIN
       SELECT COUNT (*)
         INTO vcount
         FROM user_objects
        WHERE object_name = 'ML4TEMPPERSON';
       IF (vcount = 0)
       THEN
    /* NOTE: Omit semi-colon from command. */
          vcmd :=
             'create table ML4TEMPPERSON (PK integer not null, LastName varchar2(30), SortLN varchar2(30), FirstName varchar2(30), SortFN varchar2(30))';
          EXECUTE IMMEDIATE vcmd;
          vcmd :=
             'alter table ML4TEMPPERSON add (constraint XPKML4TEMPPERSON PRIMARY KEY (PK))';
          EXECUTE IMMEDIATE vcmd;
       END IF;
       vcmd := 'delete from ML4TEMPPERSON';
       EXECUTE IMMEDIATE vcmd;
       FOR p IN cperson
       LOOP
          vlastname := RPAD (p.lastname, 30, ' ');
          vfirstname := RPAD (p.firstname, 30, ' ');
          vsortln := vlastname;
          vsortfn := vfirstname;
          DBMS_OUTPUT.put_line (vlastname || ', ' || vfirstname);
          vpk := vpk + 1;
          vcmd :=
                'INSERT into ML4TEMPPERSON
    ( PK, LastName, SortLN, FirstName, SortFN)
    values
             || vpk
             || ', '
             || vlastname
             || ','
             || vsortln
             || ','
             || vfirstname
             || ','
             || vsortfn
             || ')';
          EXECUTE IMMEDIATE vcmd;
       END LOOP;
       IF (vpk > 0)
       THEN
          COMMIT;
       END IF;
    END;
    /Edited by: Salim Chelabi on 2009-05-21 06:12

  • Allocate channel sbt_tape hangs for one database, but not others.

    We are using Commvault's Simpana Oracle iDataAgent v8.0.0 on Windows 2003 R2.
    The database version is 10.2.0.4 and all of the databases run from a single ORACLE_HOME.
    The problem is that in one of my databases, allocate channel ... type sbt_tape... hangs.
    I'm not connecting to a catalog, on the command line I execute 'rman target /'
    My simple script is:
    run {
    allocate channel ch1 type 'sbt_tape'
    PARMS="ENV=(CvClientName=testsvr, CVInstanceName=Instance001), BLKSIZE=262144"
    release channel ch1;
    In other databases running from this OH, "allocate channel" works fine. But in the one database that I need
    to back up, it hangs - just sits there.
    I added 'trace=2' to the allocate channel command, but it doesn't produce any useful information. Neither
    does the alert log.
    What else can I do to debug this problem? Is there a way to recreate the database packages that
    RMAN executes for a backup?
    Thank you for your help.
    Mike

    I'm not sure of what value a doc referencing Oracle 9i will do for you so my suggestion would be to first of all leverage the many V$ dynamic performance views to see what it is the Oracle thinks is happening. Perhaps nothing since you don't get a trace file but do your due diligence. You can find them by running the following:
    SELECT view_name FROM dba_views WHERE view_name LIKE '%RMAN%'Then open an SR at MyOracleSupport.

  • Code runs fine in debug mode but hangs when compiled in release mode

    I am struggling with the following problem. I have code which runs fine when it is executed in debug mode. However, when I compile it in release mode and run the executable, the code freezes and does not work. The code acquires images from a Hamamatsu camera. In the debug mode I am able to continuously acquire images. However, in the release version, the code hangs after acquiring the first image.
    I am using LabWindows/CVI version 7.
    I would greatly appreciate if I can get any help/suggestions in resolving this problem?
    Thanks!
    Regards,
    Sripad
    Solved!
    Go to Solution.

    Sripad:
    If you search this forum for "debug release crash" or "release version crash" or similar phrases, you'll find that this is a pretty common question.  Look through the other posts you find here to see if anything is applicable to you.
    The debug version does some things like padding variables so you can sometimes overrun your declared variable space without overwriting the next variable.  In the release, the variables are packed, so if you overrun one, you are overwriting another.  Just one possible difference.
    You can do some things in your release code to see where things get lost, like (temporarily using printf statements after multiple statements at the start and end of your loop to try to identify that failing line of code.
    Look through other threads to find other ideas.

  • Program running fine in Debug mode but failing in direct execution

    Hi All,
    I am facing a peculiar problem, I have created a report that create STO then Delivery and then Shipment one after one. I have used BAPI to do so. If STO creation is successful then Create Delivery and if delivery creation is also successfull then create Shipment.
    When I run this program by pressing execute button it is only creating STO and coming out ,but if I run it in Debug mode I get all the three( STO, Delivey,Shipment). Since it run fine in debug so I can't found where the problem is.
    Can any one help???
    Regards
    Hemant

    Hi guys,
    A learning for me .... how important WAIt parmeter is in commit work .. Initially i have not set WAIT paramater in commit BAPI to X due to this further processing.. Delivery and Shipment creation was failing in direct execution ... as after STO creation I was reding EKPO and that was failing in direct execution , but in backgroung everything was ok.
    Thanks for your time.
    Cheers
    Hemant

Maybe you are looking for

  • How can I prevent pages from opening documents from last session

    During my last session using Pages I selected and opened several documents. These documents were image heavy and pages froze.  Now I can't open any document without pages trying to open all these documents and freezing.   I've spent two hours trying

  • Can't update iPhoto since updating to Yosemite

    We updated our Mac last night to find this morning I couldn't open IPhoto. I am getting an error saying I need to upgrade to a newer version however when I am directed to the App store. When attempting to install the upgrade I am getting a message "a

  • Apple TV attached to an Onkyo receiver

    I have my Apple TV attached to an Onkyo receiver and my Samsung tv is attached as well.  The Samsung has a dvi port and I use a dvi hdmi adapter.  My problem is I have audio from the Apple TV but no video feed.  Any ideas what might be the problem?

  • How to change username and password for already running mappings

    Hi Gurus, We have created so many mappings(more than 200) in owb 11g and deployed them into production and all are running without any issues. Now we are in big problem and the reason is our internal team is asking us to use the new user and password

  • Copy of Raw Images

    I burned a series of RAW images to DVD on my Mac and then read them into Photoshop on my PC. Although all the images are RAW on the Mac, the copied as jpeg's to the DVD.??? How do I get the RAW images copied as RAW images? Chuck