Skip to main content
1-Visitor
October 24, 2013
Question

Anyone using ODBC_EXECUTE

  • October 24, 2013
  • 7 replies
  • 2895 views

I am trying to build my input string forODBC_EXECUTE to execute and keep getting an error. when I hard code the string it enters fine into my sql database.

 

This is how I am building my string:

 

INPUT_STRING = "INSERT INTO number4 VALUES ('005', " + itos(NEW_NUMBER) +", 'XX', " + MKUPPER(DESCRIPTION) + ", " + MKUPPER(USERNAME) + ", " + DATE + ", " + PROJ_NO + ")"

 

When I print the input_string variable it looks just like the hard coded one except my new number has increased by 1. Any help would be great.


This thread is inactive and closed by the PTC Community Management Team. If you would like to provide a reply and re-open this thread, please notify the moderator and reference the thread. You may also use "Start a topic" button to ask a new question. Please be sure to include what version of the PTC product you are using so another community member knowledgeable about your version may be able to assist.

7 replies

1-Visitor
October 24, 2013

Here is the template I use for insert statements:



WayneBeck1-VisitorAuthor
1-Visitor
October 24, 2013
Yes when I hard code it, it works fine. The problem I am running into is wanting to build the input string and enter that into the sql table.

Wayne Beck
CAD/Windchill Analyst
-<">mailto:->
1-Visitor
October 24, 2013

So if you print out your text string from SA and paste that into a query, it works?

WayneBeck1-VisitorAuthor
1-Visitor
October 24, 2013
yes

Wayne Beck
CAD/Windchill Analyst
-<">mailto:->
1-Visitor
October 24, 2013

What kind of database are you working with?

WayneBeck1-VisitorAuthor
1-Visitor
October 24, 2013
Ms sql through the ODBC connection

Wayne Beck
CAD/Windchill Analyst
-<">mailto:->
1-Visitor
October 25, 2013

You can use variables to pass the VALUES into the statement as shown below:



DB table name = number4


DB table field names = description, username, date



.....



DECLARE_VARIABLE STRING string1 "TEST7"


DECLARE_VARIABLE STRING string2 "WBECK"


DECLARE_VARIABLE STRING string3 "10/25/2013"
DECLARE_VARIABLE STRING INSERT_QUERY



INSERT_QUERY = "INSERT INTO number4 (description, username, date) VALUES ("+string1+", "+string2 +", "+string3 +")"PRINT "%" UPDATE_QUERYODBC_EXECUTE UPDATE_QUERY