Insert data into database using sqlldr in coldfusion - linux

I have a CSV file that I got from a website. I need to upload that same CSV file into my database using SQLLDR in ColdFusion. For some reason I'm not able to insert the data into database.
Below is my code. Using this code I was not able to insert the data into database from the CSV file. It is working file from a batch file, but it is not working using cfexecute. By that I mean, I'm getting a blank screen. No errors, no exceptions, nothing. Checked in the logs but I did not get any errors there either. Only thing what I can see is that the data is not inserted into the database.
FYI, we are using Linux environment, so the path is slightly different.
<cfset CTLPATH="/home/mosuser/apps/nodal/ctl">
<cfset LOGPATH="/home/mosuser/apps/nodal/logs">
<cfexecute name="/opt/oracle/product/12.1.0/client_1/bin/sqlldr"
arguments="userid/password#Sid control=#CTLPATH#/mpimReport.ctl
log=#LOGPATH#/#PathfileName#_load.log data=#filelist##PathfileName#.csv
bad=#LOGPATH#/#PathfileName#_error.txt">
</cfexecute>
Update:
As suggested, dumping the error variable qryerr showed:
Message 2100 not found; No message file for product=RDBMS,
facility=ULMessage 2100 not found; No message file for product=RDBMS,
facility=UL

Add a few parameters to your <cfexecute> call.
timeout - in the order of the number of seconds expect the process to take
variable - the name of the variable to hold the STDOUT output of sqlldr
errorVariable - name of the variable to hold the STDERR output of sqlldr
After doing that you can get the output of the call and inspect it for any error messages and other info.
Adding the timeout is the crucial step - this makes cfexecute block until either the program terminates or the timeout is reached. Without a timeout, ColdFusion simply kicks off the process and immediately continues executing the rest of the current page.

Related

Why request in View results in a tree listener shows "No data to display" in non-gui mode

Expected Requests and Response are showing after executing jmeter script in GUI mode but when the same is execcuted in non-gui mode, for few requests it shows "No data to display" and Response is empty.
This was encountered in jmeter v4. Can anybody help as in why such variance in requests when script is executed in non-gui mode?
enter image description here
enter image description here
This is done intentionally, JMeter removes request and especially response data from sample results (mainly because it cannot be stored in CSV format) in order to reduce memory consumption and disk IO required to aggregate and store the data.
If you really need to see request and response data you can "tell" JMeter to store it by adding the next lines to user.properties file (lives in "bin" folder of your JMeter installation)
jmeter.save.saveservice.output_format=xml
jmeter.save.saveservice.response_data=true
jmeter.save.saveservice.samplerData=true
jmeter.save.saveservice.requestHeaders=true
jmeter.save.saveservice.url=true
jmeter.save.saveservice.responseHeaders=true
JMeter restart will be required to pick the properties up. Once done - re-run the test and make sure to use the different output .jtl file (or delete the existing one) - this time it will have much more results suitable for displaying in the View Results Tree listener
References:
Configuring JMeter
Apache JMeter Properties Customization Guide
Results File Configuration

How do I export runtime datatable into excel if any error occurs due to data?

I want to know if I can export a datatable into excel when I get an error due to data while running the scripts.
If i am having 5 records in a sheet, and 2 records processed well, while running the third record my script encounters an error. Am I able to export into excel in that moment?
Errors may occur at any places because of the data.
Your question doesn't explicitly say QTP, but I'm assuming QTP because you used the tag HP-UFT.
I'm not sure what you mean by "when we get error", so I'll explore two possibilites.
1) You're getting an error in the application you are testing; QTP itself is still executing the script.
In this situation, your script should have validation checks (if statements that check to make sure that what you expected to happen did indeed just happen), and if those checks fail, you could immediately do a DataTable.Export(filename) to save the data to disk before QTP ends. Then, the script could continue, or you can add an ExitTest to fail out and stop the test.
Based on your question, I think it's more likely that:
2) You're getting an error in QTP itself. When QTP crashes, it drops any dynamic changes to the DataTable (i.e. if you had done a DataTable.Import(filename) or updated any fields, it would loose that and go back to it's design time DataTable instead)
In this situation, your script is encountering something that is causing QTP itself to stop the script. Perhaps it's hitting an error where an object cannot be found, or some kind of syntax error. You should consider adding defensive statements to check on things before your code reaches the point that this kind of error would occur... For example, perhaps add...
If not Browser("ie").Page("page").WebTable("table").Exists then
FailTestBecause "Can't find table"
End If
...
function FailTestBecause (reason)
Print "Test Failed Because: " & reason
Reporter.ReportEvent micFail, Environment("ActionName"), reason
DataTable.Export(filename)
ExitTest
end Function
Or, you could just use an On Error Resume Next and put in a command to DataTable.Export(filename) immediately after where it is failing...

