Oracle Apex link to BLOB from different table - oracle-apex

I've got a form in which I want to display either a download link for a BLOB or use a file browser field to do the same.
I can manage the file browser method normally, however because the BLOB I want to refer to isn't part of the table the form is based on, I can't seem to get it to show properly.
The best I've got so far is a 'display only' field with an SQL query returning the size of the file.

If you are using Oracle Application Express, you may youse the "P" procedure.
Just like the "F" procedure that you it to show pages, the P procedure allows you to download files from apex.
for example :
http://apex.shellprompt.net/pls/apex/p?n=217605020644166778
where that number at the end is the primary key number form the
select id
from apex_application_files
To add a file to this table, simple add a browse-file item on a page. Run the page, browse for a file, and submit the page. It will automatically insert it in this table.
you can query it after :
select id
from apex_application_files
where filename = YOUR_FILE
good post for this is : http://dgielis.blogspot.com/2007/08/oracle-apex-fp-pn-zp.html
test it out, tell me if you get stuck

Related

How to change a database name in a query via a URL in power bi

i am trying to change my database name in my advanced editor query in power bi. I know i can create parameters with in the power bi desktop app and pass the different database with in it. I have done this and it works fine.
But what i am trying to do is when i give a user a link for example
https://app.powerbi.com/groups/me/reports/DataSource="PowerBi_1"
how do i get the datasource name which is "PowerBi_1" and pass it into my advanced editor query which looks as follows
let
Source = Sql.Database(".", "PowerBi_2", [Query="select *#(lf)from Customer"])
in
Source
so i want to replace the Powerbi_2 with PowerBi_1
is this possible?
I tried searching and the only things i could find was to add parameters from "manage parameters" which i can already do. But i need it to be passed from the URL and automatically change the data source instead of manually changing it via "edit parameters"
i know you can use filter in your URL as https://app.powerbi.com/groups/me/reports/12345678-6418-4b47-ac7c-f8ac7791a0a7?filter=Customer/PostalCode eq '15012'
but this would only work on datasets. im not sure how to do this for a database change in a query
The only thing you could try is if you have a direct query and use the new feature of binding query parameters.
https://learn.microsoft.com/en-us/power-bi/connect-data/desktop-dynamic-m-query-parameters
Then you can set a filter with url to point to the database you need. Not sure how it would work - haven't tried it myself.
To expand on the idea a bit - you would need a table with database names in it. Then you would bind database column of that table to your query parameter and finally, use your url to set appropriate filter on this new table.
EDIT:
Scratch that, in the article I linked to, it says that direct query T-SQL is not supported. But if they were ;)...

Building app to upload CSV to Oracle 12c database via Apex

