Skip to main content
Solved

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?

  • December 21, 2015
  • 7 replies
  • 41 views

Forum|alt.badge.img
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?

Best answer by takashi

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.

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

7 replies

pratap
Contributor
Forum|alt.badge.img+12
  • Contributor
  • December 21, 2015

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


takashi
Celebrity
  • December 21, 2015

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.


Forum|alt.badge.img
  • Author
  • December 21, 2015

@takashi Here is the actual script

import fmeobjects

 

import cx_Oracle

 

import sys

 

#Getting the database paramters

 

service = FME_MacroValues['DBService']

 

userName = FME_MacroValues['DBUserName']

 

password = FME_MacroValues['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()

takashi
Celebrity
  • Best Answer
  • December 21, 2015

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.


Forum|alt.badge.img
  • Author
  • December 21, 2015

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?


takashi
Celebrity
  • December 21, 2015

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).


Forum|alt.badge.img
  • Author
  • December 21, 2015

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