Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!newsfeed.eweka.nl!eweka.nl!feeder3.eweka.nl!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!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.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; '21,': 0.07; 'subject:help': 0.07; 'python': 0.09; 'argument,': 0.09; 'cursor': 0.09; 'name)': 0.09; 'nameerror:': 0.09; 'sep': 0.09; 'def': 0.10; 'subject:error': 0.11; 'subject:not': 0.11; 'class)': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'function;': 0.16; 'wrote:': 0.17; 'instance': 0.17; 'thu,': 0.17; 'skip:" 30': 0.20; 'received:209.85.214.174': 0.21; 'skip:c 70': 0.22; 'defined': 0.22; 'idea': 0.24; "we'd": 0.24; 'pass': 0.25; 'header:In-Reply-To:1': 0.25; 'looks': 0.26; 'appreciated': 0.27; 'subject:please': 0.27; 'message-id:@mail.gmail.com': 0.27; '(since': 0.29; 'skip:/ 40': 0.29; "i'm": 0.29; "skip:' 10": 0.30; 'function': 0.30; 'error': 0.30; 'code': 0.31; 'file': 0.32; 'function.': 0.33; 'traceback': 0.33; 'to:addr:python-list': 0.33; 'skip:d 20': 0.34; 'received:google.com': 0.34; 'pm,': 0.35; 'received:209.85': 0.35; 'but': 0.36; 'received:209': 0.37; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'received:209.85.214': 0.39; 'header:Received:5': 0.40; 'help': 0.40; 'your': 0.60; 'further': 0.61; 'subject:Need': 0.61; 'different': 0.63; 'more': 0.63; 'other.': 0.64; 'results': 0.65; 'member,': 0.66; 'subject::': 0.83; 'subject:this': 0.84; 'skip:/ 30': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=3ybLEz8VPvpj4lYHW0j7CZb24yLy+dkdLsnMcpxRVz8=; b=ZNm2l6eQeVpx5pnz9Le87IL4/jMKQegWJxgYlLNmq05Mw4YxMeo0zSdm0hApU8YbUb vdHKoluNLpla3h9uWWqfvcHDVFSnF1HfJt3mcA8XKkJAE27WkoM17zbHVMHX1tSH1KE7 fu++H9UCThMrLvSX9GoBMjfxBWED7LY1p61pzPf/Z7qaaFPugtpT+l+ULDyz6VGvGLas 7Z/bdJVPDv8gb4bNrrI1GrQsfNgTfWGczqZ/ZtitWIIERE5yD2EJrmb22588a0H7q/Tr Ie0NoNBec8jpdA2Mc25KjXRiXtcOJUL3Fp1I8qjEI7aEC9fxzDjOXPhymC/WkUw/ciaw ZQpA== MIME-Version: 1.0 In-Reply-To: <149e9472-ec31-4b74-9f20-d4945a9fb678@googlegroups.com> References: <149e9472-ec31-4b74-9f20-d4945a9fb678@googlegroups.com> Date: Thu, 6 Sep 2012 21:05:29 +1000 Subject: Re: Need help fixing this error please:NameError: global name is not defined From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 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: 32 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1346929532 news.xs4all.nl 6914 [2001:888:2000:d::a6]:37198 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:28573 On Thu, Sep 6, 2012 at 8:45 PM, shaun wrote: > ////CODE/////////////////////////////// > > 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() > ////////////////////////////////////////// > > 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 > > ////////////////////////////////////////////// > Not quite, actually. The traceback names a different function. Look in your code for a 'fetchbatchdata' function; it looks like you need to pass the cursor from one function to the other. To further assist, we'd need to see more of the code; but for a guess, I would say that you either need to make cur a function argument, or else (since this is class) an instance member, which you'd reference as 'self.cur'. ChrisA