Thanks Daniel. It did fix the old bug. But I got a couple of new bugs which I guess it might relate to UNICODE supported from Python to Sapdb.

For example I created a table with ASCII VARCHAR and UNICODE VARCHAR columns. I can get the data properly by 'SELECT ... FROM ...'. Anyway if I create a dbproc to get the data with a cursor it will return a 'Space for converted value too small' which I guess it came from failure in converting UNICODE to ASCII. Also the code crashed after running in the same python IDLE shell for four times.

Here is the error message from pythonw.exe:

The instruction at "0x77fcb5bf" referenced memory at "0x00000000". The memory could not be "written".

\the instruction at"0x1027722b" referenced memory at "0x00000107". The memory could not be "read".

I attached the sample code to produce the error.

Thanks,

Christine Ke

#****************************************************************
#
# sapdbBug.py - to create a simple case to report sapdb bug
#
# Written by Christine Ke
#
#****************************************************************

import sys
import sapdb                                    # to access sapdb SQL
import sapdb.loader                             # to access the Loader

#
# Initial db connection
#
user = 'TEST'
pwd = 'TEST'
dbname = 'SDC'
host = ''


#---------------------------------------------------------------- # # CreateTable - create a table # # Input: sTableName - name of table # sScript - the script to create the table # #----------------------------------------------------------------

def createTable(sTableName, sScript):

   #
   # drop table if exists
   #
   try:
       session.cmd('DROP TABLE %s' %sTableName)
   except sapdb.loader.LoaderError, err:
       pass                                    # Table not exists

   #
   # create the table
   #
   try:
       session.cmd(sScript)
       print 'TABLE', sTableName, 'CREATED!'
   except sapdb.loader.LoaderError, err:
       print 'TABLE', sTableName, 'FAIL!\n', err

#----------------------------------------------------------------
#
# CreateDbProc  - create a dbproc
#
# Input:    sDbProcName   - name of dbproc
#           sScript      - the script to create the dbproc
#
#----------------------------------------------------------------

def createDbProc(sDbProcName, sScript):

   #
   # drop dbproc if exists
   #
   try:
       session.cmd('DROP DBPROC %s' %sDbProcName)
   except sapdb.loader.LoaderError, err:
       pass                                    # Table not exists

   #
   # create the table
   #
   try:
       session.cmd(sScript)
       print 'DBPROC', sDbProcName, 'CREATED!'
   except sapdb.loader.LoaderError, err:
       print 'DBPROC', sDbProcName, 'FAIL!\n', err

#----------------------------------------------------------------
#
# testDbProc  - test the existed dbproc
#
# Input:    sScript - the script to test the dbproc
#
#----------------------------------------------------------------

def testDbProc(sScript):

   #
   # execute the script
   #
   try:
       rows = session.sqlX(sScript)

print sScript

       #
       # print out rows
       #
       for row in rows:
           print row

   except sapdb.SQLError, err:
       print err.message   # error message from db

#
# Initial tables name and scripts
#
tplTables = (
   'tblTest',
   )

#
# tableName : script
#
dctTables = {
   'tblTest' : """
       CREATE TABLE tblTest(
           tblTestID FIXED(12, 0) PRIMARY KEY,
           description VARCHAR(100) NOT NULL,
           unicodeDesc VARCHAR(100) UNICODE NOT NULL)"""
   }
#
# Initial DbProcs name and scripts - DbProc created sequence sensitive
#
tplDbProcs = (
   'dataLoad',
   )

#
# dbprocname : script
#
dctDbProcs = {
   "dataLoad" : """
       CREATE DBPROC dataLoad (
                          IN pnRange Fixed(12, 0))
       RETURNS CURSOR AS

           DECLARE :$CURSOR CURSOR FOR
                SELECT t.tblTestID, t.description, t.unicodeDesc
                FROM test.tblTest t
                WHERE t.tblTestID > :pnRange
                ORDER BY t.tblTestID;
   """}

#
#
#
tplTestData = (
   """INSERT INTO tblTest(tblTestID, Description, unicodeDesc)
       VALUES(1, 'Hello world', 'Hello world')""",
   """INSERT INTO tblTest(tblTestID, Description, unicodeDesc)
       VALUES(2, 'Goodbye world', 'Goodbye world')""",
   """INSERT INTO tblTest(tblTestID, Description, unicodeDesc)
       VALUES(3, 'Sorry', 'Sorry')"""
   )

#
# Test DbProc
#
tplTestDbProcs = (
   "CALL dataLoad(0)",
   )

session = sapdb.loader.Loader (host, dbname)    # connect to db
session.cmd ('use user %s %s' % (user, pwd))    # connect

print 'CONNECTED'

#
# create tables
#
print "=" * 20, "CREATE TABLES", "=" * 20

for tbl in tplTables: # create tables in the sequence defined in tplTables
print dctTables[tbl]
createTable(tbl, dctTables[tbl]) # create table


#
# create dbProcs
#
print "=" * 20, "CREATE DBPROCS", "=" * 20

for dbProc in tplDbProcs: # create dbprocs in the sequence defined in tplDbProcs
print dctDbProcs[dbProc]
createDbProc(dbProc, dctDbProcs[dbProc]) # create dbProc


#
# add test data
#
print "=" * 20, "TEST DATA", "=" * 20

for td in tplTestData:
   try:
       session.cmd(td)                             # add test data
       print td, "...DONE\n"
   except sapdb.loader.LoaderError, err:
       print td, "\n", err, "\n"

session.cmd("COMMIT") # commit

del session

session = sapdb.connect (user, pwd, dbname, host)

#
# test UNICODE table
#
print "=" * 20, "TEST UNICODE", "=" * 20
rows = session.sql("""
   SELECT tblTestID, description, unicodeDesc
   FROM tblTest
   WHERE tblTestID > 0""")

for row in rows:
   print row

#
# test dbprocs
#
print "=" * 20, "TEST DBPROC", "=" * 20

for tdp in tplTestDbProcs:
   testDbProc(tdp)

print "=" * 20, "IT'S DONE", "=" * 20

session = None # disconnect







From: "Dittmar, Daniel" <[EMAIL PROTECTED]>
To: "'Christine Ke'" <[EMAIL PROTECTED]>, [EMAIL PROTECTED]
Subject: RE: Sapdb to Python 2.3 - Any progress on it
Date: Mon, 13 Oct 2003 18:49:28 +0200

> I reported this bug one month ago. Any progress in it?

I did have a fix a week later (http://lists.mysql.com/maxdb/18200),
but it probably got lost in the transition of the mailing list.

I noticed since that it broke the version for Python 2.2 instead.
I uploaded a new archive (ftp://ftp.sap.com/pub/sapdb/bin/win/sapdb-python-win32-7.4.03.31a.zip)
which runs your example on all the supported Python versions. And I will work on a setup which allows me to test against the various versions more easily.


Daniel Dittmar

--
Daniel Dittmar
SAP DB, SAP Labs Berlin
[EMAIL PROTECTED]
http://www.sapdb.org/

_________________________________________________________________
Chat via SMS. Simply send 'CHAT' to 1889918. More info at http://ninemsn.com.au/mobilemania/MoChat.asp?blipid=6800



-- MaxDB Discussion Mailing List For list archives: http://lists.mysql.com/maxdb To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]



Reply via email to