Skip to main content
In the FME ,we have included python startup script. When we run it in FME 2014 version, it showing an error like : name 'dbCursor' is not defined.Could you please temme what would be the reason?

Hi,

I don't know python but when I tried for first-time even I too received the error.

In Python, position of starting of line and ending of line is most important. So re-write the script in editor in the position where it starts and end.

Hope this helps :)

Pratap


The error occurs if a variable called "dbCursor" is not defined before using it in the script. Cannot think of other things unless seeing the actual script.


@takashi Here is the actual script

import fmeobjects

 

import cx_Oracle

 

import sys

 

#Getting the database paramters

 

service = FME_MacroValuesl'DBService']

 

userName = FME_MacroValuesa'DBUserName']

 

password = FME_MacroValuesV'DBPassword']

 

updateImportIDProc= 'NBN_DATA_OWNER.UPDATE_NBN_DATA_LOG'

 

getImportIDProc = 'NBN_DATA_OWNER.GET_NBN_IMPORT_ID'

 

#Getting the current process Id

 

importID =-1

 

#Creating connecting strings

 

connectionString = userName + '/' + password + '@' + service

 

try:

 

dbConnection = cx_Oracle.connect(connectionString)

 

dbCursor = dbConnection.cursor()

 

dbCursor.callproc(updateImportIDProc,('UPLOADING','NBN_FPRNT'))

 

#checking the run status of 01_CleanUp_Input.fmw workspace

 

id = dbCursor.var(cx_Oracle.NUMBER)

 

dbCursor.callproc(getImportIDProc,('NBN_FPRNT',id))

 

#raise Exception("Translation failed, 01_CleanUp_Input.fmw is not yet finished")

 

importID = id.getvalue()

 

if importID==-1:

 

raise Exception(message)

 

if dbCursor is not None:

 

dbCursor.close()

 

dbCursor=None

 

if dbConnection is not None:

 

dbConnection.commit()

 

dbConnection.close()

 

dbConnection=None

 

except Exception, e:

 

print str(e)

 

importID = -1;

 

if dbCursor is not None:

 

dbCursor.close()

 

dbCursor=None

 

if dbConnection is not None:

 

dbConnection.commit()

 

dbConnection.close()

 

dbConnection=None

 

sys.exit()

The variable "dbCursor" is defined inside of the "try" block, so it cannot be accessed from the "except" block. Try inserting these lines before the try block.

dbCursor = None
dbConnection = None

Indentations are important in Python scripts. Please use the CODE block when posting a script in the next time.


Thnq @takashi ...it got resolved. And now iam getting an error saying like

 

Unable to configure the XML module to read the XML dataset. No <xrs:switch> item in the xrs document 'D:\\apps\\FME\\xml\\xrs\\xrs.xml' matched the XML dataset 'D:\\IDW\\Data\\XML\\Historical Footprint List C.xml'

The XML format could not be determined by examination. Try entering a feature path into the "Elements to Match" parameter, specifying an xfMap, selecting an XRS, or using a more specific reader

The XML Module halted on error, see the logfile for details

Could you please help me in dis?


Thnq @takashi ...it got resolved. And now iam getting an error saying like

 

Unable to configure the XML module to read the XML dataset. No <xrs:switch> item in the xrs document 'D:\\apps\\FME\\xml\\xrs\\xrs.xml' matched the XML dataset 'D:\\IDW\\Data\\XML\\Historical Footprint List C.xml'

The XML format could not be determined by examination. Try entering a feature path into the "Elements to Match" parameter, specifying an xfMap, selecting an XRS, or using a more specific reader

The XML Module halted on error, see the logfile for details

Could you please help me in dis?

Looks like the error is from an XML reader in your workspace. Isn't it?

If so, please post it as a new question (with more detailed explanation about the reader setting so that we can understand the situation).


Looks like the error is from an XML reader in your workspace. Isn't it?

If so, please post it as a new question (with more detailed explanation about the reader setting so that we can understand the situation).

yeah @takashi sorry...now everything is fine thnqqq


Reply