PL/SQL delete static workspace file - oracle

I've been searching on google and still not found anything.
Is there any possible way to delete a file from the Static Workspace Files within the database?
For example you can remove a file from the Static Application Files with this procedure wwv_flow_api.remove_app_static_file
Regards

Looking at the source code for app 4000 page 315 (the page used to delete a static workspace file through the APEX Builder), it doesn't seem to be using any sort of API to remove the file. It just seems to be performing a DELETE on WWV_FLOW_COMPANY_STATIC_FILES. You should be able to perform the DELETE yourself if you prepend your APEX schema to the beginning of the table like this:
DELETE FROM APEX_190200.WWV_FLOW_COMPANY_STATIC_FILES
WHERE id IN (SELECT workspace_file_id
FROM apex_workspace_static_files
WHERE workspace = 'MY WORKSPACE' AND file_name = 'temp.txt');

Related

Excel cannot open the file because the file format or file extension is not valid - PHP Maatwebsite

In our backend project, we have some features that allows to export files to xlsx.
We have done some tests locally and everything is working fine.
However, I deployed the app in an Azure App Service and some of the exports (not all) are not working fine.
I deployed backend (PHP), frontend (React) and database (MySQL) in Azure. I copied the information of the local DB to the DB deployed in azure (just because we don't wanna waste time with the data).
In the backend project, we are using Laravel with Maatwebsite for the features related to the exports. I created a class that implements FromQuery, WithHeading and ShouldAutoSize and that has construct, query and headings functions. Next, in a Controller, I use this structure to get the file:
public function functionName(Request $request){
$fileName= 'name'.time().'.xlsx';
return (new ClassThatHasTheLogicOfExporting($request->all()))->download($fileName);
}
All my exports works like that, but I'm getting the following error in some of them:
"Excel cannot open the file because the file format or file extension is not valid"
When I try to open the file.
I've been reading about the issue and some people says that I should use ob_start() (at the beggining of the class) and ob_end_clean() (just before exporting the file) but when I do this, I get a 404 error in the web app.
A curious thing is that when I add a filter to the data for exporting (for instance, downloading only the data of people in a specific city) (I can do it in the frontend app), the file opens without errors.
With this strategy, I've achieved downloading all the data in separate groups, so I don't think that the issue is related to special characters in the data.
Does anybody have any suggestion?
I'm using maatwebsite/excel 3.1 and PHP 8 with Laravel 8
I believe the error statement correctly suggests the error is being caused due to an invalid extension. Don’t worry there are several workarounds to this, I am sharing them below:
Method 1 – Change the Default File Format to Save Excel Workbooks
In Excel 2007, click the ‘Microsoft Office’ button and then ‘Excel Options’. In Excel 2010 and higher versions, click File > Options.
Select the Export option.
Select the Change File Type option.
Change the file extension, and then click Save As.
Method 2 – Recover Unsaved Workbook
Go to File and select the Info option.
Under Manage Versions, select ‘Recover Unsaved Workbooks’ op
If MS Excel has unsaved files then, it will list them. You can open and save it.
Method 3 – Use the' Open and Repair' Feature of MS Excel
Open MS Excel application.
Go to File and select the Open option.
Select the corrupt file and choose the Open and Repair option.
You can also check this forum:
https://social.technet.microsoft.com/forums/office/en-US/63020ccc-51d7-46d9-b956-121c0e6efcc8/excel-file-error-the-file-format-and-extension-dont-match?forum=Office2016ITPro
Best Regards,
Steve
you can add the below
if (ob_get_length() == 0 ) {
ob_start();
$response = Excel::download(new KingdomsExport, 'kingdoms.xlsx',\Maatwebsite\Excel\Excel::XLSX);
return $response;
}

How can you create a view as a post deployment script in a SQL Server Database Project?

I've create a SQL Server Database Project and imported my database. I've got a few static data tables that I want to recreate every time it's redeployed, so these get recreated as part of the post deployment script.
To ensure this drops and recreates them I've changed these static data tables to have a build action of 'None' so they are dropped as part of the build and only recreated as part of post deployment steps.
My problem is that I have a view that references these tables. Obviously this shows syntax errors as the tables are no longer part of the build as their build action is 'None'. My workaround was to try and create the view also as part of the post deployment script. I do this with the following code:
:r .\PostDeploymentScripts\Views\myView.sql
The actual script looks like this:
CREATE VIEW [CompTotalByType] AS
SELECT
c.Id,
t.id AS TypeId,
SUM(c.total) AS CompTotal,
FROM CompNumber c
INNER JOIN Type t
ON t.ProdId = c.ProdId
GROUP BY
c.Id,
t.id
However, now I get a syntax error under 'CREATE VIEW' as follows:
Severity Code Description Project File Line Suppression State
Error SQL72007: The syntax check failed 'Incorrect syntax near CREATE.' in the batch near:
'CREATE VIEW [CompTotalByType] AS' ....path name....
However, when I put this code into SSMS it has no syntax errors. What's causing this?
I found the answer here: SQL72007: The syntax check failed 'Unexpected end of file occurred.' in batch near :
It was the second answer that said you needed to add a 'GO' to the previous script. This makes sense as the CREATE VIEW needs to be in its own batch. So I added a 'GO' to the bottom of my previous script before creating the view and that fixed it.
How many static tables are you trying to recreate? I have a similar situation, but what I do instead is create 'MERGE' scripts using a stored procedure on Github called sp_generate_merge. Then I simply include those scripts within the project under a 'Scripts' folder and call them within the post-deployment script. That way you don't have to drop/create them, and your view and tables can be included in the build.
However, if you'd like to keep it the same - it seems that the other user is correct in saying that you need to add 'GO' before 'CREATE VIEW'.

Oracle Apex: files stored in BLOB column not accessible after session expired

I have Oracle Apex app to upload files. Files are loaded by P14_FILE_BROWSE item and storage type is set to apex_application_temp_files. After upload button is pressed process with following PL/SQL code is executed:
declare
begin
insert into files(
ID, NAME, FILENAME, MIME_TYPE, CONTENT )
select ID, NAME, FILENAME, MIME_TYPE, BLOB_CONTENT
from apex_application_temp_files
where name = :P14_FILE_BROWSE;
end;
I have created report with this table and column ID is defined as URL link p?n=#ID# . I am able to download my files by this link. It works fine until my session expire. When session expire files are no more accessible (The webpage cannot be found). But files are still stored in files table as you can see here:
files table
Why my files are no more accessible by p?n=.. after session expire ? I am using Oracle 12c with Oracle Apex 5.1.
Thank you
As per the documentation:
http://docs.oracle.com/cd/E59726_01/doc.50/e39143/toc.htm#HTMRN264
"Any select, update or delete operations on WWV_FLOW_FILES should be changed to using the APEX_APPLICATION_TEMP_FILES table. Deletes are no longer necessary, as the file will automatically be purged after the request or when the session is purged."
Just a suggestion:
When you define the link to the report based on the file you uploaded , do include the session and debug id.
example:
'f?p=&APP_ID.:'|| PAGE_ID || ':&SESSION.::&DEBUG.::::'
This be the link to a page (PAGE_ID ) of the application having app_id(APP_ID)
here,
PAGE_ID is a report page and this report is based on a file uploaded using file browser.
When I had missed out to include the session and debug id , I too couldn't find my report page in a new session.

Microsoft office cannot find the input table or query

I am trying to migrate an access database from 2000 to 20007 version. I have two .mdb files one used as a front end and the other containing only the back end tables. I performed all the necessary initialization for the migration like export of table, extension with .accd, etc.. But when i execute the following code , i get an error " Microsoft office cannot find the input table or query . Check spelling and so".
set Db=currentDb
SQLText ='some sql query'
Db.OpenRecordset(SQLText, dbOpenDynaset)
When i tried to output the value of Db with a msgbox (MSgbox Db), it shows the message "ABC, type mismatch", where ABC is the function name. But, Msgbox Db.name showing the correct database name. But, the same code has been running fine on the older version.
Please help me on this
Okay, you do not have to "migrate" to a different version persay. You only have to import everything from an MDB to ACCDB file. That is all. Scratch whatever you have done, start afresh.
Create a new "empty" accdb file, then using the options under
External Data-> Import/Link From Access. Select the Front End Access
file. Use the Option IMPORT Forms, Report etc., select all Forms, Reports, Queries, Mods then click OK. This
will import all objects.
Create a new "empty" accdb file, then using the options under
External Data-> Import/Link From Access. Select the Back End Access file. Use the Option IMPORT Forms, Report etc., select all tables and click OK. This will import all the tables over to the new file.
Now open up your new "front end" (the one with accdb extension). Under External Data -> Import/Link. Select the new "back end" (the one with the accdb extension). Use the Link to the Data Source option. Then select all tables and click OK.
Now perform a Compact & Repair, follow it with a Compile of the VBA code.
The whole strategy will fail if you have a backend DB in a different platform like SQL or Oracle.

DocsList findFolder() issue

This is a google spreadsheet script question.
I have a GUI setup in order to search for "SouthWest" and then find a "test" sheet. This is the code I am using.
var file = DocsList.getFolder("SouthWest").find("test");
This works just fine when I run it under my account (as I have this folder and file setup correctly) but when another user is logged into google docs it will attempt to search for this folder/file under the new user instead of the owner of the document. Is there a way to have it just search the DocsList of the owner of the spreadsheet that is currently open? The error that I get under the new user is "Error encountered: Cannot find folder SouthWest." Thanks.
If you always want to access the same file, you can use the getFileById method and address it directly instead of searching every time:
https://developers.google.com/apps-script/class_docslist#getFileById
Of course, you should make sure that all users are allowed to access that file.

Resources