changeset 216:c5a49947eedc

going to try multiple pull
author catherine@Elli.myhome.westell.com
date Thu, 29 Jan 2009 12:31:56 -0500
parents 6ffd31222f55
children a65b98938596
files sqlpython/sqlpyPlus.py
diffstat 1 files changed, 27 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/sqlpython/sqlpyPlus.py	Wed Jan 28 13:38:22 2009 -0500
+++ b/sqlpython/sqlpyPlus.py	Thu Jan 29 12:31:56 2009 -0500
@@ -547,7 +547,7 @@
         object_type, owner, object_name = self.resolve(target)
         if not object_type:
             return
-        self.stdout.write("%s %s.%s\n" % (object_type, owner, object_name))
+        #self.stdout.write("%s %s.%s\n" % (object_type, owner, object_name))
         self.stdout.write(str(self.curs.callfunc('DBMS_METADATA.GET_DDL', cx_Oracle.CLOB,
                                                  [object_type, object_name, owner])))
         if opts.full:
@@ -868,11 +868,8 @@
 
     def do_declare(self, arg):
         self.anon_plsql('declare ' + arg)
-
-    @options([make_option('-l', '--long', action='store_true', help='long descriptions'),
-              make_option('-a', '--all', action='store_true', help="all schemas' objects")])        
-    def do_ls(self, arg, opts):
-        where = ''
+        
+    def _ls_statement(self, arg, opts):
         if arg:
             where = """\nWHERE object_type || '/' || object_name
                   LIKE '%%%s%%'""" % (arg.upper().replace('*','%'))
@@ -885,12 +882,31 @@
             whose = 'user'
             objname = 'object_name'            
         if opts.long:
-            extraInfo = ', status, last_ddl_time AS modified'
+            moreColumns = ', status, last_ddl_time AS modified'
+        else:
+            moreColumns = ''
+        return {'objname': objname, 'moreColumns': moreColumns,
+                'whose': whose, 'where': where}        
+        
+    @options([make_option('-a', '--all', action='store_true', help="all schemas' objects")])
+    def resolve_many(self, arg, opts):
+        clauses = self._ls_statement(arg, opts)
+        if opts.all:
+            clauses['owner'] = 'owner'
         else:
-            extraInfo = ''
-        statement = '''SELECT object_type || '/' || %s AS name %s 
-                  FROM   %s_objects %s
-                  ORDER BY object_type, object_name;''' % (objname, extraInfo, whose, where)
+            clauses['owner'] = 'user'
+        statement = '''SELECT %(owner)s, object_type, object_name 
+                  FROM   %(whose)s_objects %(where)s
+                  ORDER BY object_type, object_name;''' % clauses
+        self.curs.execute(statement)
+        return self.curs.fetchall()
+    
+    @options([make_option('-l', '--long', action='store_true', help='long descriptions'),
+              make_option('-a', '--all', action='store_true', help="all schemas' objects")])        
+    def do_ls(self, arg, opts):
+        statement = '''SELECT object_type || '/' || %(objname)s AS name %(moreColumns)s 
+                  FROM   %(whose)s_objects %(where)s
+                  ORDER BY object_type, object_name;''' % self._ls_statement(arg, opts)
         self.do_select(self.parsed(statement, terminator=arg.parsed.terminator or ';', suffix=arg.parsed.suffix))
         
     @options([make_option('-i', '--ignore-case', dest='ignorecase', action='store_true', help='Case-insensitive search')])