Hope I can explain the problem I'm having trouble with.
I have to write a stepwise methodology using pseudocode/SQL query to auto generate a list of products/items with low stock/expiry from the inventory database.The list must be updated at 12 a.m. daily.
I tried this
CREATE EVENT IF NOT EXISTS update_table
ON SCHEDULE EVERY 1 DAY STARTS '2022-05-22 00:00:00'
ON COMPLETION PRESERVE ENABLE
Do
Select inventory.products from inventory where inventory.stocks <
inventory.required_stocks.
Your stated requirement is to run some sort of report very soon after the beginning of each calendar day.
The next question you must answer is this: What will you do with that report? Will you simply drop it into "low_stock" table someplace in your database? Will you format it into an email message and send it to your purchasing department? It will be difficult to make "pseudocode" for your requirement without first analyzing the overall business process you intend to enhance.
Various RDBMS systems have ways of doing scheduled things at particular times of day. You've shown the EVENT setup provided by MariaDB / MySQL. SQL Server has their "Jobs" system. postgreSQL has the pg_cron extension. Yo
The thing is, you can't just do SELECT operations from within these scheduled database actions: the result sets have noplace to go from that context. You can do CREATE TABLE midnight_run AS SELECT whatever ... to place the results in a table. But then the results are in another table.
If you want to get the results out of the DBMS, you'll need a UNIXish cron job or a Windowsish scheduled task running an appropriate application at midnight each day.
Pro tip Do your best to avoid scheduling stuff for precisely midnight. Many things run then. If you wait until a couple of minutes after the hour, your code is less likely to contend with other midnight code.
I have following SQL query in Data Flow, Control flow of SSIS package and I want to limit records by cutting off point, and that cut off point is current day/date from system. So, it should only display past records, not including todays. So, I think I need to use the specific field (which is date field - in the query its called 'FinalCloseDate' and compare with current system date and tell it to only to pull the records (perhaps < todays date) that happened before today or current system day.
Add
AND dbo.Producthit.FinalCloseDate < CAST(GETDATE() AS DATE)
to your WHERE clause.
I'm running a series of reports where time window called in query is rolling, and individual per report.. Some reports look 400 days back, others look 10 weeks back, while others again look at -40days/+80days... and so on - many options.
All reports are scheduled in daily or weekly runs, meaning setting prompts will require a manual reset of prompt for every instance through the scheduler. Not optimal.
I know the universe designer can design specific filters to drag into the queries using the query designer, but with so many different options, I find it a bit of an issue that the universe designer should create specific filters for these specific purposes, adding a vast number of specific filters intended for specific use to various universes.
I'm after an option where it is possible to assign a calculation to a date field, which stay fixed for the purpose of the report for every scheduled instance.
For instance, looking at invoice date from 400 days before today and onwards would look like Where DIM_TIME_INV.DAY_DAY >= sysdate -400 - This I can hardcode into the SQl of the specific report, and it will stay through the scheduler and roll 1 day for every day the report is run. But if I decide to make a change in the query elements, the SQl is screwed, and I will have to manually add the modification to the SQL again.
I found an article reg. the use of #Prompt and would ask universe designer to try and sandbox this in our version of BO.
While I'm being impatient, I try myself using following code based on example 4 from linked article.
SELECT
#select('DIM_TIME_INV.DAY_DAY') >= sysdate -(#prompt('Invoiced, days before today:','N',[DIM_TIME_INV.DAY_DAY],mono,free))
FROM
DIM_TIME_INV
Testing the SQL gives following error:
ORA-00936
SAP kba 2054721
The whole idea is to have a flexible yet consistent dimension that will calculate every time the report is run, without losing the code whenever new items are added to the report.
Does anyone know of a way to use the #Prompt in SQL for SAP WEBI 4.2? - Or any other way to have 'flexible' time dimensions where it is possible to set a from-date or to-date independently or even a range, without having universe designer creating a s**t-load of filters and dump in various universes.
Thanks // C
With regard to your example code, I think you're on the right track but your syntax has some issues:
SELECT
#select('DIM_TIME_INV.DAY_DAY') >= sysdate -(#prompt('Invoiced, days before today:','N',[DIM_TIME_INV.DAY_DAY],mono,free))
FROM
DIM_TIME_INV
First, both #Select and #Prompt must refer to universe objects, not columns. The syntax for both is: class name\object name. Assuming that the DIM_TIME_INV.DAY_DAY is associated with a universe object named Day Day in a class named Dim Time, the above code should be:
SELECT
#select('Dim Time\Day Day') >= sysdate -(#prompt('Invoiced, days before today:','N','Dim Time\Day Day',mono,free))
FROM
DIM_TIME_INV
Also note that the object reference in the #prompt call is delimited by single quotes, not brackets.
Next, I'm assuming that DAY_DAY is a date field. Its reference in the #prompt call would cause the prompt to display a list of values, sourced from DAY_DAY. But you want a numeric value from the prompt, not a date, so I would just leave that out, which will let the users enter a numeric value:
SELECT
#select('Dim Time\Day Day') >= sysdate -(#prompt('Invoiced, days before today:','N',,mono,free))
FROM
DIM_TIME_INV
Next, even with this corrected syntax, there will be an issue using this code as you have it. A good way to debug #prompt issues is to view the SQL in the WebI report after you get the error -- the SQL will show the rendered result, with all functions (#select and #prompt) expanded. For the above, you might get SQL like:
SELECT
DIM_TIME_INV.DAY_DAY >= sysdate -(400)
FROM
DIM_TIME_INV
This, of course, is invalid - you can't have a condition in the SELECT clause. If this is truly intended to be a condition (which I think it is, based on your objective), then it should be a predefined condition rather than a dimension.
With that said, I think you're on the right track for what you want to do. With the above corrections, you would have a predefined condition that you could drop into reports, which would enable the users to select the starting period (by number of days ago) for the report. You could create additional prompts with different logic, ex:
#select('Dim Time\Day Day') >= sysdate -(#prompt('Invoiced, weeks before today:','N',,mono,free) * 7)
or
#select('Dim Time\Day Day')
BETWEEN sysdate - #prompt('Starting days ago:','N',,mono,free)
AND sysdate - #prompt('Ending days ago:','N',,mono,free)
I am building a Monthly License Report for our IT department and it receives a list of License information in Euro's. I have an XML feed that provides Exchange rate data daily but the job will only be set to run once a month.
I have a conditional split set up in my SSIS package that splits off the USD exchange rate and discards everything else.
What I have left to do is to return only the exchange rate for the 1st of every month, I don't need every day just the day the report runs.
Is there an SSIS expression that will return only that line out of the XML feed?
Or is there an SQL-T Script that will return only the first month data?
Date format is MM/DD/YYYY, I have a sequence of Derived columns that creates a [DateKey] for my [DIMDate] that is formatted as YYYYMMDD.
you have a dim date table?
select datekey
from dimdate
where day(datefield) = 1
That will give you the first day of every month that is in your dim date table. Inner join your existing select to this (inner join here will effectively function as a filter). Something along the lines of this
inner join dimdate on dimdate.datefield = mainquery.datefield and day(dimdate.datefield) = 1
For the XML posted, this Xpath query will bring you the first element (group of currencies for the first date):
'//Cube/Cube[1]/.'
if you need to bring only the USD part then:
'//Cube/Cube[1]/Cube[#currency="USD"]/.'
In SSIS you can apply Xpath transformations through XML task in control flow.
I actually found a solution for this online that was a little simpler. I have built it, tested it and implemented.
I had to put my foot down with our Network guy and request an outside connection to the internet in order to make it happen (something he wasn't happy about doing) but once we worked that out it worked like a charm.
Here is the link to the site that I used.
http://technet.microsoft.com/en-us/sqlserver/ff686773.aspx
Thank you everyone for all the great ideas. I'm sure they will come in handy for other projects.
I need to create a SSRS report where the user specifies the start and end date (e.g. March 2012 to July 2012) and the result is a report with the following headings:
User Department Product Mar-12 Apr-12 May-12 Jun-12 Jul-12
The dates are stored in a datetime column (e.g.2012-06-11 14:48:04.787) in my SQL table which I'm using to build the time-series report.
Do I need to convert/transpose my SQL table first? Or should I be processing this in SSRS?
Your advice is much appreciated!
Based on your question it appears all your dates are in a single datetime column and your trying to display them, formatted as a month, in a single report with the report columns grouped and renamed based on the month. This is a pivot and I don't think you can do that within SSRS. The dataset will already need to be pivoted by the time SSRS gets it.
So, to me this sounds like something you'll have to do both pre and post SSRS. I did a similar report using days of the month. You can see the winning answer here. as opposed to months of the year.
Thinking through your logice, I think you'll probably have to build the query with the pivot and then send to SSRS. On the SSRS side you need 12 columns for all 12 months and then put some logic to hide the ones that don't get data. Your original pivot will need to be smart enough to pass the empty months so SSRS doesn't error out. The end result will appear the same but needs a lot of pre-thought and design effort up front.
You do the processing using SSRS - you would design it in the GUI editor(BIDS ) , and you can customize things using the VBasic code also(i.e, dates and logic)
Looks like you need an intro, I really recommend this video