Hi all,
In the process of learning about SQL and SAPDB, I downloaded and ran
egSQL.py. In the two cases when session.sql is called with SELECT INTO, the
results where not what was expected. The comments in egSQL.py and the
documentation for the Python interface, state that a tuple should be
returned. What was returned was a character string. I ran the program with
Python versions 1.52 and 2.1. I used sapdbmodule versions 7.3.0.18 and
7.3.0.21a. The results where always the same.
A portion of the output from egSQL.py follows (I have included the result of
the call to sqlX because it returns the expected tuple):
Getting single value 'select first msgtext into ? from messages'
result: ' PRECOM ENGMSG 7.3.0.00 1998-02-27
', <type 'string'>
Getting multiple values 'select first msgno, msgtext into ?, ? from
messages'
result: ' ; PRECOM ENGMSG 7.3.0.00 1998-02-27
', <type 'string'>
parse/execute in one call 'select first msgno, msgtext into ?, ? from
messages where
sgno between ? and ?'
result: (200, 'Duplicate key')
This being the wonderful world of open source, I downloaded the source of
version 7.3.0.18 (I could not find the sources for sapdbmodule 7.3.0.21a).
With much praise and thanks to Joseph M. Hinkle for the information at
http://sapdb.automatix.de/build-notice.html, I was able to generate the
development environment and do some debugging.
The problem shows up in the function packet2result in the module vin77.c.
In the tests that I ran, the client returned the correct information;
however, packet2result treated the buffer as if it contained a length and a
unterminated character string. It calls SL_fromString to generate the
results. Depending on what is in the buffer, this produces some interesting
results.
There are several "work arounds" for this problem. One appears to be to
always use sqlX instead of sql to process SELECT INTO statement. Because
the parameter list argument is optional, it appears that sqlX can always be
used in place of sql. I ran a few tests and in almost all cases, sqlX
returned the expected results.
The one odd case is the Python snippet that follows:
cmmd = 'select first msgno, msgtext from messages where msgno between 200
and 700'
result = session.sql (cmmd)
result = session.sqlX (cmmd)
sql returned a character string while sqlX returned the following error
message:
'sapdb.SQLError: [-5015] (at 29) Missing
keyword:YEARS,WRITE,WORK,WHILE,WHENEVER,
WAIT,VTRACE,VSIZE,VIEW'
Being a newbie, I am not sure if this is a valid SQL command; however, I
believe that one or both of the results must be wrong.
I am sorry that I don't have any real solutions for you.
Al Perga
_______________________________________________
sapdb.general mailing list
[EMAIL PROTECTED]
http://listserv.sap.com/mailman/listinfo/sapdb.general