Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

EXEC SQL , PROBLEM WITH SELECT

Former Member
0 Likes
819

Hi.

I have a external database in which I do the next query...

()

Data: cod_campana TYPE integer,

departament TYPE STRING.

EXEC SQL.

connect to 'EX_PP' as 'ex_pp'

ENDEXEC.

EXEC SQL.

set connection 'ex_pp'

ENDEXEC.

cod_campana = 272

departament = 'BKK' "-> This data it's variable

EXEC SQL.

OPEN c1 FOR

SELECT a.cod_modelo, a.nom_modelo2, a.cod_color, b.nom_color

FROM pro_modelos a ,con_color b

WHERE a.cod_modelo = b.cod_modelo

AND a.cod_campana = b.cod_campana

AND a.cod_color = b.numero

AND a.brand = :departament

AND a.cod_campana = :cod_campana

END EXEC

I obtain a dump and the reason it's in the phrase --> AND a.brand = :departament

When I execute the same query and don't put the variable --> AND a.brand = 'BKK' like this the program run correctly... and I don't obtain dump...

EXEC SQL.

OPEN c1 FOR

SELECT a.cod_modelo, a.nom_modelo2, a.cod_color, b.nom_color

FROM pro_modelos a ,con_color b

WHERE a.cod_modelo = b.cod_modelo

AND a.cod_campana = b.cod_campana

AND a.cod_color = b.numero

AND a.brand = 'BKK'

AND a.cod_campana = :cod_campana

END EXEC

I don't know what it's the problem, and how I can solve it...,

Can you help me??

I try the next phrases and not obtain a good result:

-


AND a.brand like :departament

-


departament = '"BSK"'

and a.brand = :departament

-


Thks for your help

5 REPLIES 5
Read only

Former Member
0 Likes
723

Try declaring departament as a character field with the same length as in the source table.

Rob

Read only

0 Likes
723

Dear Rob.

I try this..., In my external Database, the field brand it's a char 50.

I declarate in ABAP program like this --> DATA: departament(50).

But not ok yet.

Another idea???...

Thks.

Read only

Former Member
0 Likes
723

You can put the code in TRY-ENDTRY block, and CATCH the exceptions.

If you are sure of the asignation to "department" (try to debug), you can make this:

OPEN c1 FOR

SELECT a.cod_modelo, a.nom_modelo2, a.cod_color, b.nom_color

FROM pro_modelos a ,con_color b

WHERE a.cod_modelo = b.cod_modelo

AND a.cod_campana = b.cod_campana

AND a.cod_color = b.numero

AND a.brand = :departament

Remove (AND a.cod_campana = :cod_campana).

Or

OPEN c1 FOR

SELECT a.cod_modelo, a.nom_modelo2, a.cod_color, b.nom_color

FROM pro_modelos a ,con_color b

WHERE a.cod_modelo = b.cod_modelo

AND a.cod_campana = b.cod_campana

AND a.cod_color = b.numero

AND ( a.brand = :departament )

AND a.cod_campana = :cod_campana

Remember to put department or DEPARMENT in case.

Read only

0 Likes
723

Dear Alex.

I try the two forms that you tell me ..., and I debug... and it's no ok.

Dump appear again.

Another idea??

thks.

Read only

0 Likes
723

-