Values between pages with Apex - sql

I tried looking for an answer, but everything I found seemed too high level. I am a college student who's working on a database project. We need to use apex (oracle) to shred data from an open API source. You can see what me & my team are working on here: http://bit.ly/Jvt4av.
I have listing of movies with links. Those links go to another page that is supposed to show all sorts of details for that movie.
I have successfully passed the movie_id variable between the list and the detail page, but I am stumped now. I need to show the movie's details and I don't want to use reports or forms because they're too ugly to show this kind of info. I want to be able to show the data with HTML. So, my questions are:
Where/how do I query the database, so I can use the results in HTML?
How do I display those results in HTML?
Thank you!

Well, if you have the movie ID then you can use it to query the database and get all the other details from the database. If you want to render those details using just plain HTML then a PL/SQL region in conjunction with some htp.p calls will do the job. For example:
for x in (select * from movies_details where id=<MOVIE_ID>) loop
htp.p('<h1>' || x.movie_title || '</h1>');
end loop

Related

Where in the Sitefinity database is content stored?

I've successfully migrated 1,000s of news items and other content from Sitefinity 5 to Wordpress after hours of excruciating analysis and sheer luck with guessing but have a few items that are still left over. Specifically the pages. I know a lot of the content is stored in very obscure ways but there has to be somebody who has done this before and can steer me in the right direction.
My research (and text-search against the DB) has found the page titles etc but when I search the content I get nothing. My gut tells me that the content is being stored in binary form, can anyone confirm if this is the case?
Sitefinity documentation is only helpful if you're a .net developer who has a site set up in Visual Studio (as far as I've seen).
This is probably the most obfuscated manner of storing content that I've ever encountered. After performing text searches against the database I've finally found where the content is stored but it's not a simple process to get it out.
Pages' master record appears to be sf_page_node, there are related tables:
sf_object_data (page_id is related to sf_page_node.content_id)
sf_draft_pages (page_id is related to sf_page_node.content_id)
sf_page_data (content_id is related to sf_page_node.content_id)
sf_control_properties (control_id is related to sf_object_data.id)
So you could get the info you need with a query like this:
select * from
[sf_page_node]
join sf_object_data on sf_page_node.content_id = sf_object_data.page_id
join sf_control_properties on sf_object_data.id = sf_control_properties.control_id
Other things to consider:
the parent_id field is related to the sf_page_node table, so if you're writing a script, be sure to query this as well
the page may have a banner image, you will pick up the "place_holder" value as 'BannerHolder' with a caption of "Image" The image may be stored as blobs in sf_media_content, you should handle this separately. The "nme" value of 'ImageId' will have a GUID in the "val" column. You can query sf_media_content with this value as "content_id" the actual binary data is stored in sf_chunks, they relate on "file_id"
My revised query taking into account what I'll need to migrate content is below:
select
original.content_id,
original.url_name_,
original.title_,
parent.id,
parent.url_name_,
parent.title_,
place_holder,
sf_object_data.caption_,
sf_control_properties.nme,
val
from [sf_page_node] original
join sf_object_data on original.content_id = sf_object_data.page_id
join sf_control_properties on sf_object_data.id = sf_control_properties.control_id
join sf_page_node parent on original.parent_id = parent.id
I hope this helps someone!
You don't need the version items in this case - as you already found out, it stores the previous version of the pages in binary format.
The current live pages' data is available in sf_control_properties and sf_object_data tables. You need to join these together with sf_page_data and sf_page_node and you will get the full picture.
Depending on your requirements, it may be easier to do a GET request to each page and parse the returned html response.

Oracle Application Express SQL Query to show meaningful information

I am trying to write a query that 1) works and 2) shows meaningful information.
However, I can't seem to complete both scenarios. Both bits of code do work to a degree. My SQL query does work by showing all the useful information a user wants but when you click the edit button it doesn't link properly so it won't allow the user to update that row. The other shows only keys and rowid but when you click edit does show the information and allows it to be updated.
So as not to get another down-voted question, I have taken pictures of each scenario to show the problem, but, ultimately, I need to show meaningful information: an id or key isn't meaningful to the vast majority of users.
Here is my code
SELECT APPLICATIONS.APP_ID, APPLICATIONS.SRN, STUDENTS.SURNAME, STUDENTS.FORENAME, APP_STATUS.STATUS, METHODS.METHOD, JOBS.JOB_TITLE, APPLICATIONS.APP_DATE
FROM APPLICATIONS
JOIN STUDENTS
ON APPLICATIONS.SRN = STUDENTS.SRN
JOIN APP_STATUS
ON APPLICATIONS.STATUS_ID = APP_STATUS.STATUS_ID
JOIN METHODS
ON APPLICATIONS.METHOD_ID = METHODS.METHOD_ID
JOIN JOBS
ON APPLICATIONS.JOB_ID = JOBS.JOB_ID;
and here are the pictures of it in action
below is the code that does not show meaningful information but does work.
select "ROWID",
"APP_ID",
"SRN",
"STATUS_ID",
"METHOD_ID",
"JOB_ID",
"APP_DATE"
from "#OWNER#"."APPLICATIONS"
If i knew how to properly use rowid i am sure this is a simple feat but i dont so if i could get any help it would be useful
//edit
who ever renamed this to Application Expression why? what i am using is Apex Application Express it was relevant information that got changed to something wrong which might make it hard for someone with a similar problem to find later.
In the second, simple query, apex can determine which table (and record) you are trying to edit.
In the first query, with the joins, it can't tell which of the five tables in query you want to edit. You probably want to have the edit link pass the primary key of the row from APPLICATIONS to the child page. You would need to build into that page any logic (lists of values etc) that map lookup tables (such as status) to the values needed in the APPLICATIONS table.