Coldfusion Nondescript Error Message

I have a coldfusion application that queries an oracle database for some data, converts the query into a CSV variable via a function creaeted by Ben Nadel, and is supposed to use a tag to then convert the csv value into an excel spreadsheet. However it is giving me the following error:
"The following information is meant for the website developer for debugging purposes.
Error Occurred While Processing Request
3
The error occurred in C:/inetpub/wwwroot/APPS/CapDB/generate_extract.cfm: line 312"
Here is the section of code it is referencing:
<cfspreadsheet action="Write" filename="C:\inetpub\apps\capdb\files\extract.xls" format="csv" name="strOutput" overwrite="true">
I've tried sending it different csv variables, even one created by Ben Nadel to work specifically with his custom function and the cfspreadsheet tag. The only thing that changes with the error when I use different csv variables is what number is displayed. I've seen 3 and 35 so far. Has anyone ever encountered an error like this before?

executing script file from azure blob and write its results to file

I'll explain the task requested from me:
I have two containers in Azure, one called "data" and one called "script". In the "data" container there's a txt file with data, and in the "script" container there's a script file.
Now, I need programatically (with WorkerRole) to execute the script file, with the content of the data file as parameters (Example: a script file that accepts a string 's' and returns to the screen "Hello, 's'", when 's' in the string given, and in the data file there's a string), and save the result of the run into another file which needs to be saved in another container called "result".
How do I do all these? I've already uploaded the files and created the blobs programatically, but I can't seem to understand how to execute the file of how to save its result to another file?
Can I please have some help?
Thanks in advance
Here are the steps in pseudo code:
Retrieve the script from the blob(using DownloadToStream())
Compile the script(I will leave this to you as I have no idea what
format your script is)
Load parameters from blob(same as step 1)
Execute script with those parameters.
If your script's can be written as lambda expressions then this becomes a lot easier as you can turn them into Action's
Edit based on your questiions:
DownloadText() is no longer included in Azure Storage 2.0, you only have access to DownloadToStream(). Even if you are using an older version(say 1.7) I would recommend using DownloadToStream() in the event you ever upgrade in the future. This will prevent having to refactor your code.
In terms of executing your script, depending on what type of script it is(if it is c# code you can use this example: Is it possible to dynamically compile and execute C# code fragments?. If you need to execute a different type of script you would need to run it using Process.Start and you can look at this example: http://www.dotnetperls.com/process-start
I do not have much experience with point number 2 but those are the processes I have heard and seen used.

MVC3 return File action causes intermittent Excel program error

I have a problem that closely relates to this problem Microsoft Excel Error: "There was a problem sending the command to the program." whereby opening Excel gives There was an error sending a command to the program error.
However, rather than the file existing and being opened or shortcutted-to, I am using MVC3 with an action that generates a bunch of data, generates an excel file (using NPOI), writes it to a MemoryStream and then chucks that to the browser using the built-in return File(etc) ActionResult, with something akin (but shortened here to aid readability) to this:
return File(myMemoryStream, "application/vnd.ms-excel", "filename.xls");
The first time you click the link which fires this action and returns this File - it comes up with the error. if you press ok and try it again it works, and will continue to work... forever
Now I know this is potentially something to do with disabling DDE/plug-ins or something in Excel - but since I'm generating an excel workbook and dumping it to a memory stream rather than opening something that exists permanently on the file system, I'm not sure what options I have to remove the issue.
Any suggestions on how to get around it? Perhaps I have the wrong mime-type?
The Content-Type application/vnd.ms-excel is sending the command to the Browser to open the file in the Browser. Which can be the cause of issue. Try setting the content type to application/x-msexcel.
In your example the browser will try to open an Excel spreadsheet in the browser (if the user has Excel installed).
return File(myMemoryStream, "application/vnd.ms-excel", "filename.xls")
Please make the following change
return File(myMemoryStream, "application/x-ms-excel", "filename.xls")

Resources