[PLSQL] Onverwacht symbool bij stringdefinitie

Pagina: 1
Acties:
  • 128 views sinds 30-01-2008

  • Wilfred
  • Registratie: Januari 2000
  • Laatst online: 22-08-2022
Ik heb een stukje sql dat het prima doet....

code:
1
2
3
4
create table tb_temp as
select naam, adres, woonplaats
from tb_naw
where tb_NAW.woonplaats = 'Rotterdam';


nu wil ik het in een EXECUTE IMMEDIATE statement zetten om met PLSQL te kunnen uitvoeren..

code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
DECLARE

str_plaatsnaam varchar2 (200);

BEGIN

str_plaatsnaam := 'Rotterdam';

EXECUTE IMMEDIATE 'create table tb_temp as
select naam, adres, woonplaats
from tb_naw
where woonplaats = '||str_plaatsnaam|| ';

END;
/


FOUT in regel 10:
.ORA-06550: Regel 10:
PLS-00103: Symbool "Rotterdam" aangetroffen terwijl een van de volgende werd
verwacht:
. ( * @ % & = - + ; < / > at in is mod not rem
<an exponent (**)> <> or != or ~= >= <= <> and or like
between ||
Symbool ". werd ingevoegd voor "Rotterdam" om door te gaan.

Hoe kan ik dit oplossen?

Sign of my Time


  • Creepy
  • Registratie: Juni 2001
  • Laatst online: 17:10

Creepy

Tactical Espionage Splatterer

En wat heb je nu zelf al gedaan? Wat lukte daar niet mee? Puur een foutmelding dumpen en hopen dat wij het voor je gaan oplossing is hier eigenlijk not done.

Kan je daarnaast even een nieuwe titel via een topicreport doorgeven? Alleen PLSQL zegt niks over het probleem dat je nu hebt :)

"I had a problem, I solved it with regular expressions. Now I have two problems". That's shows a lack of appreciation for regular expressions: "I know have _star_ problems" --Kevlin Henney


  • Cyphax
  • Registratie: November 2000
  • Nu online

Cyphax

Moderator LNX
code:
1
2
3
4
EXECUTE IMMEDIATE 'create table tb_temp as
select naam, adres, woonplaats
from tb_naw
where woonplaats = '||str_plaatsnaam|| ';

Zie ik het verkeerd of wordt hier een string niet afgesloten?

Saved by the buoyancy of citrus


Verwijderd

Duidelijk een geval van te weinig quootjes. Voor elk quootje wat je wilt afdrukken/opnemen moet je één extra quootje opnemen.

Het volgende werkt:
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
DECLARE

str_plaatsnaam varchar2 (200);

BEGIN

str_plaatsnaam := 'Rotterdam';

EXECUTE IMMEDIATE 'create table tb_temp as
select naam, adres, woonplaats
from tb_naw
where woonplaats = '''||str_plaatsnaam|| '''';

END;
/

  • Wilfred
  • Registratie: Januari 2000
  • Laatst online: 22-08-2022
Ja te weinig Quotes inderdaad.
Dank je!

Sign of my Time


  • NMe
  • Registratie: Februari 2004
  • Laatst online: 22-01 23:51

NMe

Quia Ego Sic Dico.

Gewoon een kwestie van zelf even debuggen dus. Simpelweg een editor met code highlighting gebruiken had je probleem namelijk al opgelost. ;)
SQL:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
DECLARE

str_plaatsnaam varchar2 (200);

BEGIN

str_plaatsnaam := 'Rotterdam';

EXECUTE IMMEDIATE 'create table tb_temp as
select naam, adres, woonplaats
from tb_naw
where woonplaats = '||str_plaatsnaam|| ';

END;
/

'E's fighting in there!' he stuttered, grabbing the captain's arm.
'All by himself?' said the captain.
'No, with everyone!' shouted Nobby, hopping from one foot to the other.

Pagina: 1

Dit topic is gesloten.