Repeating Data In Access Combo Box

I am having an issue regarding repeating data in my access form, I want to be able to select a tutors name and for it to display all of the students linked to that tutor this does work however in the list view because one tutor sees many students the data is repeated (see images) Is there a SQL statement I should be using to stop this? (I am new to Access and SQLServer so I apologies if this is an obvious) Please see the images below which will make my issue clear.
I solved my problem by adding SELECT 'DISTINCT' to my SQL Statement so from
SELECT "Tutors"."PAT" FROM "Tutors";
To:
SELECT DISTINCT "Tutors"."PAT" FROM "Tutors";

SRSS: Dynamic amount of subreports in a report

it might be possible I'm searching for the wrong keywords, but so far I couldn't find anything useful.
My problem is quite simple: At the moment I get a list of individual Ids through a report parameter, I pass them to a procedure and show the results.
The new request is like this: Instead of showing the list for all individuals at once, there should be a list for each individual id.
Since I'm quite a beginner in srss, I thought the easiest approach would be the best: Create a subreport, copy the shown list, and create a subreport per individual id.
The amount of this IDs is dynamic, so I have to create a dynamic amount of subreports.
Funny enought, this doesnt seem to be possible. This http://forums.asp.net/t/1397645.aspx url doesnt show exactly the problem, but it shows the limit of the subreports.
I even ran trough the whole msdn pages starting http://technet.microsoft.com/en-us/library/dd220581.aspx but I couldnt find anything there.
So is there a possibility, to create a loop like:
For each Individual ID in Individual IDs, create a subreport and pass ONE ID to this?
Or is there another approach I should use to make this work?
I tried to create a 'Fake'-Dataset with no sql query but just for iterating the id list, but it seems the dataset needs a data-source...
As usual, thanks so far for all answers!
Matthias Müller
Or is there another approach I should use to make this work?
You didn't provide much detail about what sort of information needs to be included in the subreport, but assuming it's a small amount of data (say, showing a personnel record), and not a huge amount (such as a persons sales for the last year), a List might be the way to go.
I tried to create a 'Fake'-Dataset with no sql query but just for iterating the id list, but it seems the dataset needs a data-source...
All datasets require a data source, though if you're merely hard-coding some fake return data, any data source will do, even a local SQL instance with nothing in it.

How to Structure an ASP.NET website with over 1,300 Articles/Quotes

Good Morning All,
I have loaded over 1,300 blurbs into my client's database with table schema of BlurbID, Seq, Content, Keywords. A separate database table will contain vote details (voteID, BlurbID, Seq, VoteDate). His intent is to have a blurb website that serves up humorous quotes. Users must vote for the first blurb before being allowed to see the next one, and so forth.
The client will modify the blurb table as needed to re-sequence the blurbs. He wants the blurbs displayed on content pages in the website according to the value of the SEQ field in the Blurbs table. Thus, the entry with SEQ=1 will be the first Blurb displayed on the site etc. Users will be required to vote using a radiobuttonlist for each blurb before being allowed to see the next blurb.
Question: Is it advisable to use one content page (default.aspx) to serve up the blurbs? If I do that, how do I structure a stored procedure to select the blurbs according to the SEQ field in the blurb table? Conversely, do I create content pages for each of the 1,300 blurbs? If I use one content page, what would the TSQL look like to iterate through the blurbs according to the SEQ field after a vote is cast for each blurb? Pseudo code would be: if radiobuttonlist.value >0 then select blurb id, seq, blurbcontent, keywords from blurbs where seq = current seq +1
Finally, for SEO purposes, should I output the keywords database field to a hidden field on the content page?
If you have written this type of site before, I would greatly appreciate your insight and guidance.
Thanks,
Sid
Learn asp.net ;) Seriously - especially the ASP.NET routing added some time ago, and while you are at it, learn MVC.
There is no sense to even have more than one view on the data. It is all the same.
Years ago, those who did not know made something like "/default.aspx/id=1
Years ago, those who DID read the documentation wrote something like "/content.ashx/112
Today everyone should use URL routing and write something like /sometitle.html for everything, and use the routing mechanism to route that call to a program module (page, view, whatever) that generates the html.
I suggest pulling the title from the database (or use the first x words) so you have some textual reference, not jut an ID.
Now, database
What do you mean with "how do I structure a stored procedure to". This is similar to "how do I structure a pizza delivery service to deliver pizza tonno". The stored procedure sturecture should depend on your coding guidelines, not on what data you retrieve- this is for the code part in the structure. And that will depend a lot on your needs, which obviously are - given from the site design.
Why do you think you even need a stored procedure here? ;)