ORA-01756: quoted string not properly terminated when I try to execute my code

前端 未结 3 1734
[愿得一人]
[愿得一人] 2021-01-18 08:34

I keep getting the following message every time I try to run this code in oracle. The code is as follows:

DROP TABLE movie;
CREATE TABLE movie (movie_id NUMB         


        
相关标签:
3条回答
  • 2021-01-18 08:56

    Try Oracle's quoting mechanisms :

    The mechanism is invoked with a simple "q" in PL/SQL only.

    The syntax is q'[...]', where the "[" and "]" characters can be any of the following as long as they do not already appear in the string.

    •!

    •[ ]

    •{ }

    •( )

    •< >

    Here For Example ,

    INSERT INTO movie (movie_id, title, description, released_by, released_on)
    VALUES('4', 'Godzilla', q'[The legendary tale of Godzilla comes roaring back to
     life. This time, it's the modern era, and Godzilla is a giant lizard who has
     been made fearsome through the interference of radiation.]', '1', '16-SEP-
    2014');
    

    It's always headache to find all single quotes and replace it with escape character.

    For more Reference Follow : THIS

    0 讨论(0)
  • 2021-01-18 09:05

    My solution try:

    <br>
    pelicula = array("titulo"=>"it's the modern era");
    <br>
    

    and insert this array.

    INSERT(%%%,pelicula["titulo"],%%%).

    Explicacion: Para evitar el problema de la comilla, copia la cadena a un array, inserta el nombre a traves de este array y el problema se acaba.

    0 讨论(0)
  • 2021-01-18 09:07

    Escape single quotes:

    INSERT INTO movie (movie_id, title, description, released_by, released_on)VALUES('4', 'Godzilla', 'The legendary tale of Godzilla comes roaring back to life. This time, it''s the modern era, and Godzilla is a giant lizard who has been made fearsome through the interference of radiation.', '1', '16-SEP-2014');
    

    Notice the it''s instead of it's.

    0 讨论(0)
提交回复
热议问题