developers

    Forum Stats

  • 3,873,924 Users
  • 2,266,630 Discussions
  • 7,911,659 Comments

Discussions

I have a REST data source for genres of a given movie, but how can I store those in a local table?

I want to do this so I can filter movies by genre. As an extension of the APEX Movie Catalog tutorial, I created a REST data source for retrieving the genres from the Movie Database movie detail JSON payload, and I can output the genres onto the Movie Details page, but if the user adds a movie to their watch list, how can I store the genres in my movies_x_genres table?

I keep believing I can do something like write the rows of #APEX$SOURCE_DATA# to my table, but I have not figure out quite how to do that.

This seems like something people would need to do, basically query a web service (like TheMovieDB.org) and store the multiple records that are returned within the JSON payload, but I have not found a solution yet and have not created a working solution yet, either. I'd love to hear if others have done something similar.

Answers

  • jariola
    jariola Member Posts: 10,924 Gold Crown

    Depend APEX version you use, check if REST Data Source Synchronization is what you looking for

    https://blogs.oracle.com/apex/post/synchronize-data-from-rest-services-to-local-table-with-no-code-at-all

    SmithJohn45
  • Sean Montgomery
    Sean Montgomery Member Posts: 2 Employee

    Thanks, Jariola, for the suggestion. I am on the latest APEX, so I can certainly enable synchronization, but the problem is that my REST Data Source is based on .genres (array within the movie JSON), so when that REST Data Source retrieves, I can get genre ID and genre name, but I can't also collect the movie ID. The movie ID has to be a parameter for the REST data source, and I need it to be the primary key for the local table.

    So whereas this MIGHT work if I knew how to include the value of the REST data source parameter from the page (i.e. P3_ID) in the REST data source output, I don't seem to be able to include :P3_ID in the output. Also, I don't see how to fire the REST data source sync from a form.

    I completed the entire tutorial for the Movie Catalog, and all I want to do is query the genres out of the JSON that the Movie Details page already has available and write them to a table movies_x_genres. I feel like this is an application dev 101 operation, but I don't know how to reference the JSON genres array from the form that is already accessing the JSON but at the movie level (rather than the genres array).

    I don't even know if I am making sense.

developers