Can Data Export from SQL Developer to Excel be scheduled? - excel

I have to run almost 50 queries daily for daily reports and copy-paste the data into Excel sheets. Is there a way to schedule a job on SQL Developer that exports data from all the queries in an Excel Workbook?

You could link the excel spreadsheets to your queries so they automatically update themselves.
Insert > Data from External Source. I do this with SQL Server a lot, and you can do it with Oracle too if you know the connection strings.
I would comment, but I dont have the rep yet.

I would advise using your operating system to schedule the task. Assuming that this is Windows (as you want to write to Excel) then you can use Task Scheduler to set off a cmd script or powershell script which can call SQLPLUS passing in a parameter for the the sql file that you wish to run. It would not be too difficult to output this to a CSV file which can be opened in Excel. If you actually need to write the data to a .xlsx (or similar) file then there are options (e.g. Python libraries that can do this), but it will not be as straight forward.
I am not sure exactly what part of this you need help with, so can I suggest that you consider the steps below, if you want to proceed do some research and have an attempt at each step and then post a question for each that you are stuck on with details of what you have tried:
Schedule a job from your operating system;
Write a script to call SQLplus and execute a .sql file;
Change query output to csv and redirect to file (or find a way to write directly to an Excel file if this is what you need to do);

Related

Insert data from a CANoe database to an existing Excel sheet

