Facebook Ads: use of parameter ad_id

Hi there,

I’m already using the view AdInsight by AdAccount using the following statement.

    create or replace table myAdInsights@inmemorystorage 
    as 
    select t.* 
    from   myadaccounts act 
    join   AdInsightsByAdAccount(act.id) t
    select /*+ ods(true) */ * 
    from   myAdInsights@inmemorystorage

Now I would like to use the same view but only by Ad. I know I need to use the parameter “ad_id”

Can someone help me with this?

You can either use:

    --
    -- Using base tables.
    --
    select ait.*
    from   ( select ad.id
             from  MyAdAccounts act
             join  AdsByAdAccount(act.id) ad
             --
             -- Just 10 to get some number quickly.
             --
             limit 10
           ) ad
    join  AdInsightsByAd(ad.id) ait

or

    --
    -- Alternative 2: use a pre-defined view which is essentially the
    -- same, but can be slower depending on your needs.
    --
    select ait.* 
    from   AdAccountAds ad 
    join   AdInsightsByAd(ad.dtl_id) ait
    limit  10