#!/usr/bin/python
from lnx import *
#Das ist ein Kommentar
s=lnx()
if s.SQLConnect("/home/lnx/odbc.ini","demo","lnx","lnx") == SQL_SUCCESS:
s.SQLPrepare("cursor1","select * from lnxtables")
if s.SQLExecute("cursor1") == SQL_SUCCESS:
rc,count_of_columns=s.SQLNumResultCols("cursor1")
if rc == SQL_SUCCESS and count_of_columns > 0:
print "*** Describe Dynamic Cursor ***"
i=0
while i < count_of_columns:
rc,colname,sqltype,collength,scale,nullable=s.SQLDescribeCol("cursor1",i)
if rc <> SQL_SUCCESS: break
if(nullable == SQL_NULLABLE): null_string=""
if(nullable <> SQL_NULLABLE): null_string="NOT NULL"
if sqltype == SQL_INTEGER: print colname,"INTEGER",null_string
if sqltype == SQL_DATE: print colname,"DATE",null_string
if sqltype == SQL_DOUBLE: print colname,"FLOAT",null_string
if sqltype == SQL_CHAR: print colname,"CHAR(",collength,")",null_string
i=i+1
# end of while
number_of_rows=0
while s.SQLFetch("cursor1") == SQL_SUCCESS:
number_of_rows=number_of_rows+1
if number_of_rows == 5:
s.SQLCancel("cursor1")
break;
print "*** Satz: ",number_of_rows," ***"
i=0
while i < count_of_columns:
rc,value,nullwert=s.SQLGetData("cursor1",i)
if rc == SQL_SUCCESS:
if nullwert == SQL_NULL_DATA:
print "NULL"
else:
print value
i=i+1
# end of while
# end of query
if count_of_columns == 0:
print "DML Statement"
rc,rowcount=s.SQLRowCount("cursor1")
if rc == SQL_SUCCESS: print "Row's: ",rowcount
s.SQLClose("cursor1")
if s.SQLTables("stmttables") == SQL_SUCCESS:
rc,count_of_columns=s.SQLNumResultCols("stmttables")
if rc == SQL_SUCCESS and count_of_columns > 0:
print "*** Describe SQLTables Cursor ***"
i=0
while i < count_of_columns:
rc,colname,sqltype,collength,scale,nullable=s.SQLDescribeCol("stmttables",i)
if rc <> SQL_SUCCESS: break
if(nullable == SQL_NULLABLE): null_string=""
if(nullable <> SQL_NULLABLE): null_string="NOT NULL"
if sqltype == SQL_INTEGER: print colname,"INTEGER",null_string
if sqltype == SQL_DATE: print colname,"DATE",null_string
if sqltype == SQL_DOUBLE: print colname,"FLOAT",null_string
if sqltype == SQL_CHAR: print colname,"CHAR(",collength,")",null_string
i=i+1
# end of while
while s.SQLFetch("stmttables") == SQL_SUCCESS:
print "*** Satz ***"
i=0
while i < count_of_columns:
rc,value,nullwert=s.SQLGetData("stmttables",i)
if rc == SQL_SUCCESS:
if nullwert == SQL_NULL_DATA:
print "NULL"
else:
print value
i=i+1
# end of while
s.SQLClose("stmttables")
s.SQLPrepare("cursor1","select * from lnxtables")
if s.SQLExecute("cursor1") == SQL_SUCCESS:
rc,count_of_columns=s.SQLNumResultCols("cursor1")
if rc == SQL_SUCCESS and count_of_columns > 0:
print "*** Describe Dynamic Cursor ***"
i=0
while i < count_of_columns:
rc,colname,sqltype,collength,scale,nullable=s.SQLDescribeCol("cursor1",i)
if rc <> SQL_SUCCESS: break
if(nullable == SQL_NULLABLE): null_string=""
if(nullable <> SQL_NULLABLE): null_string="NOT NULL"
if sqltype == SQL_INTEGER: print colname,"INTEGER",null_string
if sqltype == SQL_DATE: print colname,"DATE",null_string
if sqltype == SQL_DOUBLE: print colname,"FLOAT",null_string
if sqltype == SQL_CHAR: print colname,"CHAR(",collength,")",null_string
i=i+1
# end of while
while s.SQLFetch("cursor1") == SQL_SUCCESS:
print "*** Satz ***"
i=0
while i < count_of_columns:
rc,value,nullwert=s.SQLGetData("cursor1",i)
if rc == SQL_SUCCESS:
if nullwert == SQL_NULL_DATA:
print "NULL"
else:
print value
i=i+1
# end of while
# end of query
if count_of_columns == 0:
print "DML Statement"
rc,rowcount=s.SQLRowCount("cursor1")
if rc == SQL_SUCCESS: print "Row's: ",rowcount
s.SQLClose("cursor1")
s.SQLPrepare("cursor1","select * from lnxcolumns")
if s.SQLExecute("cursor1") == SQL_SUCCESS:
rc,count_of_columns=s.SQLNumResultCols("cursor1")
if rc == SQL_SUCCESS and count_of_columns > 0:
print "*** Describe Dynamic Cursor ***"
i=0
while i < count_of_columns:
rc,colname,sqltype,collength,scale,nullable=s.SQLDescribeCol("cursor1",i)
if rc <> SQL_SUCCESS: break
if(nullable == SQL_NULLABLE): null_string=""
if(nullable <> SQL_NULLABLE): null_string="NOT NULL"
if sqltype == SQL_INTEGER: print colname,"INTEGER",null_string
if sqltype == SQL_DATE: print colname,"DATE",null_string
if sqltype == SQL_DOUBLE: print colname,"FLOAT",null_string
if sqltype == SQL_CHAR: print colname,"CHAR(",collength,")",null_string
i=i+1
# end of while
while s.SQLFetch("cursor1") == SQL_SUCCESS:
print "*** Satz ***"
i=0
while i < count_of_columns:
rc,value,nullwert=s.SQLGetData("cursor1",i)
if rc == SQL_SUCCESS:
if nullwert == SQL_NULL_DATA:
print "NULL"
else:
print value
i=i+1
# end of while
# end of query
if count_of_columns == 0:
print "DML Statement"
rc,rowcount=s.SQLRowCount("cursor1")
if rc == SQL_SUCCESS: print "Row's: ",rowcount
s.SQLClose("cursor1")
if s.SQLColumns("stmtcolumns","lnxtables") == SQL_SUCCESS:
rc,count_of_columns=s.SQLNumResultCols("stmtcolumns")
if rc == SQL_SUCCESS and count_of_columns > 0:
print "*** SQLColumns Cursor ***"
while s.SQLFetch("stmtcolumns") == SQL_SUCCESS:
print "*** Satz ***"
i=0
while i < count_of_columns:
rc,value,nullwert=s.SQLGetData("stmtcolumns",i)
if rc == SQL_SUCCESS:
if nullwert == SQL_NULL_DATA:
print "NULL"
else:
print value
i=i+1
# end of while
s.SQLClose("stmtcolumns")
if s.SQLStatistics("stmtstatistics","lnxcolumns") == SQL_SUCCESS:
rc,count_of_columns=s.SQLNumResultCols("stmtstatistics")
if rc == SQL_SUCCESS and count_of_columns > 0:
print "*** SQLStatistics Cursor ***"
while s.SQLFetch("stmtstatistics") == SQL_SUCCESS:
print "*** Satz ***"
i=0
while i < count_of_columns:
rc,value,nullwert=s.SQLGetData("stmtstatistics",i)
if rc == SQL_SUCCESS:
if nullwert == SQL_NULL_DATA:
print "NULL"
else:
print value
i=i+1
# end of while
s.SQLClose("stmtstatistics")
if s.SQLExecDirect("stmtdirect","select * from lnxindexes") == SQL_SUCCESS:
rc,count_of_columns=s.SQLNumResultCols("stmtdirect")
if rc == SQL_SUCCESS and count_of_columns > 0:
print "*** Describe SQLExecDirect Cursor ***"
i=0
while i < count_of_columns:
rc,colname,sqltype,collength,scale,nullable=s.SQLDescribeCol("stmtdirect",i)
if rc <> SQL_SUCCESS: break
if(nullable == SQL_NULLABLE): null_string=""
if(nullable <> SQL_NULLABLE): null_string="NOT NULL"
if sqltype == SQL_INTEGER: print colname,"INTEGER",null_string
if sqltype == SQL_DATE: print colname,"DATE",null_string
if sqltype == SQL_DOUBLE: print colname,"FLOAT",null_string
if sqltype == SQL_CHAR: print colname,"CHAR(",collength,")",null_string
i=i+1
# end of while
while s.SQLFetch("stmtdirect") == SQL_SUCCESS:
print "*** Satz ***"
i=0
while i < count_of_columns:
rc,value,nullwert=s.SQLGetData("stmtdirect",i)
if rc == SQL_SUCCESS:
if nullwert == SQL_NULL_DATA:
print "NULL"
else:
print value
i=i+1
# end of while
s.SQLClose("stmtdirect")
if s.SQLSpecialColumns("stmtspecialcolumns","lnxcolumns") == SQL_SUCCESS:
rc,count_of_columns=s.SQLNumResultCols("stmtspecialcolumns")
if rc == SQL_SUCCESS and count_of_columns > 0:
print "*** SQLSpecialColumns Cursor ***"
while s.SQLFetch("stmtspecialcolumns") == SQL_SUCCESS:
print "*** Satz ***"
i=0
while i < count_of_columns:
rc,value,nullwert=s.SQLGetData("stmtspecialcolumns",i)
if rc == SQL_SUCCESS:
if nullwert == SQL_NULL_DATA:
print "NULL"
else:
print value
i=i+1
# end of while
s.SQLClose("stmtspecialcolumns")
s.SQLTransact(SQL_COMMIT);
s.SQLDisconnect()
               (
geocities.com/tokyo/towers)                   (
geocities.com/tokyo)