cancel
Showing results for 
Search instead for 
Did you mean: 

ERROR Connection DB SQL

Former Member
0 Kudos

HI EXPERTS I NEED YOUR HELP URGENTLY¡¡

I'm new in ABAP programming and I need to do an Aplication connecting SQL and ABAP

I have made this code.. But when I run the aplication appears this error before close the connection to the BD

The error is DBIF_DSQL2_SQL_ERROR

SQL error 170

I think my connection is ok because the SY-SUBRC is setting to 0 after the statment . CONNECT to con_name

I don't know what happen... Could somebody help me??? this is my code:

DATA: c_pilot(15) TYPE c.

DATA con_name LIKE dbcon-con_name VALUE 'CON'.

EXEC SQL.

SET CONNECTION :con_name

ENDEXEC.

IF sy-subrc <> 0.

  • Connection not yet opened.

EXEC SQL.

CONNECT TO :con_name

ENDEXEC.

endif.

IF sy-subrc = 0.

  • Do something on connection 'con_name'

EXEC SQL.

select MBS

from flights into

:c_pilot.

ENDEXEC.

  • **** Runs normally before this, here appears the error

EXEC SQL.

SET CONNECTION :con_name

ENDEXEC.

EXEC SQL.

DISCONNECT :con_name

ENDEXEC.

ENDIF.

-

-


This is the DBCO DATA

Connection name : CON

DBMS: MSS

Conn. info: MSSQL_SERVER=NENITA MSSQL_DBNAME=MBS

I'm not ussing user neither password.

I 'm using minisap 4.6 with Gui Patch 6.2, WIndows Xp, and SQL 2000

THANKS FOR YOUR HELP

Edited by: ARACELI GONZALEZ on May 26, 2008 4:41 PM

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hello Araceli

Could you tell me how you set up MiniSAP to connect to SQL Server on WIndows XP. I developed a great deal using 'normal' SAP connecting to external databases, so I should be able to offer some guidance.

Regards

Ray

clas_hortien
Employee
Employee
0 Kudos

Hi,

sql error 170 means: syntax error.

This is the correct syntax.

select MBS into :c_pilot from flights.

Regards

Clas Hortien

Former Member
0 Kudos

Hi Clas Thank you very much

I changed that but did't solve the problem

Do you have another idea??

clas_hortien
Employee
Employee
0 Kudos

Hi,

two more things.

When the target database is an SAP MCOD system you have to specify the MSSQL_SCHEMA=mbs in your DBCON entry. If the owner of the objects in the target database is dbo, you have to specify dbo then.

The selection you made

select MBS into :c.. from flights

looks strange. Is MBS a column in the table flights, as it is the same as the database name. And does MBS really contains the pilot name ? I would suspect a column name like Pilot etc.

Regards

Clas Hortien

Former Member
0 Kudos

HI CLAS Thank veryyyyy much for your help and answers

I've changed some things and now my code is like this:

REPORT Z_CONEXBD_ARACELI2.

DATA: c_pilot TYPE FLIGHTS-pilot.

DATA: con_name LIKE dbcon-con_name VALUE 'CON_ARA'.

EXEC SQL.

SET CONNECTION :con_name

ENDEXEC.

IF sy-subrc <> 0.

  • Connection not yet opened.

EXEC SQL.

CONNECT TO :con_name

ENDEXEC.

endif.

  • Do something on connection 'con_name'

EXEC SQL.

select pilot

from flights

into :c_pilot.

ENDEXEC.

EXEC SQL.

SET CONNECTION :con_name

ENDEXEC.

EXEC SQL.

DISCONNECT :con_name

ENDEXEC.

I don't know how to know if is an MCOD or dbo in the DATABASE-SCHEMA..

but I attempted by the to ways and is still appearing that error # 170 : - (

Thank you very much for your help, it's very kind of you

clas_hortien
Employee
Employee
0 Kudos

Hi,

the select is still wrong:

select pilot

from flights

into :c_pilot.

It has to be

select pilot

into :c_pilot

from flights.

Regards

Clas Hortien

Former Member
0 Kudos

Hi Clas

I have changed it some times but, the error is still there... : -(

This is my code now:

DATA: c_pilot TYPE FLIGHTS-pilot.

DATA: con_name LIKE dbcon-con_name VALUE 'CON_ARA'.

EXEC SQL.

SET CONNECTION :con_name

ENDEXEC.

IF sy-subrc <> 0.

  • Connection not yet opened.

EXEC SQL.

CONNECT TO :con_name

ENDEXEC.

endif.

  • Do something on connection 'con_name'

EXEC SQL.

select pilot

into :c_pilot

from flights.

ENDEXEC.

*Commit the changes on 'con_name'

EXEC SQL.

COMMIT

ENDEXEC.

EXEC SQL.

SET CONNECTION :con_name

ENDEXEC.

EXEC SQL.

DISCONNECT :con_name

ENDEXEC.

ENDFORM.