We have a report with bursting query in OBIEE12c. We schedule report job using webservice via ScheduleService::scheduleReport() using web service client.
In the Burst Query we set the TEMPLATE for the generated report. Every thing is working fine.
select "invoice_table"."invid" as "KEY",
**'invoice_template1' as "TEMPLATE",**
'en-US' as "LOCALE",
'PDF' as "OUTPUT_FORMAT",
'EMAIL' as "DEL_CHANNEL",
'America/Los_Angeles' as "TIMEZONE",
...
The new requirement is to change the TEMPLATE in bursting query dynamically.
Is there any way to change the TEMPLATE set in Bursting query dynamically while invoking ScheduleService::scheduleReport() so that the generated report changed according to requirement.
There are different ways to do it. It all depends on what is the condition to change the TEMPLATE. If it is within reach of your bursting select command then you can use CASE expression to select the right TEMPLATE. But it is probably not.
I do burstings combined with BI_BURST_CONTROL table created for different reports where are all the data needed to control the execution. That table is joined to and part of bursting query. One of such looks like below where I use CASE to either send the report by mail or to save it to the directory. The same way you can change the TEMPLATE but only if you can define the condition for the CASE expression.
SELECT
mb.MATBR "KEY", -- DELIVER_BY Node beeing matched to KEY column
bc.TEMPLATE "TEMPLATE", -- Layout template to use (not name of Layout file)
bc.LOCALE "LOCALE", -- Localization (hr-HR)
'PDF' "OUTPUT_FORMAT", -- (PDF)
CASE mb.MATBR WHEN '000000' THEN 'File' ELSE 'Email' END "DEL_CHANNEL", -- (Email) (File) for not existing MATBR
CASE mb.MATBR WHEN '000000' THEN 'D:\File_Delivery' ELSE mb.MAIL END "PARAMETER1", -- (Email)To (File)Folder='D:\File_Delivery'
CASE mb.MATBR WHEN '000000' THEN 'Ost_' || To_Char(bc.ID) || '_' || :PROLAZ || '.pdf' ELSE Null END "PARAMETER2", -- (Email)Cc=Null (File)FileName
CASE mb.MATBR WHEN '000000' THEN Null ELSE bc.PARAMETER3 END "PARAMETER3", -- (Email)From (File)Null
CASE mb.MATBR WHEN '000000' THEN Null ELSE bc.PARAMETER4 END "PARAMETER4", -- (Email)Subject (File)Null
CASE mb.MATBR WHEN '000000' THEN Null ELSE bc.PARAMETER5 END "PARAMETER5", -- (Email)Message body (File)Null
CASE mb.MATBR WHEN '000000' THEN Null ELSE bc.PARAMETER6 END "PARAMETER6", -- (Email)Attachment=true (File)Null
Null "PARAMETER7", -- (Email)Reply to=Null (File)Null
Null "PARAMETER8", -- (Email)Bcc=Null (File)Null
Null "PARAMETER9", -- (Email)=Null (File)Null
Null "PARAMETER10", -- (Email)=Null (File)Null
bc.OUTPUT_NAME || mb.MATBR "OUTPUT_NAME" -- (Email)=AttFileName (with no extension) (File)Null
FROM
(
Select
MATBR "MATBR",
E_MAIL "MAIL"
From
SOME_TABLE#DBLINK
Where
DATE_START <= Last_Day(Add_Months(SysDate, -1)) And
Last_Day(Add_Months(SysDate, -2)) < Nvl(DATE_END, To_Date('11.10.2062', 'dd.mm.yyyy')) And
E_MAIL Is Not Null
UNION
Select '000000' "MATBR", Null "MAIL" From DUAL
) mb
INNER JOIN
BI_BURST_CONTROL bc ON(bc.OWNER_ID = 'OWNER_ID' And bc.ID = :ID)
The other way depends on your definition of SOAP envelope to invoke a ScheduleService. That envelope, in my case, is created by a package handling all the conditions and decisions within PL/SQL where it is not a problem to change the TEMPLATE or whatever else. Sample envelope generated by the package is here:
<?xml version="1.0" encoding="utf-8"?>
<soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soap-env:Body>
<ns0:scheduleReport xmlns:ns0="http://xmlns.oracle.com/oxp/service/v2">
<ns0:scheduleRequest>
<ns0:dataModelUrl>http://some.url.of.bi.server:9502/xmlpserver/xdmeditor.jsp?f=/%7Euser/DPOP/DataModels/Otpr/Analyze_DataModel.xdm</ns0:dataModelUrl>
<ns0:jobLocale>hr-Hr</ns0:jobLocale>
<ns0:repeatCount>1</ns0:repeatCount>
<ns0:reportRequest>
<ns0:attributeCalendar>Gregorian</ns0:attributeCalendar>
<ns0:attributeFormat>pdf</ns0:attributeFormat>
<ns0:attributeLocale>hr-Hr</ns0:attributeLocale>
<ns0:attributeTemplate>Word_BI_PayListSQL_BLANK_7B.rtf</ns0:attributeTemplate>
<ns0:parameterNameValues>
<ns0:listOfParamNameValues>
<ns0:item>
<ns0:name>PASS_NUMBER</ns0:name>
<ns0:values>
<ns0:item>1</ns0:item>
</ns0:values>
</ns0:item>
<ns0:item>
<ns0:name>STEP</ns0:name>
<ns0:values>
<ns0:item>20</ns0:item>
</ns0:values>
</ns0:item>
</ns0:listOfParamNameValues>
</ns0:parameterNameValues>
<ns0:reportAbsolutePath>/~user/Payments/Reports/Work/PayListSQL_1_ver7_Report.xdo</ns0:reportAbsolutePath>
</ns0:reportRequest>
<ns0:scheduleBurstingOption>True</ns0:scheduleBurstingOption>
<ns0:startDate>2020-10-08T09:00:00+02:00</ns0:startDate>
<ns0:userJobName>PAYMENTS_2020-09_1</ns0:userJobName>
</ns0:scheduleRequest>
<ns0:userID>username</ns0:userID>
<ns0:password>password</ns0:password>
</ns0:scheduleReport>
</soap-env:Body>
</soap-env:Envelope>
I know that this will not solve your problem but hopefully it will give you an idea how to do it in your specific context. In my experience one of the two or a combination of both can solve almost every possible problem of the kind as in your question. Regards...
Mcode= Table.ReplaceValue(#"Renamed Columns2", each if Text.Contains([Rate_Card.Payee],"Financial Services") and [Externalidinvestorlevel] = null then null else [Rate_Card.Payee]
Error Message:
Expression.SyntaxError: Token RightParen expected.
I think maybe you want to do this
Mcode= Table.ReplaceValue(#"Renamed Columns2",
each [Rate_Card.Payee],
each if Text.Contains([Rate_Card.Payee],"Financial Services")
and [Externalidinvestorlevel] = null
then null else [Rate_Card.Payee]
,Replacer.ReplaceValue,{"Rate_Card.Payee"})
in #"Replaced Value"
I have a control file that loads text to oracle but i am trying to strip first 3 digits of Phone number example 1-469-428-5920 to 469-428-5920, please see below control file. what should be the syntax?
I keep getting error below, Please help
thanks
options (ERRORS=1000, SKIP=2)
load data
infile '/clients/vca2/data/API/ADHOC_LOAD/VCA_RP_Hospital_Website_Master_List_VCA.CSV'
replace
into table VCABARK_CDI_DV.RP_HOSPITAL_MASTER_LIST
fields terminated by '|'
OPTIONALLY ENCLOSED BY '"' AND '"'
trailing nullcols
(
HOSPITAL_EXT_NUMBER,
REGION,
HOSPITAL_NAME,
ADDRESS_1,
CITY ,
STATE,
POSTAL_CODE,
PHONE "CASE WHEN SUBSTR(:PHONE,1,2) = '1-' THEN ‘SUBSTR(:PHONE,3)’ ELSE ‘:PHONE’ END",
RCF_PHONE,
FAX ,
EMAIL ,
WEBSITE_CLASS,
DOMAIN,
SHORTNAME,
PMS,
INDICATOR_24_HOUR,
CARECLUB,
HOME_DELIVERY,
APPOINTMENT_CTA,
FREE_FIRST_EXAM,
AAHA ,
AAFP_MEMBER,
CAT_FRIENDLY,
FEAR_FREE ,
LOW_STRESS, E
VECCS,
FACEBOOK_URL,
GMB_URL ,
YELP_URL,
BOOK_URL,
REQUEST_URL,
HOURS_OPERATIONS_URL,
HD_URL_SUBDOMAIN,
HD_URL_ORIGINAL,
PET_PORTAL_URL,
AIS_CLINIC_ID,
AIS_TOKEN
)
You haven't said what error you are getting, but you should have quotes - curly or otherwise - within your case expression. Instead of:
PHONE "CASE WHEN SUBSTR(:PHONE,1,2) = '1-' THEN ‘SUBSTR(:PHONE,3)’ ELSE ‘:PHONE’ END",
use:
PHONE "CASE WHEN SUBSTR(:PHONE,1,2) = '1-' THEN SUBSTR(:PHONE,3) ELSE :PHONE END",
You could also just keep the last 12:
PHONE "SUBSTR(:PHONE, -12, 12)",
I am not sure what kind of statement I need in order for what i need to do. I would like to add a case statement after the case statement i currently have. Bellow is the case statement.
CASE
WHEN LOCOFF.EXT_SRV_POLYGON IN ('BOF', 'CDA', 'COL', 'DAC', 'GOS', 'KEL', 'KLF', 'LAG', 'LEC', 'MED', 'PUM', 'RIT', 'ROS', 'SAN', 'SPO')
THEN 'GAS'
WHEN LOCOFF.EXT_SRV_POLYGON IN ('CDC', 'COC', 'DAV', 'DPC', 'GRC', 'KEC', 'LCC', 'OTC', 'PAC', 'SAC', 'SPC')
THEN 'ELECTRIC'
ELSE 'MISSING'
END AS TYPE,
I would like to say if EXT_Distworktype is GC or GT and the TYPE is ELECTRIC,
GIVE ME TYPE THAT SAYS WRONG POLYGON OR IF THE EXT_DISTWORKTYPE is EC, ES, or ET and Type is GAS then give me a TYPE that say WRONG POLYGON.
here is my full query:
SELECT WO.WONUM AS "Work Order",
WO.LOCATION AS "Location",
WO.STATUS AS "Status",
WO.DESCRIPTION,
WO.ACTFINISH AS "Actual Finish",
WO.PARENT AS "Parent WO",
WO.WORKTYPE AS "Work Type",
CASE
WHEN WO.REPORTDATE IS NULL
THEN TO_DATE('29-JAN-15 00:00:00', 'DD-MON-YY HH24:MI:SS')
ELSE WO.REPORTDATE
END AS "Reported Date",
WO.SITEID AS "Site",
CASE
WHEN WO.ACTFINISH IS NULL
THEN GREATEST(TRUNC(TO_DATE(SysDate, 'DD-MON-YY HH24:MI:SS') - TO_DATE(WO.REPORTDATE, 'DD-MON-YY HH24:MI:SS'), 6), 0)
WHEN WO.STATUS NOT IN ('COMP')
THEN GREATEST(TRUNC(TO_DATE(SysDate, 'DD-MON-YY HH24:MI:SS') - TO_DATE(WO.REPORTDATE, 'DD-MON-YY HH24:MI:SS'), 6), 0)
WHEN WO.STATUS IN ('COMP')
THEN GREATEST(TRUNC(TO_DATE(WO.ACTFINISH, 'DD-MON-YY HH24:MI:SS') - TO_DATE(WO.REPORTDATE, 'DD-MON-YY HH24:MI:SS'), 6), 0)
END AS "Age",
WO.EXT_DISTWORKTYPE,
LOCOFF.EXT_OFFICE,
CASE
WHEN LOCOFF.EXT_SRV_POLYGON IN ('BOF', 'CDA', 'COL', 'DAC', 'GOS', 'KEL', 'KLF', 'LAG', 'LEC', 'MED', 'PUM', 'RIT', 'ROS', 'SAN', 'SPO')
THEN 'GAS'
WHEN LOCOFF.EXT_SRV_POLYGON IN ('CDC', 'COC', 'DAV', 'DPC', 'GRC', 'KEC', 'LCC', 'OTC', 'PAC', 'SAC', 'SPC')
THEN 'ELECTRIC'
ELSE 'MISSING'
END AS TYPE,
LOCOFF.EXT_STATECODE,
WO.OWNERGROUP,
WO.EXT_JOBCODE
FROM LOCATIONS LOCOFF
RIGHT JOIN WORKORDER WO
ON WO.LOCATION = LOCOFF.LOCATION
WHERE WO.STATUS NOT IN ('CLOSE', 'WAIV', 'CAN', 'REJ', 'REVOKED')
AND LOCOFF.SITEID = 'OPS'
AND WO.EXT_JOBCODE NOT LIKE 'A%' AND WO.E`enter code here`XT_JOBCODE NOT LIKE 'B%'
AND WO.EXT_JOBCODE NOT IN ('K008','K009','I006','I007','I008');
You can nest case expressions if you only want to modify the existing column value (rather than adding a separate column with the 'wrong polygon' message):
CASE
WHEN LOCOFF.EXT_SRV_POLYGON IN ('BOF', 'CDA', 'COL', 'DAC', 'GOS', 'KEL', 'KLF', 'LAG', 'LEC', 'MED', 'PUM', 'RIT', 'ROS', 'SAN', 'SPO')
THEN
CASE
WHEN WO.EXT_DISTWORKTYPE IN ('EC', 'ES', 'ET')
THEN 'WRONG POLYGON'
ELSE 'GAS'
END
WHEN LOCOFF.EXT_SRV_POLYGON IN ('CDC', 'COC', 'DAV', 'DPC', 'GRC', 'KEC', 'LCC', 'OTC', 'PAC', 'SAC', 'SPC')
THEN
CASE
WHEN WO.EXT_DISTWORKTYPE IN ('GC', 'GT')
THEN 'WRONG POLYGON'
ELSE 'ELECTRIC'
END
ELSE 'MISSING'
END AS TYPE,
Quick SQL Fiddle demos with the same made-up data; your original case and this nested case, which gives:
EXT EX TYPE
--- -- -------------
BOF GC GAS
CDA GT GAS
SPO ES WRONG POLYGON
CDC EC ELECTRIC
COC ET ELECTRIC
SPC GC WRONG POLYGON
This is a bit simpler than trying to do a second step that interprets the TYPE value, because you can't refer to a column alias in the same level of query; you would need to make your existing query into an inline view.
Will an extra case not do it?
CASE
WHEN WO.EXT_DISTWORKTYPE IN ('GC', 'GT')
AND LOCOFF.EXT_SRV_POLYGON IN ('CDC', 'COC', 'DAV', 'DPC', 'GRC', 'KEC', 'LCC', 'OTC', 'PAC', 'SAC', 'SPC') --electronic
THEN 'WRONG POLYGON'
CASE
WHEN WO.EXT_DISTWORKTYPE IN ('EC', 'ES', 'ET' )
AND LOCOFF.EXT_SRV_POLYGON IN ('BOF', 'CDA', 'COL', 'DAC', 'GOS', 'KEL', 'KLF', 'LAG', 'LEC', 'MED', 'PUM', 'RIT', 'ROS', 'SAN', 'SPO') --gas
THEN 'WRONG POLYGON'
ELSE 'MSSING'
END AS YOURANSWER,
You could do an case within a case
CASE
WHEN (TRUE) THEN
CASE WHEN (true) THEN 'a' ELSE 'b' END
ELSE
'A'
END
I have the folllowing perl code:
my $dbo_prd = DBI->connect(
"dbi:Oracle:host=$db_srv_prd;port=1521;sid=$db_sid_prd",
$db_user_prd,
$db_pass_prd
) || warn &senderror("TREE_STRUCTURE.Could not connect to $db_srv_prd: $DBI::errstr\n");
print "\n\nconnection:" . $dbo_prd . "\n";
if ($dbo_prd != 1){
print "in prod prepare\n\n";
my $query1_prd = $dbo_prd->prepare(
"INSERT INTO CMSV2.CMS_INBOX VALUES (
'vmsdk', (SELECT SYSDATE from DUAL), 'NODE_TREE_UPDATE',?,?,?,?,NULL,NULL
)"
) || warn &senderror("TREE_STRUCTURE.Could not prepare to $db_srv_prd: $DBI::errstr\n");
}
The issues that I'm having is that I thought if the connect didn't work it would set the connection $dbo_prd to undef but it is setting it to 1? This is not what the documentation states anywhere.
The connection is being printed out as "1" when it fails and a hash which it is supposed to if it succeeds.
You have a precedence error here:
|| warn
That is assigning the return value of warn to your variable when the connect fails. Use this instead:
or warn
(warn, like print, returns 1 if successful.)
Always use the low precedence and/or for flow control between what are essentially different expressions; only use the high precedence &&/|| within what is essentially all one expression (e.g. my $foo = $bar eq 'a' || $bar eq 'b').