comparison sqlpyPlus.py @ 78:8529876f7541

ls working
author catherine@cordelia
date Sun, 27 Apr 2008 08:40:28 -0400
parents 4b5d4e5798dd
children 01d578f4e6e7
comparison
equal deleted inserted replaced
77:4b5d4e5798dd 78:8529876f7541
805 self.anon_plsql('begin ' + arg) 805 self.anon_plsql('begin ' + arg)
806 806
807 def do_declare(self, arg): 807 def do_declare(self, arg):
808 self.anon_plsql('declare ' + arg) 808 self.anon_plsql('declare ' + arg)
809 809
810 def do_create(self, arg):
811 self.anon_plsql('create ' + arg)
812
813 lsflags = flagReader.FlagSet([flagReader.Flag('long')])
814 def do_ls(self, arg):
815 options, arg = self.lsflags.parse(arg)
816 where = ''
817 if arg:
818 where = """\nWHERE object_type || '/' || object_name
819 LIKE '%%%s%%'""" % (arg.upper().replace('*','%'))
820 else:
821 where = ''
822 result = []
823 statement = '''SELECT object_type, object_name,
824 status, last_ddl_time
825 FROM user_objects %s
826 ORDER BY object_type, object_name''' % (where)
827 self.curs.execute(statement)
828 for (object_type, object_name, status, last_ddl_time) in self.curs.fetchall():
829 if options.has_key('long'):
830 result.append('%s\t%s\t%s/%s' % (status, last_ddl_time, object_type, object_name))
831 else:
832 result.append('%s/%s' % (object_type, object_name))
833 self.stdout.write('\n'.join(result) + '\n')
834
835
836 if options.has_key('insensitive'):
837 searchfor = "LOWER(text)"
838 arg = arg.lower()
839
840
810 def do_cat(self, arg): 841 def do_cat(self, arg):
811 targets = arg.split() 842 targets = arg.split()
812 for target in targets: 843 for target in targets:
813 self.do_select('* from %s' % target) 844 self.do_select('* from %s' % target)
814 845