0

I am trying to run this statement but it is not working

EXECUTE IMMEDIATE 'UPDATE TPERSON SET NAME = 'john' WHERE NAME = 'John'';
diziaq
  • 6,881
  • 16
  • 54
  • 96
BlondeSue
  • 17
  • 3

1 Answers1

1

In simple cases use doubling every qoute

EXECUTE IMMEDIATE 'UPDATE TPERSON SET NAME = ''john'' WHERE NAME = ''John''';

Still there is a better option in Oracle - text blocks, where any inner quotes need no escaping

EXECUTE IMMEDIATE q'[UPDATE TPERSON SET NAME = 'john' WHERE NAME = 'John']';

More information and examples here

diziaq
  • 6,881
  • 16
  • 54
  • 96
  • This is giving me an error – BlondeSue Jul 28 '22 at 15:57
  • Error starting at line 23 in command: EXECUTE IMMEDIATE q'[UPDATE TPERSON SET NAME = 'john'' WHERE FULLNAME = 'John']' Error report: ORA-06550: line 1, column 17: PLS-00103: Encountered the symbol "UPDATE TPERSON SET NAME = 'john'' WHERE FULLNAME = 'John'" when expecting one of the following: := . ( @ % ; The symbol ":=" was substituted for "UPDATE TPERSON SET NAME = 'john'' WHERE FULLNAME = 'John'" to continue. 06550. 00000 - "line %s, column %s:\n%s" *Cause: Usually a PL/SQL compilation error. *Action: – BlondeSue Jul 28 '22 at 15:57
  • Error starting at line 23 in command: EXECUTE IMMEDIATE 'UPDATE TPERSON SET NAME = ''John'' WHERE NAME = ''john''' Error report: ORA-06550: line 1, column 17: PLS-00103: Encountered the symbol "UPDATE TPERSON SET NAME = 'John' WHERE NAME = 'john'" when expecting one of the following: := . ( @ % ; The symbol ":=" was substituted for "UPDATE TPERSON SET NAME = 'John' WHERE NAME = 'john'" to continue. 06550. 00000 - "line %s, column %s:\n%s" *Cause: Usually a PL/SQL compilation error. *Action: – BlondeSue Jul 28 '22 at 15:59
  • 1
    There's an redundant quote after `'john'` in the error message. Use exact copy of the snippet from the answer. – diziaq Jul 28 '22 at 16:04