Forum Discussion
OK... first of all.... you copied my sample code from bitbucket... which, by itself, isn't bad... however, that code is in JavaScript/JScript... based upon the extension of the file you sent me, you're writing your code in VBScript. Syntax is ENTIRELY different so, that's why it won't work as written. You'll need to adapt my code for VBScript.
Secondly, since you need this done for Oracle, I can modify my extension to support Oracle connection strings... This will take a bit to do so, probably a few hours, but I don't mind. However, understand that I don't have an Oracle DB server to test this on so I can make what LOOKS to be right but I can't make any guarentees it works until you try it.
Thirdly, the following line is incorrect, even in Javascript:
queryObject = SQLUtilities.NewQueryObject(Update student_course_enrolment Set WITHDRAWN_DATE = '01-AUG-18' where STUDENT_COURSE_ENROLLEMNT_ID IN (Select STUDENT_COURSE_ENROLLEMNT_ID from student_course_enrolment where student_id = XXXXXXX AND WITHDRAWN_DATE IS null ; ))
The reason being is that the query that you send to NewQueryObject needs to be a string. There are no string symbols around your query so it's not going to be able to determine what's the query... it's going to just fail at this point. Again, you'll need to make the necessary changes for VBScript but, in JavaScript, it should look like
queryObject = SQLUtilities.NewQueryObject("Update student_course_enrolment Set WITHDRAWN_DATE = '01-AUG-18' where STUDENT_COURSE_ENROLLEMNT_ID IN (Select STUDENT_COURSE_ENROLLEMNT_ID from student_course_enrolment where student_id = XXXXXXX AND WITHDRAWN_DATE IS null ; "))
So... give me some time to get the extension updated for Oracle...
FYI, one of the pros of script extensions is that ANYONE can edit a script extension, not just the developer. Change the extension from tcx to zip, open it in your favorite compression utility, find the code file, edit, update the zip, change the extension to tcx... and you're golden.
- tristaanogre6 years agoEsteemed Contributor
OK... I've made an update to the SQLUtilities.tcx file. Should be reading as version 4.1 now. Please download and let me know if this works for you.
- tristaanogre6 years agoEsteemed Contributor
OK...
contacteswart wrote:
- Updated the code as per my requirement
The line for SetSQLType... change the parameter from MSDASQL.1 to ORACLE.
contacteswart wrote:- change extention ot .js > Save it & Close it
Not sure this is going to work as you intend it. When you created your project in TestComplete, you selected a script code language. This is the language you should be writing your script code in. So, just changing the extension is not going to get it to work in TestComplete.
Additionally, based upon step 3, you're writing this OUTSIDE of TestComplete. The script extension won't work outside of TestComplete. Everything that I've been instructing in has been assuming that you are writing your script code in the code editor built in to TestComplete. Please review https://support.smartbear.com/testcomplete/docs/scripting/overview.html
So... double clicking on the JS file isn't going to execute anything. This is something that needs to be created in TestComplete and then use, in your keyword test, the "Call Script Routine" operation to execute the two different functions...and, again, you need to make sure the code is written in the appropriate code language that you selected when you created your project.
- contacteswart6 years agoOccasional Contributor
Hello
Appreciate your patience. Thanks for detailed extension.
I dont have any restrictions if it is VB or Java. I want to insert it as a Run Script and call it after every execution so that Withdrawn date is populated with some previous date so that product gets un-enrolled from user.
For the ease of connection string , I am able to connect to database to add a Db check point. Connection string is as given below
Provider=MSDASQL.1;Persist Security Info=False;User ID=enterprise_uat4;Data Source=UAT4.
Password you can keep it blank I will fill it out
I am also exploring it from db check point side where in I can write a custom Query in the last page of the wizard. However after writing it I am receiving the following error message
Database check point > Connection details > Custom Query > paste the following query
"Unable to execute SQL query
Command Text doesnt not return a result set "
SQL statement
Update student_course_enrolment
Set WITHDRAWN_DATE = '01-AUG-18'
Where STUDENT_COURSE_ENROLLEMNT_ID IN
(Select STUDENT_COURSE_ENROLLEMNT_ID from student_course_enrolment where student_id = XXXXXXX AND WITHDRAWN_DATE IS null );My query doesn't return any value instead it will update Withdrawn date with some previous date so that product gets un-enrolled.
Thanks
Eswara V
- contacteswart6 years agoOccasional Contributor
Okay. Thanks for telling that. Our environment is very restricted if download a file from net and try opening I will be prompted with Admin credentials which I dont have
Thanks
Eswara V
- contacteswart6 years agoOccasional Contributor
Hello
I downloaded the TCX file and noted the updated .Js file. Code looks quite lenghty and I lost on where to update what?
Sorry I am not too techy :smileysad:
Regards
Eswara V
- tristaanogre6 years agoEsteemed Contributor
In this case, you don't need to update anything in the code.
So, go back to the original attempt you made with SQLUtilities.VBS that you sent earlier... convert that code to VBScript. And, in the line where you SetSQLType, set it to "ORACLE" and you should be good to go.
- tristaanogre6 years agoEsteemed Contributor
Just following up contacteswart... have you gotten anywhere with this yet?
- contacteswart6 years agoOccasional Contributor
How to call you? i.e your first name or calling name
Hi there,
Not yet. while I was looking into this issue new requirement came up. Currently working on new requirement. Once it is done I will move back to your solution.
Will keep you posted about the out come
thanks a lot for your time and explanation
Regards
Eswara V
- tristaanogre6 years agoEsteemed Contributor
Most folks call me Rob or Robert. That's fine for me.
- contacteswart6 years agoOccasional Contributor
Hello Robert
I have attached the JS which you shared and I updated as per my project condition.
Steps I have executed are
- Updated the code as per my requirement
- change extention ot .js > Save it & Close it
- Double click on .js file
No errors are returned
How will I come to know 'myRecords' got populated with enrollment date?
or
How to confirm that connection got established and query execution is sucessful?
Thanks
Eswara V
Related Content
Recent Discussions
- 21 minutes agoSvetaG