Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; '21,': 0.07; 'subject:help': 0.07; 'python': 0.09; 'method:': 0.09; 'name)': 0.09; 'nameerror:': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'def': 0.10; 'subject:error': 0.11; 'subject:not': 0.11; 'guess.': 0.16; 'received:80.91.229.3': 0.16; 'received:dip.t-dialin.net': 0.16; 'received:plane.gmane.org': 0.16; 'received:t-dialin.net': 0.16; 'tabs': 0.16; 'wrote:': 0.17; 'code.': 0.20; 'skip:" 30': 0.20; 'defined': 0.22; 'idea': 0.24; 'script': 0.24; 'header:User-Agent:1': 0.26; 'appreciated': 0.27; 'subject:please': 0.27; 'header:X-Complaints-To:1': 0.28; 'actual': 0.28; 'run': 0.28; "skip:' 50": 0.29; 'class': 0.29; "i'm": 0.29; 'error': 0.30; 'code': 0.31; 'file': 0.32; 'to:addr :python-list': 0.33; 'skip:d 20': 0.34; 'received:org': 0.36; 'but': 0.36; 'subject:: ': 0.38; 'object': 0.38; 'nothing': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'help': 0.40; 'your': 0.60; 'real': 0.61; 'subject:Need': 0.61; 'different': 0.63; 'results': 0.65; 'subject::': 0.83; 'subject:this': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Peter Otten <__peter__@web.de> Subject: Re: Need help fixing this error please:NameError: global name is not defined Date: Thu, 06 Sep 2012 13:07:28 +0200 Organization: None References: <149e9472-ec31-4b74-9f20-d4945a9fb678@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7Bit X-Gmane-NNTP-Posting-Host: p5084a9c5.dip.t-dialin.net User-Agent: KNode/4.7.3 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 35 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1346929651 news.xs4all.nl 6934 [2001:888:2000:d::a6]:39807 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:28575 shaun wrote: > I have a class which I create an object from in a different script but when its run I get an error at the last part of this method: > def databasebatchcall(self,tid, bid): > con=cx_Oracle.connect( > 'user/user123@odb4.dcc.company/ODB4TEST.COMPANY.COM') > cur = con.cursor() > cur.execute("SELECT * FROM name) > results = cur.fetchall() This is not your real code. The above would give you a SyntaxError in the line > cur.execute("SELECT * FROM name) > From this last line I get the following error which I don't understand I'm very new to python and have no idea about this any help would be appreciated > File "/home/dcroke/mdcFDACStringCall.py", line 21, in fetchbatchdata > results = cur.fetchall() > NameError: global name 'cur' is not defined The offending line may not be indented correctly: def databasebatchcall(...): ... cur = con.cursor() ... results = cur.fetchall() This may be obscured by mixing tabs and spaces. However, without the actual code this is nothing but a guess.