Schedule sql query

Dear all,
I need to schedule some queries (audit related) running at certain time of the day. I can do this using unix shell script.
can this be done using oracle scheduler - just running a simple sql query and not using pl/sql block
for ex: 4.1.     select * from dba_stmt_audit_opts where audit_option like '%TABLE'
kind regards
thanks
SL

You can not schedule a select statement using dbms scheduler. It should be either pl/sql block or os script.
Edited by: oracle.beginner on Apr 15, 2010 5:23 AM

Similar Messages

  • How to schedule a sql query on Windows

    Hi Experts;
    I got a sql query that I need to put on schedule, (on windows) in order it runs everyday at specific time.
    I got the query, but I want to know the next:
    How to invoke SQLPlus from this query? Explain how to include the user/password@SID
    Do I need to create this query in a .bat file?
    Also I want to know, how to send the results to an email?
    Thanks for your help.
    Regards
    Al

    I would suggest to put your sql query to a separate file and spool the result to a concrete file:
    query.sql:
    spool query.lst
    select * from emp;
    spool off;create a bat file query.bat:
    sqlplus <connection> @query.sql
    ...work with content of query.lst, send mail etcThen schedule your bat file with Windows scheduler
    The above could be simplified with JavaScript or VBScript
    Thanks.

  • Issue with SQL Query with Presentation Variable as Data Source in BI Publisher

    Hello All
    I have an issue with creating BIP report based on OBIEE reports which is done using direct SQL. There is this one report in OBIEE dashboard, which is written using direct SQL. To create the pixel perfect version of this report, I am creating BIP data model using SQL Query as data source. The physical query that is used to create OBIEE report has several presentation variables in its where clause.
    select TILE4,max(APPTS), 'Top Count' from
    SELECT c5 as division,nvl(DECODE (C2,0,0,(c1/c2)*100),0) AS APPTS,NTILE (4) OVER ( ORDER BY nvl(DECODE (C2,0,0,(c1/c2)*100),0))  AS TILE4,
    c4 as dept,c6 as month FROM 
    select sum(case  when T6736.TYPE = 'ATM' then T7608.COUNT end ) as c1,
         sum(case  when T6736.TYPE in ('Call Center', 'LSM') then T7608.CONFIRMED_COUNT end ) as c2,
         T802.NAME_LEVEL_6 as c3,
         T802.NAME_LEVEL_1 as c4,
         T6172.CALENDARMONTHNAMEANDYEAR as c5,
         T6172.CALENDARMONTHNUMBERINYEAR as c6,
         T802.DEPT_CODE as c7
    from
         DW_date_DIM T6736 /* z_dim_date */ ,
         DW_MONTH_DIM T6172 /* z_dim_month */ ,
         DW_GEOS_DIM T802 /* z_dim_dept_geo_hierarchy */ ,
         DW_Count_MONTH_AGG T7608 /* z_fact_Count_month_agg */
    where  ( T802.DEpt_CODE = T7608.DEPT_CODE and T802.NAME_LEVEL_1 =  '@{PV_D}{RSD}' 
    and T802.CALENDARMONTHNAMEANDYEAR = 'July 2013'
    and T6172.MONTH_KEY = T7608.MONTH_KEY and T6736.DATE_KEY = T7608.DATE_KEY
    and (T6172.CALENDARMONTHNUMBERINYEAR between substr('@{Month_Start}',0,6)  and substr('@{Month_END}',8,13))
    and (T6736.TYPE in ('Call Center', 'LSM')) )
    group by T802.DEPT_CODE, T802.NAME_LEVEL_6, T802.NAME_LEVEL_1, T6172.CALENDARMONTHNAMEANDYEAR, T6172.CALENDARMONTHNUMBERINYEAR
    order by c4, c3, c6, c7, c5
    ))where tile4=3 group by tile4
    When I try to view data after creating the data set, I get the following error:
    Failed to load XML
    XML Parsing Error: mismatched tag. Expected: . Location: http://172.20.17.142:9704/xmlpserver/servlet/xdo Line Number 2, Column 580:
    Now when I remove those Presention variables (@{PV1}, @{PV2}) in the query with some hard coded values, it is working fine.
    So I know it is the PV that's causing this error.
    How can I work around it?
    There is no way to create equivalent report without using the direct sql..
    Thanks in advance

    I have found a solution to this problem after some more investigation. PowerQuery does not support to use SQL statement as source for Teradata (possibly same for other sources as well). This is "by design" according to Microsoft. Hence the problem
    is not because different PowerQuery versions as mentioned above. When designing the query in PowerQuery in Excel make sure to use the interface/navigation to create the query/select tables and NOT a SQL statement. The SQL statement as source works fine on
    a client machine but not when scheduling it in Power BI in the cloud. I would like to see that the functionality within PowerQuery and Excel should be the same as in Power BI in the cloud. And at least when there is a difference it would be nice with documentation
    or more descriptive errors.
    //Jonas 

  • How do I query off a pl/sql funtion that returns an sql query in apex.

    I built a function that a returns a good sql query. I verified the out put of my function works when I manually entered into the SQL Commands.
    Is it possible to build a report off of this query. My attempt failed with the following error.
    failed to parse SQL query:
    ORA-00933: SQL command not properly ended
    I am sure the query generated is correct. Like I mentioned, I was able to use in the sql command succesfully.
    Thanks,
    Edited by: greich on Nov 21, 2008 10:55 AM

    This is the code for my function:
    create or replace function f_act_proj_sched (i_facility varchar2, i_date varchar2, i_shift varchar2)
    Return varchar2 is
    o_query Varchar2 (32000);
    BEGIN
    -- function that will return the query used in main application
    o_query := o_query || 'SELECT act_proj.DESTINATION,';
    o_query := o_query || ' act_proj.SHIPPING_DATE,';
    o_query := o_query || ' act_proj.SHIFT,';
    o_query := o_query || ' act_proj.JOB_CLASS_GROUPING,';
    o_query := o_query || ' act_proj."Actual Units",';
    o_query := o_query || ' act_proj."Projected Units",';
    o_query := o_query || ' act_proj."Actual Hours",';
    o_query := o_query || ' act_proj."Projected Hours",';
    o_query := o_query || ' NVL (sched."Sched_Hours", 0)';
    o_query := o_query || ' "Scheduled Hours"';
    o_query := o_query || ' From (SELECT P.DESTINATION,';
    o_query := o_query || ' P.SHIPPING_DATE,';
    o_query := o_query || ' P.JOB_CLASS_GROUPING,';
    o_query := o_query || ' P.SHIFT,';
    o_query := o_query || ' NVL (FACILITY_STATS.WORK_UNITS, 0) "Actual Units",';
    o_query := o_query || ' NVL (P.WORK_UNITS, 0) "Projected Units",';
    o_query := o_query || ' NVL (CASE FACILITY_STATS.JOB_CLASS_GROUPING';
    o_query := o_query || ' WHEN ''Backhaul''';
    o_query := o_query || ' THEN Facility_stats.work_units';
    o_query := o_query || ' / Goal_destination_shift.backhauler_goal';
    o_query := o_query || ' WHEN ''Selector''';
    o_query := o_query || ' THEN Facility_stats.work_units';
    o_query := o_query || ' / Goal_destination_shift.selector_goal';
    o_query := o_query || ' WHEN ''Common''';
    o_query := o_query || ' THEN Facility_stats.work_units';
    o_query := o_query || ' / Goal_destination_shift.backhauler_goal';
    o_query := o_query || ' WHEN ''Lift''';
    o_query := o_query || ' THEN Facility_stats.work_units';
    o_query := o_query || ' / Goal_destination_shift.forklift_goal';
    o_query := o_query || ' ELSE Facility_stats.work_units';
    o_query := o_query || ' END, 0) "Actual Hours",';
    o_query := o_query || ' CASE P.JOB_CLASS_GROUPING';
    o_query := o_query || ' WHEN ''Backhaul''';
    o_query := o_query || ' THEN P.work_units';
    o_query := o_query || ' / Goal_destination_shift.backhauler_goal';
    o_query := o_query || ' WHEN ''Selector''';
    o_query := o_query || ' THEN P.work_units';
    o_query := o_query || ' / Goal_destination_shift.selector_goal';
    o_query := o_query || ' WHEN ''Common''';
    o_query := o_query || ' THEN P.work_units';
    o_query := o_query || ' / Goal_destination_shift.backhauler_goal';
    o_query := o_query || ' WHEN ''Lift''';
    o_query := o_query || ' THEN P.work_units' ;
    o_query := o_query || ' / Goal_destination_shift.forklift_goal';
    o_query := o_query || ' ELSE P.work_units';
    o_query := o_query || ' END "Projected Hours"';
    o_query := o_query || ' FROM STAFFING.FACILITY_STATS,';
    o_query := o_query || ' STAFFING.FACILITY_STATS P,';
    o_query := o_query || ' STAFFING.GOAL_DESTINATION_SHIFT';
    o_query := o_query || ' WHERE (GOAL_DESTINATION_SHIFT.DESTINATION = P.DESTINATION)';
    o_query := o_query || ' AND (GOAL_DESTINATION_SHIFT.SHIFT_FLAG = P.SHIFT)';
    o_query := o_query || ' AND (FACILITY_STATS.DESTINATION(+) = P.DESTINATION)';
    o_query := o_query || ' AND (FACILITY_STATS.SHIPPING_DATE(+) = P.SHIPPING_DATE)';
    o_query := o_query || ' AND (FACILITY_STATS.JOB_CLASS_GROUPING(+) = P.JOB_CLASS_GROUPING)';
    o_query := o_query || ' AND (FACILITY_STATS.SHIFT(+) = P.SHIFT)';
    o_query := o_query || ' AND (P.PROJ_ACTUAL_FLAG = ''P'')';
    o_query := o_query || ' AND (FACILITY_STATS.PROJ_ACTUAL_FLAG(+) = ''A'')';
    o_query := o_query || ' AND P.DESTINATION = ' || i_facility;
    o_query := o_query || ' AND P.SHIPPING_DATE = ' || i_date;
    o_query := o_query || ' AND (case';
    o_query := o_query || ' when to_number(' || i_shift || ') != -1';
    o_query := o_query || ' Then P.SHIFT';
    o_query := o_query || ' Else 1';
    o_query := o_query || ' end =';
    o_query := o_query || ' case';
    o_query := o_query || ' when to_number(' || i_shift || ') != -1';
    o_query := o_query || ' Then to_number(' || i_shift || ')';
    o_query := o_query || ' Else 1';
    o_query := o_query || ' end)) act_proj,';
    o_query := o_query || ' (SELECT Destination,';
    o_query := o_query || ' schedule_date,';
    o_query := o_query || ' shift,';
    o_query := o_query || ' job_class_grouping,';
    o_query := o_query || ' SUM ("Sched_Hours") "Sched_Hours"';
    o_query := o_query || ' FROM (';
    -- Loop to create bucket query
    for idx in 1..20 Loop
    o_query := o_query || '(SELECT EMP_SCHEDULE.EMPLOYEE_ID,';
    o_query := o_query || ' EMP_SCHEDULE.SCHEDULE_DATE,';
    o_query := o_query || ' EMP_SCHEDULE.DESTINATION,';
    o_query := o_query || ' EMP_SCHEDULE.SHIFT, ';
    o_query := o_query || idx || ' "Bucket_number",';
    o_query := o_query || ' Bucket' || idx || '_class "bucket class",';
    o_query := o_query || ' JOB_CLASS_GROUPING,';
    o_query := o_query || ' NVL (EMP_SCHEDULE.BUCKET' || idx || '_SCHED_HRS, 0) "Sched_Hours"';
    o_query := o_query || ' FROM STAFFING.EMP_SCHEDULE,';
    o_query := o_query || '(SELECT DISTINCT FACILITY_CLASS_BUCKET.JOB_CLASS_GROUPING,';
    o_query := o_query || ' FACILITY_CLASS_BUCKET.DESTINATION';
    o_query := o_query || ' FROM STAFFING.FACILITY_CLASS_BUCKET';
    o_query := o_query || ' WHERE (FACILITY_CLASS_BUCKET.BUCKET_ID = ' || idx || ')) A';
    o_query := o_query || ' Where A.Destination = EMP_SCHEDULE.DESTINATION';
    o_query := o_query || ' and EMP_SCHEDULE.DESTINATION = ' || i_facility;
    o_query := o_query || ' and EMP_SCHEDULE.SCHEDULE_DATE = ' || i_date;
    o_query := o_query || ' AND (case';
    o_query := o_query || ' when to_number(' || i_shift || ') != -1';
    o_query := o_query || ' Then EMP_SCHEDULE.SHIFT';
    o_query := o_query || ' Else 1';
    o_query := o_query || ' end =';
    o_query := o_query || ' case';
    o_query := o_query || ' when to_number(' || i_shift || ') != -1';
    o_query := o_query || ' Then to_number(' || i_shift || ')';
    o_query := o_query || ' Else 1';
    o_query := o_query || ' end))';
    if idx < 20
    THEN
    o_query := o_query || ' UNION ';
    Else
    o_query := o_query || ')';
    End if;
    END Loop;
    o_query := o_query || ' GROUP BY Destination,';
    o_query := o_query || ' schedule_date,';
    o_query := o_query || ' shift,';
    o_query := o_query || ' job_class_grouping) Sched';
    o_query := o_query || ' WHERE (act_proj.DESTINATION = sched.DESTINATION(+))';
    o_query := o_query || ' AND (act_proj.SHIPPING_DATE = sched.SCHEDULE_DATE(+))';
    o_query := o_query || ' AND (act_proj.SHIFT = sched.SHIFT(+))';
    o_query := o_query || ' AND (act_proj.JOB_CLASS_GROUPING = sched.JOB_CLASS_GROUPING(+))';
    o_query := o_query || ' ORDER BY SHIFT,';
    o_query := o_query || ' job_class_grouping';
    Return (o_query);
    END;

  • Default value of date picker not showing in sql query

    Hi,
    I have a tabular form page with a query similar to the following:
    select emp_name, salary from emp_table where trunc(hire_date)=trunc(to_date(:P42_START_DATE))
    where P42_START_DATE is the name of a date picker item.
    I set the source type of the date picker to be "Only when current value in session state is null" and the value to be "select trunc(next_day(sysdate,'MON')-7) from dual;" - basically the monday of the current week. I set the sequence of the date picker to be 5, and the sequence of the region to be 10. Now, when I open this page, no data gets pulled. I checked the page source, and the value of the date picker input is being set to "17-NOV-2008", but it somehow isn't reflected in the sql query.
    Data does get retrieved if I manually set the date in the date picker, but I'd like it to default to the monday of the current week. What am I doing wrong?
    Thanks

    nope, still same problem.
    I used javascript alerts to help debug, and here might be some useful information.
    The computation to set the value of :P42_START_DATE is set to run "before header", but when I put this following javascript in the header:
    <script language="javascript">
    var c = $v('P42_START_DATE');
    alert(c);
    </script>
    the alert box is blank (ie :P42_START_DATE is empty). Putting the same exact script in the footer gives 24-Nov-2008 in the alert box. Now, the SQL query is run sometime after the first alert and before the second alert, I believe. Why would the value of :P42_START_DATE not be getting set at the correct time?
    P42_START_DATE is a date picker item that belongs to the region SCHEDULE (which is where the sql query is). I set the sequence of the region to 10, and the sequence of the date picker and computation to be 5 and 6. Even so, does this mean that the sql query is executing before the call to the computation, because the region needs to be created before any items can be created that belong to the region?

  • How to aggregate data in SQL Query

    Hi,
    I have Table1 field1 and field2. Combination of these fields form the key of this table.
    Next I have Table2 with field3 and field4. field1 is the unique key for this table.
    My query is:
    select T2.field4||','||T1.field2 from T1 inner join T2 on T1.field1 = T2.field3;
    In the result I want to aggregate the data by T2.field4
    How do I that? Please help
    Thanks in advance,
    Raja

    How to aggregate data in SQL Query By using aggregate functions and group by:
    SQL> select object_type, count(*), sum(decode(status,'VALID',0,1)) inv_obs
      2  from all_objects
      3  group by object_type;
    OBJECT_TYPE                     COUNT(*)              INV_OBS
    CONSUMER GROUP                         2                    0
    INDEX PARTITION                      970                    0
    TABLE SUBPARTITION                    14                    0
    SEQUENCE                             226                    0
    SCHEDULE                               1                    0
    TABLE PARTITION                      349                    0
    PROCEDURE                             21                    0
    OPERATOR                              57                    0
    WINDOW                                 2                    0
    PACKAGE                              313                    0
    PACKAGE BODY                          13                    0
    LIBRARY                               12                    0
    PROGRAM                                9                    0
    INDEX SUBPARTITION                   406                    0
    LOB                                    1                    0
    JAVA RESOURCE                        771                    0
    XML SCHEMA                            24                    0
    JOB CLASS                              1                    0
    TRIGGER                                1                    0
    TABLE                               2880                    0
    INDEX                               4102                    0
    SYNONYM                            20755                  140
    VIEW                                3807                   72
    FUNCTION                             226                    0
    WINDOW GROUP                           1                    0
    JAVA CLASS                         16393                    0
    INDEXTYPE                             10                    0
    CLUSTER                               10                    0
    TYPE                                1246                    0
    EVALUATION CONTEXT                     1                    0

  • How to run sql query in bat file in task schedular at every 10 seconds

    This is my sql script :
    DECLARE @countRows INT,
    @currDate DATE,
    @checkForTasks INT,
    @created_by_id INT,
    @gst_ID int;
    SET @currDate = Getdate()
    SET @countRows = (SELECT Count(*)
    FROM [dbo].[sd_gst_effective_table]
    WHERE isapplied = 0)
    IF @countRows > 0
    -- Check for those GST''s who are not applied yet : if they are greater than 0 then perform next task
    BEGIN
    SET @checkForTasks = (SELECT Count(*)
    -- Check is current date equals to task date or not
    FROM [dbo].[sd_gst_effective_table]
    WHERE effect_date = @currDate AND isapplied = 0)
    IF @checkForTasks > 0
    -- If current date = task date then perform this task
    BEGIN
    SET @created_by_id = (SELECT TOP 1 createdby FROM [dbo].[sd_gst_effective_table] WHERE effect_date = @currDate AND isapplied = 0)
    SET @gst_ID = (SELECT gst_id FROM [dbo].[sd_gst_effective_table] WHERE effect_date = @currDate AND isapplied = 0)
    -- STEP 1 :: InActivate the existing GST according to createdbyID
    UPDATE sd_gst_rate
    SET isactive = 0,
    inactivedate = Getdate()
    WHERE isactive = 1
    AND createdby = @created_by_id
    -- STEP 2 :: Activate the New GST according to implementation date and gstID
    UPDATE sd_gst_rate
    SET isactive = 1,
    activedate = Getdate()
    WHERE id = @gst_ID
    -- STEP 3 :: Inactivate the applied GST from sd_gst_effective_table
    UPDATE [dbo].[sd_gst_effective_table] SET isApplied = 1 WHERE gst_id = @gst_ID
    END
    END
    DECLARE @Text AS VARCHAR(100)
    DECLARE @Cmd AS VARCHAR(100)
    DECLARE @value nvarchar(1000);
    SET @value = (SELECT CONVERT(TIME,GETDATE()) AS HourMinuteSeconds);
    SET @Text = 'File Writed ' + @value
    SET @Cmd ='echo ' + @Text + ' > E:\AppTextFile.txt'
    EXECUTE Master.dbo.xp_CmdShell @Cmd
    This is resided in videos folder of windows , i have created a task schedular in windows 8.1 to run daily at every 10 seconds , but it is not working ... Please tell me how to deal with it.
    Please note : This sql query is running perfectly in sql server. Query have no errors. Please check whats wrong with my time schedular. I just want my schedular to run every 10 seconds regardless of date.

    Hi Emad,
    Is your script in a ".sql" file? May I know how you configure the schedule task action?
    Since you didn't mention how you configure the schedule task, can you confirm you have followed the below step correctly?
    Save your script in a ".sql" file.
    Create a ".bat" file and call the sql file above inside with
    sqlcmd.exe, you can reference
    here.
    Configure a schedule task to run the ".bat" file in a certain interval.
    Have you tried to run the script in you bat file in a standalone commandline window? Please post the script in your bat file, It can help to diagnose the issue.
    If you have any question, feel free to let me know.
    Eric Zhang
    TechNet Community Support

  • Send mail weekly with spreadsheet generated from SQL query

    I have a requirement which is as follows
    1 - Run an SQL query to generate a report (lets say select * from emp;)
    2 - Save the report output in a excel (csv/xls/xlsx) and send as a mail attachment.
    3 - Schedule this procedure as a weekly job.
    #3 Job scheduling is simple and can be done but i am stuck with #1 and #2. How can I go about this?

    Hello,
    the FAQ of this forum space has a whole section about Re: 5. How do I read or write an Excel file?
    And as Karthik said: you can search this forum, all of your question where asked and answered many times.
    Regards
    Marcus

  • How do i get a output in CSV of a SQL query executed via SQL Command prompt

    Hi All,
    I have a question with reference to SQL command prompt. I have a sql query which runs properly and gives proper execution in SQL Management console in GUI.
    This report is used to pull the free disk space report of our servers
    As i want to schedule it as a report so i want to script it to run via SQL command prompt. I made the script and it works fine if i enter it in SQL command prompt. When i try to extract the output to a CSV File it fails. Below is the details of the command
    i am using to query to pull the data. Can anyone help me in getting the output of this query in SQL command prompt.
    sqlcmd -W -s , -S Servers FQDN
    use operationsmanager
    Go
    Query:"select Path, InstanceName, SampleValue 
    from PerformanceDataAllView pdv with (NOLOCK)
    inner join PerformanceCounterView pcv on pdv.performancesourceinternalid = pcv.performancesourceinternalid
    inner join BaseManagedEntity bme on pcv.ManagedEntityId = bme.BaseManagedEntityId
    where SampleValue < '20' and CounterName='% Free Space' and TimeSampled > '2014-08-06 11:00:00.00'
    order by countername, timesampled" -s "," -o "C:\DataSqlCmd.csv"
    Go
    When i enter the command without the quotes when the query is starting and ending and also without the output command (-s "," -o "C:\DataSqlCmd.csv") it is working and shows the output in the command prompt. Below is the screen shot for
    your reference.
    Due to security reasons i have to erase the server names:
    But when i add the line to extract the output ( -s "," -o "C:\DataSqlCmd.csv") It gives me this error:
    The exact command would be:
    sqlcmd -W -s , -S CINMLVSCOM01.e2klab.ge.com
    use operationsmanager
    Go
    "select Path, InstanceName, SampleValue 
    from PerformanceDataAllView pdv with (NOLOCK)
    inner join PerformanceCounterView pcv on pdv.performancesourceinternalid = pcv.performancesourceinternalid
    inner join BaseManagedEntity bme on pcv.ManagedEntityId = bme.BaseManagedEntityId
    where SampleValue < '20' and CounterName='% Free Space' and TimeSampled > '2014-08-06 11:00:00.00'
    order by countername, timesampled" -s "," -o "C:\DataSqlCmd.csv" -h-1
    Go
    saying the syntax is not correct or some thing as per the below screenshot.
    Can any one please help. Below is just the query whi i use to get the output in SQL management studio.
    Can any one make a command for the below quer so i can directly execute and test for getting the output.
    select Path, InstanceName, SampleValue 
    from PerformanceDataAllView pdv with (NOLOCK)
    inner join PerformanceCounterView pcv on pdv.performancesourceinternalid = pcv.performancesourceinternalid
    inner join BaseManagedEntity bme on pcv.ManagedEntityId = bme.BaseManagedEntityId
    where SampleValue < '20' and CounterName='% Free Space' and TimeSampled > '2014-08-06 11:00:00.00'
    order by countername, timesampled
    Gautam.75801

    Can you try the below query?
    select Path, InstanceName, SampleValue
    from PerformanceDataAllView pdv with (NOLOCK)
    inner join PerformanceCounterView pcv on pdv.performancesourceinternalid = pcv.performancesourceinternalid
    inner join BaseManagedEntity bme on pcv.ManagedEntityId = bme.BaseManagedEntityId
    where SampleValue < 20 and CounterName like '% Free Space' and TimeSampled > '2014-08-06 11:00:00.00'
    order by countername, timesampled
    -- replace the below query part in the below SQLCMD C:\>SQLCMD -S SERVERNAME -E -d operationsmanager -Q "select * from sys.databases ds with (nolock) where name='master'" -s "," -o "F:\PowerSQL\MyData.csv" -h -1
    SQLCMD -S SERVERNAME -E -d OperationsManager -Q "select Path, InstanceName, SampleValue
    from PerformanceDataAllView pdv with (NOLOCK)
    inner join PerformanceCounterView pcv on pdv.performancesourceinternalid = pcv.performancesourceinternalid
    inner join BaseManagedEntity bme on pcv.ManagedEntityId = bme.BaseManagedEntityId
    where SampleValue < '20' and CounterName='% Free Space' and TimeSampled > '2014-08-06 11:00:00.00'
    order by countername, timesampled" -s "," -o "c:\MyData.csv" -h -1
    Refer for the other ways 
    http://dba.stackexchange.com/questions/23566/writing-select-result-to-a-csv-file
    --Prashanth

  • Can HTML-based reports be built in BLS via an SQL Query and XSLT?

    Hello xMII experts,
    I have already built a report in xMII which uses XSLT to provide group/sum totals in a web browser. However in a new project, the report must run at certain times and possibly when certain signals become true in the process.
    It appears that BLS is a good choice to achieve this and my proposed Transaction was:
    1. SQL Query Action(uses the same QueryTemplate as in xMII)
    2. XSLTransform Action on the resulting XML resultset (The .xsl file contains HTML which is the original used in xMII to produce the report there)
    3. HTML Loader action with the resulting output of the transformation
    I have now got some output in the resulting HTML file - however it omits all XSLT code - and I am left with an empty HTML shell but for a few images.
    This indicates that perhaps no SQL data was ever returned.
    I have therefore two questions:
    1. How can I check if the SQL returned data?
    2. Is it possible to deliver data to a HTML file directly after an XSLTransformation.
    Looking forward to your responses
    Best Regards
    Robert Sales

    Thank you for the replies.
    I am a little closer the result I need - however I think I need to explain what I had and what I need a little better.
    Before BLS
    1 xMII report page (.irpt extension) with two iCalendar applets (start/end date) and a set of buttons (1 for each report)
    Upon clicking on a button the two dates are passed into an .irpt file, and via a servlet an SQL QueryTemplate and a XSL DisplayTemplate are used to build the report.
    The HTML is embedded in the XSL file - thereby generating the report direct in the web browser.
    - This all works fine
    With BLS
    A transaction which uses a modified SQL QueryTemplate (no date parameters) passing the results to an XML file. This works.
    Now when I click on the button in my xMII screen the .irpt file is called with no Date parameters and the xAcute QueryTemplate called with the XSL DisplayTemplate. The irpt file has <html> and <body> tags with XSL file in the Servlet call providing the tables and data extraction from the XML.
    I have no additional HTML file so I placed the iframe tag inside the XSL file - but it refers to the .irpt file - this doesn't sound right!
    I do get a little output in the web browser but it still omits all XSLT code.
    One more point - The Transaction can be scheduled and run as required - but I need the entire report to created and stored for viewing at a later date. Will a servlet tag running inside an .irpt file achieve this?
    Sorry for the chaotic writing here - but I must leave the office.
    Regards
    Robert Sales

  • SQL Query for Project Permission in Project Server 2010

    HI
    I have assign multiple users on multiple projects with different level permission, 
    The permission level is assign from Project Permission (icon ribbon in PWA 2010.)
    (1.Open the project within Project Professional or Project Web App,
    2.Edit and Save
    the project within Project Professional or Project Web App
    3.Edit Project
    Summary Fields within Project Professional or Project Web App
    4.Publish the
    project within Project Professional or Project Web App
    5.View the Project
    Summary in the Project Center
    6.View the Project
    Schedule Details in Project Web App.
    7.View the Project
    Site)
    Is there any SQL Query to find which user/resource is assign to which projects and what above permission is assign.
    Thanks 
    Farhan
    farhan

    Hi Farhan,
    Please find the SQL below below which will give project permission users:
    select RES_SECURITY_GUID from ProjectServer_Published.dbo.MSP_RESOURCES where RES_UID = '37A56C30-34DE-417B-95A8-42FBA6F47565'
    select PROJ_NAME  from ProjectServer_Published.dbo.MSP_PROJECTS where PROJ_UID in (
    select distinct c.PROJ_UID from ProjectServer_Published.dbo.MSP_WEB_SECURITY_PROJECT_CATEGORIES c
              INNER JOIN ProjectServer_Published.dbo.MSP_WEB_SECURITY_SP_CAT_RELATIONS pcr on pcr.WSEC_CAT_UID = c.WSEC_CAT_UID
              INNER JOIN ProjectServer_Published.dbo.MSP_WEB_SECURITY_SP_CAT_PERMISSIONS pcp on pcp.WSEC_REL_UID = pcr.WSEC_REL_UID
              INNER JOIN ProjectServer_Published.dbo.MSP_WEB_SECURITY_GROUP_MEMBERS gm on gm.WSEC_GRP_GUID = pcr.WSEC_SP_GUID
              INNER JOIN ProjectServer_Published.dbo.MSP_WEB_SECURITY_FEATURES_ACTIONS AS SFA ON SFA.WSEC_FEA_ACT_UID = pcp.WSEC_FEA_ACT_UID
              INNER JOIN ProjectServer_Published.dbo.MSP_WEB_CONVERSIONS AS CONV ON CONV.CONV_VALUE = SFA.WSEC_FEA_ACT_NAME_ID where (1=1)
    And (CONV.LANG_ID = 1033) and gm.WRES_GUID = '2F5512D4-F561-43AF-AB7B-A189B0B9B6E8') -- Replace with above returned RES_SECURITY_GUID
    Vivek

  • Sql query to fetch data based on date conditons

    Hi All,
    We have to schedule a script that runs at 1:00 AM from Monday to Friday.
    The script will run a  sql query  ,that will fetch the data from sql database 2008 based on the below conditions.
    Case 1: If date = current Date then retrieve the data of the previous Date.
    Case 2: If date = Monday then retrieve the entries of Friday ,Saturday and Sunday.
    Please help us on how we can achieve this.
    Thanks

    Hi,
    Are you asking about Patrick's
    solution?
    If so I highly recommend NOT to use this solution. PLease read LMU92's
    and
    Visakh16's responses.
    Why not to use it?
    1. This solution is not deterministic!
    A deterministic algorithm is an algorithm which, given a particular input, will always produce the same output. This solution give different values for different setting! It is depending for example on "SET LANGUAGE" value
    As mentioned above if you try to use any other languge then English then this query will not work since you will never get the value "Sunday"
    2. Moreover! Even if you are using "SET LANGUAGE 'English'" then this
    solution depend on "SET DATEFIRST" and only take into consideration that the value can be 1 or 7, using any other value you will get that @weekendDateMod is null!
    What can you use?
    let's test some value first to get the solution yourself. We know that we don't care about "SET LANGUAGE" since I will not use any language dependency but we need to examine "SET DATEFIRST". Try to change the value from 1 to 7 and check
    the value of this query
    SET DATEFIRST 1 -- Change this value from 1 to 7!
    DECLARE @Sunday DATE = '2014-08-03' -- This is Sunday
    DECLARE @Munday DATE = '2014-08-04' -- This is Munday
    SELECT DATEPART(DW,@Sunday),DATEPART(DW,@Munday), @@DATEFIRST
    Can you see the behavior ?
    The results are hidden here (select the text and you will see them)
    DATEFIRST___Sunday_______Monday
    1___________7___________1
    2___________6___________7
    3___________5___________6
    4___________4___________5
    5___________3___________4
    6___________2___________3
    7___________1___________2
    assuming you did the exercise above yourself, then  you can now think now what is the filter that you need...
    You can use a filter on those two parameters together using "where DATEPART... and @@DATEFIRST...) or using one combine check. Can you think how?
    Notice that this value is always 2 on Monday! Regarding our setting
    (DATEPART(DW,@CurrentDate) + @@DATEFIRST) % 7
    Please Don't Go Down Before YOu Understand!
    Now we can go to the solution
    * I really hope that you read all and did the small exercise yourself! You can not become a developer by copy answers, and this is the reason that from the start I only gave you tha way and not the final query!
    DECLARE @CurrentDate DATE = '2007-08-20' -- This is only for testing since you should use the function GETDATE() instead
    DECLARE @MinDateToFilter DATE
    SET @MinDateToFilter = CASE
    WHEN ((DATEPART(DW,@CurrentDate) + @@DATEFIRST) % 7) = 2 THEN DATEADD(DAY,-4,@CurrentDate)
    ELSE DATEADD(DAY,-1,@CurrentDate)
    END
    SELECT *
    FROM sales.salesOrderHeader
    WHERE orderDate > @MinDateToFilter
    I hope this was useful :-)
    [Personal Site] [Blog] [Facebook]

  • Generate dynamic reports using sql query and send via mail

    Can anyone provide me the links to dynamically generate the sql query based reports and send it to Mail. it should be called from the scheduler program using PL/SQL

    suppose you have the query as
    spool myrep.txt
    select * from emp where rowid<3;
    spool off
    write the query in the emp.sql query at any directory like d:\sqljobs\emp.sql
    the call make a batch file like sndml.bat and write the following codes
    sqlplus scott/tiger@orcl @d:\sqljobs\emp.sql
    explorer mailto:[email protected] d"\sqljobs\myrep.txt
    or if you are using any mailing software then you can use that..

  • List the count of each schema objects.. schema wise sql query needed

    Hi Friends,
    i need a sql query which has to list the schema name along with the count of schema objects like tables,views,triggers.... order by schemaname
    Regards,
    DB

    Hi
    You can try this option if you use 11g .
    Get all the object types in your db.
    SELECT DISTINCT object_type
                 FROM dba_objects;Then include all the object types in to the below query.
    select *
      from (select owner, object_type, 1 CNT
              from dba_objects ) e
            pivot( sum(CNT) for object_type in
              ( 'INDEX','TYPE','VIEW','LIBRARY','TRIGGER','DIRECTORY','PACKAGE','QUEUE','PACKAGE BODY','TABLE PARTITION','PROCEDURE',
                'WINDOW','CLUSTER','LOB','FUNCTION','CONSUMER GROUP','CONTEXT','RULE','XML SCHEMA','SEQUENCE','INDEX PARTITION','OPERATOR',
                'EVALUATION CONTEXT','SCHEDULE','JOB','SCHEDULER GROUP','LOB PARTITION','JOB CLASS','INDEXTYPE','TABLE','TYPE BODY','RESOURCE PLAN',
                'TABLE SUBPARTITION','UNDEFINED','DESTINATION','SYNONYM','EDITION','PROGRAM','RULE SET' ) )       
    order by owner;Cheers
    Kanchana

  • I want SQL query to check if any of our important concurrent programs

    I want a sql query to check if any of our important concurrent programs are currently scheduled or not

    SinghP wrote:
    I want a sql query to check if any of our important concurrent programs are currently scheduled or notThat's nice,
    What scheduling tool are you using? are you referring to dbms_job?
    what version of Oracle are you using? are you using some custom job management system that involves writing to user created tables in your database?