`Recently, I was given a task to automate the process of inserting some data of an ECU in CANoe into an already existing Excel sheet using CAPL. I am fairly new to this and wanted some help. I will be as elaborate as possible.
How can I create an link an env var to a database in CAPL/CANoe.
I have already creaed a panel with a button that should be assigend with the above asked env var. So, my question here is how can I access an already existing file that needs some data from this button? I mean CAPL does not allow excel format. How can I output some data to an existing excel sheet with the click of a button? How should I proceed to write the code for this?
CAPL has no API to communicate with Excel and/or print to Excel format.
You need to write your library to do it, or use an external script (think a python script, or something else) with a call to SysExec() in your CAPL.
To the best of my knowledge, there isn't an opensource solution ready.

Running SAS programs from excel

I have a few SAS programs that I need to run from excel. The programs pull tables from SQL, perfom some calculations and give an output table that I would like to present in Excel. So I figured that it would be great to run everything in excel.
There are a few parameters in the code that need to be changed before running, so the best idea I had is to put the SAS scripts in cells on an excel sheet and change the variables with VBA.
My question is, is this achievable? Can I connect to SAS and do everything from excel?
I'm fairly good with VBA, starting to learn SAS, but I don't really know how to connect the two. Thank you for your help!
Yes it is possible , i did this in my work a week ago , SAS have an documentation here?
The link below can help you.
http://documentation.sas.com/api/docsets/itechwcdg/9.4/content/itechwcdg.pdf?locale=en
You can use ADODB to connect to , see here for the strings
https://www.connectionstrings.com/sas/
Your options are:
1) use VBA to connect to IOM, create a workspace, run your program.
This requires quite a bit of VBA, as well as the SAS Addin for MSO, and various components.
2) Run a Stored Process (STP) via point and click using the MSO addin
Again, this requires a desktop SAS Addin deployment, and isn't scriptable with VBA
3) Run a Stored Process as a web query
This is an excellent option - you don't need any special desktop installation, you can easily add (url) parameters, you can use it with / without VBA, and your output will render easily into your worksheet so long as you stream tab delimited data via the _webout fileref (without %stpxxx macros). It will also work with all versions of excel and SAS.
This approach is described here: https://www.rawsas.com/sas-as-a-service-an-easy-way-to-get-sas-into-excel-power-bi-and-000s-of-other-tools-languages/

How do I create a file from a result set?

I'm using Oracle 11g
I'm trying to create a flat file (CSV or TXT) from a result set but am struggling on where to even start. It seems like I have to create a stored proc and use UTL_FILE. After doing some research, I have two questions:
Where does the file get created? According to this question I need to get access to the Oracle user directory, but where is that on a Windows and Linux environment? I have to test on Windows , and the script will eventually be on a Linux environment.
What would be the basic format of a SQL script to create the aforementioned file, and load data into it from a fairly basic SELECT query? I'm not seeing a UTL_FILE function to write the records to the file; do I have to iterate through the entire result set and use PUT or can I somehow just push the entire result to a file?
I think using "spool" can do the trick.
Check this out https://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTION_ID:9518534700346581975
And more information is here http://www.dba-oracle.com/t_sqlplus_spool.htm
The file will get created in the directory where you launch sqlplus from.
If you're using SQL Developer you can create a view for your query. Right click view in schema browser and choose export and export as csv.
But personally I would go for spool as previous answer said. SQL Plus is most basic client so I don't believe you won't have it.

How to automate SAS EG 4.1 program daily and put the output in Excel and run VBA and print PDF?

I am totally new to automation, but trying hard to find answers online everywhere for 1 week. I could not able to do what I wanted to do. I have a SAS enterprise guide 4.1 old version and program runs on a SAS server. I have a SAS report due every day at 9:30 AM. I have the code that is already setup and working fine. I need to automate this program to run at 8:00 AM every day, then move the output to a specific excel file in sheet 1 at specific cell range, then invoke the VBA macro button (UPDATE) placed in the sheet 2 and then print out two worksheets in the same file as a single PDF file to somewhere in my computer. I will have to upload this into a CMS. I wanted to automate until the step before the last step, creating the final PDF report on a daily basis.
When I thought about all these I was stunned. I actually created a batch file in notepad and made SAS to open the file at specific time using Task Scheduler in Windows XP control panel. However, SAS did not run the program.
Here is the batch file code:
Start/w C:\PROGRA~1\SAS\ENTERP~1\SEGuide.exe –sysin "Z:\ccccc\vvvvv\Report.egp"
If anyone could please help me, I would like to know how do I make the SAS to run the program in the SAS server and also where do I provide the user name and password for the SAS server authentication. Can anyone please give me an example how to write this code in my batch file. Also, how to export the output into the specific excel file in SHEET 1 and then run the VBA macro. Then how to print out PDF files of two worksheets as a single file and place the final PDF file in the C:\Report folder.
I am sorry it is too much information, but if someone could help me figure out, I would really appreciate all your help!
Park
Enterprise Guide automation is a bigger issue than can be covered in a StackOverflow answer in detail. In general, EG exposes itself to automation through a DLL (SASEGScripting.dll), which you can then automate using VBScript, Powershell, or .NET (C# etc.). You need to read the documentation for the API or read a tutorial.
Chris Hemedinger has several good explanations of how to go about doing this; for example, see this article, or browse his blog articles.

Cannot connect csv to Excel thru ODBC

HI;
I cannot connect a CSV file to a SpreadSheet when the file is open. Currently a have a csv log file that is being constantly updated. I was able to connect it a an Excel SpreadSheet by normal import from external source with refresh every hour. However, its a big file so I needed to produce the reports using EXCEL SQL. It will not allow me to connect to the file while it is open. It says that the MS Jet database engine cannot open the file'unknown'. It is already opened exclusively by another user or i need permission to view its data. If granting permission is he problem , where do I grant myself permission. On a standard Impor, I have no problems reading the file while it is open, but otherwise, get this message and cannot proce3ed. Any help would be appreciated. If I close the update program, I am able to run the queries, but not if the update is running.
Using MSO 2007 W7 x64
It will not allow me to connect to the file while it is open.
That's right, it won't - there is no way to change this.
You must find another way to solve your problem.
How big is the file? You may be able to make a copy to a temporary filename, and connect Excel to that instead.
It sounds like you are accessing a logfile. LogParser can read CSV. In any case LogParser has an excellent SQL-like syntax and can read CSV files much more quickly and reliably than ODBC. It is also programmable from Excel VBA (or script). Perhaps you can use LogParser to extract the values of interest and then load those into your Excel table instead.
I suspect your best solution will be to use the LogParser MSUtil.LogQuery object from Excel VBA, to extract the values of interest into your spreadsheet. Since I don't know what you are actually doing this is just a guess!
I cannot recommend LogParser highly enough - it is a wonderful tool, and can read just about every standard type of logfile, CSV, TSV, W3C, as well as plain text files and the windows NT event logs:
LogParser 2.2 Download: http://www.microsoft.com/downloads/en/details.aspx?FamilyID=890cd06b-abf8-4c25-91b2-f8d975cf8c07&displaylang=en

Resources