Hi SAPDB People,

I'm having trouble creating dbprocs from python2.2/XP, doing so crashes
python, causes SQLStudio to hang, and forces me to shutdown and restart
the database. No problems dropping or calling the dbproc if it is created directly in SQLStudio.


Here's the code:

<code>

import sapdb.sql


def drop_table(session): try: session.sql("drop table tstable") except: pass

def drop_proc(session):
   try:
       session.sql("drop dbproc example")
   except:
       pass

def create_table(session):
   session.sql('''create table tstable
       (   id      INTEGER NOT NULL,
           name    VARCHAR(255),
           address VARCHAR(255),
           tstdate DATE
       )''')

   session.sql('''insert into tstable values
       (1, 'Mr. Big', '100 West St.', NULL)''')

   session.sql('''insert into tstable values
       (2, 'Mr. Small', '50 East St.', NULL)''')


def create_proc(session): session.sql(''' create dbproc example returns cursor as declare :$cursor cursor for select * from test.tstable; ''')


def call_proc(session): resultset = session.sql ("call example")

   # use resultset as an iterator
   print 'rows:'
   for row in resultset:
       print row


def createSession (username, password, dbname, host): session = sapdb.sql.connect (username, password, dbname, host) return session

def scenario1(session):
   '''success'''
   drop_table(session)
   create_table(session)
   session.commit()

def scenario2(session):
   '''success'''
   drop_proc(session)
   session.commit()

def scenario3(session):
   '''fail'''
   create_proc(session)
   session.commit()

def scenario4(session):
   '''success'''
   call_proc(session)
   session.commit()

def main ():
   session = createSession(
       username='TEST',
       password='TEST',
       dbname='TST',
       host='')

   scenario1(session)
   #scenario2(session)
   #scenario3(session)
   scenario4(session)





if __name__ == "__main__": main ()


</code>



regards,



Sandy







_________________________________________________________________
MSN 8 with e-mail virus protection service: 2 months FREE* http://join.msn.com/?page=features/virus


_______________________________________________
sapdb.general mailing list
[EMAIL PROTECTED]
http://listserv.sap.com/mailman/listinfo/sapdb.general

Reply via email to