Maybe you are looking for

  • IPhoto/iTunes/iPhone not sync

    Hi there, I have a problem syncing iPhone with iPhoto; my albums, events and faces are correctly displayed both in iPhoto and in iTunes, but not all pics where sync on iPhone. I tried to set "put all in iPhone" but not work. I tried to delete iPod ca

  • Error initializing ejb-module; Exception null

    Information about server. * OS: LINUX * OAS Instalation : J2EE y WebCache - * Standalone * Versión OAS 10g (9.0.4) I want to deploy an ear but the folowing error appear: Error initializing ejb-module; Exception null f. Erika this is the log error: E

  • Exception messages....how do YOU eat yours??

    Exception Messages - For user or developer? Summary When catching Exceptions, is/should it be necessary to look at the message String for deciding what action should be taken or is the message just for humans? What is the generally accepted use of Ex

  • Strange but anoying bug!

    hi ppl it seems for mr that when i log in trow gdm it doenst load my color background...i have everything on black..but still it remaisn blue..can anyone have any ideias how to change this? since last gdm update that this is like this

  • Where I can find Jumper J203

    When I try update my operating system from solaris 7 to solaris 8 on my ultrasparc enterprise 2, system tell me need update fireware to support 64 operating system by setting jumper J203 to 2 and 3 pin connected. But I am sorry, I can't found this ju