I'v been asked to create an app in Oracle Apex that will allow me to drop a CSV file. The file contains a list of all active physicians and associated info in my area. I do not know where to begin! Requirements:
-after dropping CSV file to apex, remove unnecessary columns
-edit data in each field, ie if phone# > 7 characters and begins with 1, remove 1. Or remove all special characters from a column.
-The CSV contains physicians of every specialty, I only want to upload specific specialties to the database table.
I have a small amount of SQL experience from Uni, and I know some HTML and CSS, but beyond that I am lost. Please help!
Began tutorial on Oracle-Apex. Created upload wizard on a dev environment
User drops CSV file to apex
Apex edits columns to remove unneccesary characteres
Only uploads specific columns from CSV file
Only adds data when column "Specialties" = specific specialties
Does not add redundant data (physician is already located in table, do nothing)
Produces report showing all new physicians added to table
Huh, you're in deep trouble as you have to do some job using a tool you don't know at all, with limited knowledge of SQL language. Yes, it is said that Apex is simple to use, but nonetheless ... you have to know at least something. Otherwise, as you said, you're lost.
See if the following helps.
there's the CSV file
create a table in your database; its description should match the CSV file. Mention all columns it contains. Pay attention to datatypes, column lengths and such
this table will be "temporary" - you'll use it every day to load data from CSV files: first you'll delete all it contains, then load new rows
using Apex "Create page" Wizard, create the "Data loading" process. Follow the instructions (and/or read documentation about it). Once you're done, you'll have 4 new pages in your Apex application
when you run it, you should be able to load CSV file into that temporary table
That's the first stage - successfully load data into the database. Now, the second stage: fix what's wrong.
create another table in the database; it will be the "target" table and is supposed to contain only data you need (i.e. the subset of the temporary table). If such a table already exists, you don't have to create a new one.
create a stored procedure. It will read data from the temporary table and edit everything you've mentioned (remove special characters, remove leading "1", ...)
as you have to skip physicians that already exist in the target table, use NOT IN or NOT EXISTS
then insert "clean" data into the target table
That stored procedure will be executed after the Apex loading process is done; a simple way to do that is to create a button on the last page which will - when pressed - call the procedure.
The final stage is the report:
as you have to show new physicians, consider adding a column (into the target table) which will be a timestamp (perhaps DATE is enough, if you'll be doing it once a day) or process_id (all rows inserted in the same process will share the same value) so that you could distinguish newly added rows from the old ones
the report itself would be an Interactive report. Why? Because it is easy to create and lets you (or end users) to adjust it according to their needs (filter data, sort rows in a different manner, ...)
Good luck! You'll need it.

File browse Item uploading to BLOB column

One of the tables in my DB has a BLOB column that stores images. So now I am setting up the page for this table. I have a bunch of IGs and such to process most of the data, but I set up a modal page to process the image.
The modal page gets the ID (which is the PK) into an item, and then it reads the image currently in the table into a 'Display Image' item. And I have a 'File browse...' item to upload new images.
Except I cannot get it to save.
I initially started with the display image item just having Setting Based on : BLOB column returned by SQL statement, as I couldn't get the source to work with the SQL query(Error Expected CHAR, source is BLOB), I managed to resolve this by putting automatic row processing on the page and then having the source be a column.
So now it displays well, with no errors.
But the save does nothing. I have tried saving by having the File browse reference the column and using automatic row processing, and there is just nothing. No errors pop up, but it just does nothing.
I have tried saving to APEX_APPLICATION_TEMP_FILES and then having a PLSQL DA or a PLSQL process to
SELECT blob_content
FROM APEX_APPLICATION_TEMP_FILES
WHERE name = :FILE_BROWSER_ITEM
And insert this into the table, but it just pops up a 'No data found' error.
I have gone through every bit of intel my google-fu has found, but I have failed to find a solution.
So I would appreciate any insight any of you might have.
Since noone answered, I stepped away from it for a bit and tried again at a later date. And now I made it work finaly.
I set up automatic row fetch and automatic row processing but disabled both of them, for some reason automatic row processing must be there so that you can have the source for the display image and file browse be the column.
Then I set the browse file to load into apex_application_temp_files.
and set up a process to be executed at page submit(but after the automatic row processing even though its disabled and shouldnt matter). The process executing the following code:
BEGIN
UPDATE MY_TABLE
SET MY_IMAGE = (SELECT blob_content
FROM apex_application_temp_files
WHERE name = :FILE_BROWSER_ITEM)
WHERE id = :ID;
END;
And I execute the page submit through a button with the action page submit and Database action being SQL UPDATE action.
I am guessing a fair bit of the things I did and have set up dont even matter, but I dont dare remove them for fear of breaking shit. What I have described here finaly works for me, and if you stumble upon this then you can try and I hope it works for you too, and you can try removing some of the disabled stuff and see if it still works.

Mapping user spreadsheet columns to database fields

I’m not sure where to start on this project. I know how to read the contents of the excel spreadsheet, I know how to identify the header row, I know how to loop over the contents. I believe I have the UX portion worked out but I am not sure how to process the data.
I’ve googled and only found .Net solutions but I’m looking for a ColdFusion/Lucee solution.
I have a working form allowing me to map a user's spreasheet column to my database values (this is being kept simple for this post; user does not have direct access to the database).
Now that I have my data, I'm not sure how to loop over the data results. I believe there will be several loops (an outer and an inner). Then of course I also need to loop over the file contents but I think if I can get the headings mapped out,I can figure out the remaining.
Any good links, tutorials, or guides would be greatly appreciated.
Some pseudo code might be enough to get me started.
User uploads form
System reads headers and content.
User is presented form with a list of columns from their uploaded spreadsheet to match with available database fields (eg “column1” matches “customer name”.
User submits form.
Now what?
UPDATED
Here is what the data looks like AFTER the mapping has been done in my form. The column deliiter is the ::: and within the column the ||| indicates the ID associated with the selected column value. I've included the id and the column value since I plan on displaying the mapping again as a confirmation. Having the ID saves a trip to the database.
If I understand correctly, your question is: how do you provide the user a form allowing them to map their spreadsheet columns to that of the database
Since you have their spreadsheet column names, and you have the database column names, then this problem is essentially a UI/UX problem. You need to show both lists, and allow the user to map them. I can imagine several approaches to this. My first thought would be some sort of drag/drop operation, as follows:
Create a list of boxes, one for each field in your database table, and include the field name in (or above) the box. I'll call this the db field list. Then, create another list for each column from the spreadsheet, which I'll call the spreadsheet column list. The user would drag/drop items from the spreadsheet column list to the db field list.
When a mapping has been completed by the user, you would store the column/field names in as data for the DOM element of the db field list box. Then upon submission, you would acquire the mapping data by visiting each box and adding it to an array. Then you would serialize that array into JSON and send that to your form submission handler.
This could be difficult or easy, depending on your knowledge of UI implementations using JavaScript. jQuery makes this easy (if you know jQuery). There's even a jquery UI plugin that does this: https://jqueryui.com/droppable/.
A quick search for javascript drag drop would help, and here's a few articles I found:
https://www.w3schools.com/html/html5_draganddrop.asp
https://medium.com/quick-code/simple-javascript-drag-drop-d044d8c5bed5
You would also need to submit the array of mappings using javascript. You could search for that as well, and here's an article I found:
https://codereview.stackexchange.com/questions/94493/submit-an-array-as-an-html-form-value-using-javascript

In Oracle Apex 5 I want to link to an Interactive Report and set a filter RequestID = #RequestID#

I am trying to link a column from an Interactive Report to another Interactive Report in Apex 5. I want to set the filter in the later one with a value from the first one. I used a column of type Link then clicked on Target button to set the page number like this:
It doesn't work. I read there are other ways, I could use an URL link and build the URL to pass the parameters using a package but if I used this, how can I bind it to the link?
Normally you'll need to specify the operator to be used in the link - documentation:
Developing Reports > Editing Interactive Reports in Page Designer > Linking to Interactive Reports
Snippet concerning setting up a link:
To create a filter, use the following itemNames and itemValues syntax:
IR[region static ID]<operator>_<target column alias>
Consider the following example:
IR[EMP]C_ENAME:KING
Meaning that if you want to place a filter on your report where the column REQUEST_ID matches a given value, you'd need the equals operator syntax:
IREQ_REQUESTID:#REQUEST_ID#
However, using
IR_REQUESTID:#REQUEST_ID#
should also work, as the EQ operator is the default operator.
Also consider other issues: do you have more than one IR on the page? You'll need to reference the correct one. Is your generated link correct? Inspect it!
I found what was causing the filter not to work. I was trying to filter a column of type "link". It doesn't work when it's a "link", but it does when it's "plain text". So now you know. Here's how it's looking...
For me it works like this:
I created an Item (display only)(source type: null) on the second page with the second IR.
In the first IR in the Column Attributes set a Link Text and the Target and Page number (like you did already). In the Name part put your Item that you just created and for the Value put the column name in which are the values for your filter (like #Request_ID'#).
Then again on the second page with the second IR you will put something like this in the Region Source:
select REQUEST_ID,
REQUEST_NUMBER,
NAME,
FIRST_NAME,
COMPANY,
COUNTRY,
TYPE,
RQ_IS_ARCHIVE,
RQ_ID_TO
from REQUEST
where REQUEST_ID = :P20_REQUEST_ID
The :P20_REQUEST_ID is the Item that you created on that second page.
You passed the value from the Request_ID column from the first page in to the Item on the second page, there you used it then as a condition.
Hope this helps you...