changeset 265:041c656dc8e5

show err working nicely now
author catherine@Elli.myhome.westell.com
date Mon, 16 Mar 2009 22:20:53 -0400
parents a8deaa38f11e
children 342e96de6de6
files sqlpython/sqlpyPlus.py sqlpython/sqlpython.py
diffstat 2 files changed, 13 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/sqlpython/sqlpyPlus.py	Mon Mar 16 22:03:41 2009 -0400
+++ b/sqlpython/sqlpyPlus.py	Mon Mar 16 22:20:53 2009 -0400
@@ -721,8 +721,8 @@
         show                  - display value of all sqlpython parameters
         show (parameter name) - display value of a sqlpython parameter
         show parameter (parameter name) - display value of an ORACLE parameter
-        show err              - errors from the most recent PL/SQL object compilation.
-        show all err          - all compilation errors from the user's PL/SQL objects.
+        show err (object type/name)     - errors from latest PL/SQL object compilation.
+        show all err (type/name)        - all compilation errors from the user's PL/SQL objects.
         '''
         if arg.startswith('param'):
             try:
@@ -741,9 +741,9 @@
             argpieces = arg.lower().split()
             try:
                 if argpieces[0][:3] == 'err':
-                    return self._show_errors(all_users=False, limit=1)
+                    return self._show_errors(all_users=False, limit=1, targets=argpieces[1:])
                 elif (argpieces[0], argpieces[1][:3]) == ('all','err'):
-                    return self._show_errors(all_users=False, limit=None)
+                    return self._show_errors(all_users=False, limit=None, targets=argpieces[2:])
             except IndexError:
                 pass
             return Cmd.do_show(self, arg)
--- a/sqlpython/sqlpython.py	Mon Mar 16 22:03:41 2009 -0400
+++ b/sqlpython/sqlpython.py	Mon Mar 16 22:20:53 2009 -0400
@@ -166,11 +166,16 @@
     def emptyline(self):
         pass
 
-    def _show_errors(self, all_users=False, limit=None, mintime=None):
+    def _show_errors(self, all_users=False, limit=None, mintime=None, targets=[]):
         if all_users:
             user = ''
         else:
-            user = "WHERE ao.owner = user\n"
+            user = "AND ao.owner = user\n"
+        if targets:
+            target = 'AND (%s)\n' % ' OR '.join("ae.type || '/' || ae.name LIKE '%s'" % 
+                                              t.upper().replace('*','%') for t in targets)
+        else:
+            target = ''
         self.curs.execute('''
             SELECT ae.owner, ae.name, ae.type, ae.position, ae.line, ae.attribute, 
                    ae.text error_text,
@@ -184,7 +189,8 @@
                                       AND ae.name = src.name
                                       AND ae.type = src.type
                                       AND ae.line = src.line)
-            %sORDER BY ao.last_ddl_time DESC''' % user)
+            WHERE 1=1
+            %s%sORDER BY ao.last_ddl_time DESC''' % (user, target))
         if limit is None:
             errors = self.curs.fetchall()
         else: