DBA_AUTOTASK_TASK is empty

I'm trying to check out the new automatic tasks in 11gR2 and I'm having a little trouble getting them to run. I check dba_autotask_client and I see that all three default tasks are there and enabled:
SQL> SELECT client_name,status,consumer_group FROM dba_autotask_client;
CLIENT_NAME STATUS CONSUMER_GROUP
auto optimizer stats coll ENABLED ORA$AUTOTASK_STATS_GROUP
ection
auto space advisor ENABLED ORA$AUTOTASK_SPACE_GROUP
sql tuning advisor ENABLED ORA$AUTOTASK_SQL_GROUP
But when I check dba_autotask_task there are no rows returned:
SQL> select client_name,status from DBA_AUTOTASK_TASK;
no rows selected
Same when I check dba_autotask_job_history:
SQL> select * from DBA_AUTOTASK_JOB_HISTORY;
no rows selected
But when I check the maintenance windows they are enabled:
select * from DBA_AUTOTASK_WINDOW_HISTORY;
WINDOW_NAME WINDOW_START_TIME WINDOW_END_TIME
SATURDAY_WINDOW 27-AUG-11 06.00.00.329614 28-AUG-11 02.00.00.003701
AM +00:00 AM +00:00
SUNDAY_WINDOW 28-AUG-11 06.00.00.243683 29-AUG-11 02.00.00.017650
AM +00:00 AM +00:00
MONDAY_WINDOW 29-AUG-11 10.00.00.090754 30-AUG-11 03.42.02.261462
PM +00:00 PM +00:00
MONDAY_WINDOW 01-AUG-11 10.00.00.153345 02-AUG-11 02.00.00.014974
Any idea how to get them to run?

All the queries you post run on my system.
There's an Oracle note on this that might help :
11g: Scheduler Maintenance Tasks or Autotasks [ID 756734.1]
Best Regards
mseberg
All these queries work on all of my Oracle 11 systems.
Sorry I cannot help.
mseberg
Edited by: mseberg on Aug 30, 2011 3:10 PM
SELECT
CLIENT_NAME, JOB_STATUS, JOB_START_TIME, JOB_DURATION
FROM
DBA_AUTOTASK_JOB_HISTORY
WHERE
CLIENT_NAME = 'auto optimizer stats collection';
SELECT
client_name, job_status, job_start_time, job_duration
FROM
dba_autotask_job_history
WHERE
client_name like '%stats%'
ORDER BY
job_start_time;
SQL> select client_name,status from DBA_AUTOTASK_TASK;
CLIENT_NAME                                                      STATUS
sql tuning advisor                                               ENABLED
auto optimizer stats collection                                  ENABLED
auto space advisor                                               ENABLEDhttp://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:1133388300346992024
begin
DBMS_AUTO_TASK_ADMIN.DISABLE;
end;
/

Similar Messages

  • DBA_HIST_UNDOSTAT IS EMPTY

    I have a issue with a view DBA_HIST_UNDOSTAT when i try to do a query the view is empty.

    All the queries you post run on my system.
    There's an Oracle note on this that might help :
    11g: Scheduler Maintenance Tasks or Autotasks [ID 756734.1]
    Best Regards
    mseberg
    All these queries work on all of my Oracle 11 systems.
    Sorry I cannot help.
    mseberg
    Edited by: mseberg on Aug 30, 2011 3:10 PM
    SELECT
    CLIENT_NAME, JOB_STATUS, JOB_START_TIME, JOB_DURATION
    FROM
    DBA_AUTOTASK_JOB_HISTORY
    WHERE
    CLIENT_NAME = 'auto optimizer stats collection';
    SELECT
    client_name, job_status, job_start_time, job_duration
    FROM
    dba_autotask_job_history
    WHERE
    client_name like '%stats%'
    ORDER BY
    job_start_time;
    SQL> select client_name,status from DBA_AUTOTASK_TASK;
    CLIENT_NAME                                                      STATUS
    sql tuning advisor                                               ENABLED
    auto optimizer stats collection                                  ENABLED
    auto space advisor                                               ENABLEDhttp://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:1133388300346992024
    begin
    DBMS_AUTO_TASK_ADMIN.DISABLE;
    end;
    /

  • Cannot assign an empty string to a parameter with JDBC type VARCHAR

    Hi,
    I am seeing the aforementioned error in the logs. I am guessing its happening whenever I am starting an agent instance in PCo. Can somebody explain whats going on?
    Regards,
    Chanti.
    Heres the complete detail from logs -
    Log Record Details   
    Message: Unable to retreive path for , com.sap.sql.log.OpenSQLException: Failed to set the parameter 1 of the statement >>SELECT ID, PARENTID, FULLPATH, CREATED, CREATEDBY, MODIFIED, MODIFIEDBY, REMOTEPATH, CHECKEDOUTBY FROM XMII_PATHS WHERE FULLPATH =  ?  <<: Cannot assign an empty string to a parameter with JDBC type >>VARCHAR<<.
    Date: 2010-03-12
    Time: 11:32:37:435
    Category: com.sap.xmii.system.FileManager
    Location: com.sap.xmii.system.FileManager
    Application: sap.com/xappsxmiiear

    Sounds like a UI browsing bug (when no path is selected from a catalog tree folder browser) - I would suggest logging a support ticket so that it can be addressed.

  • Oracle, Null and empty Strings

    Currently I'm facing problems with a class, which contains a String, which
    is set to "" (empty String).
    When the class is persistent, oracle writes null to the table column
    (which seems to be common oracle behaviour) and when retrieving the class,
    the field is set to null as well, giving me a lot of null-pointer
    exceptions.
    Anyway ... I can cope with that (just a lot of extra work)
    far worse is the problem, wenn searching objects, that have this field set
    to "" oder null.
    Oracle can't find the records because JDO creates Querys "where
    string=null" or "where string=''" , where oracle expects "where string is
    null" to find the records.
    Is there a workaround or solution ?

    Yeah, that would work as well, thx, but since I have to cope with
    null-Strings now everywhere in my program, it doesn't hurt just to forbid
    empty strings on the program side.
    In future times I'll test on Oracle first, then porting to DB/2 - this way
    I suppose work is far less to garant compability.
    Nevertheless ... having to set the bankcode into quotes is a kodo bug in
    my opinion.
    Kodo knows the type of classfields (in this case string) and shouldn't
    send the parameter as a BigDecimal to the database.
    Given that, and having only bankcodes of null (only neccesary when using
    Oracle), the method would look like:
    public Collection getAccounts (String bankCode)
    throws Exception
    return getAccounts (Account.class, "bankcode=="+bankcode);
    which is how a transparent persistent layer, um, should be , um , I mean
    ... just transparent ;-D
    Marc Prud'hommeaux wrote:
    Stefan-
    Couldn't you just do something like:
    public Collection getAccounts (String bankCode)
    throws Exception
    String filter;
    if (bankCode == null || bankCode.length () == 0)
    filter = "(bankCode == null || bankCode == "")";
    else
    filter = "bankCode == "" + bankCode + """;
    return getAccounts (Account.class, filter);
    If I understand the problem correctly, this should work for all the
    databases.
    In article <[email protected]>, Stefan wrote:
    What operations are you performing to cause this SQL to be issued? You
    say you are having trouble removing objects, but this is clearly not a
    DELETE statement. Is this the SQL that is issued when looking up
    objects by identity?I'm not removing objects, I was removing just quotes from parameters ;-)
    A string column... is it also represented as a string field in your class?Yeah ... just to give you an impression of the code:
    First we have a class, representing a bank account:
    public class Account {
    private AccountMgr myAccountMgr;
    private String bankCode;
    private String id;
    Note, that in nearly all cases bankCode will be a number or null.
    I have a second class "AccountMgr", which does all of the persistant stuff
    (seaching, making persistent etc.)
    This class has two methods, one versatile (protected) to retrieve accounts
    by a given filterString and one who just returns accounts by bankCode,
    building the expected filterstring. Here is my current working version:
    public class AccountMgr {
    public Collection getAccounts(String bankCode) throws Exception {
    if (bankCode!=null) {
    if (bankCode.equals("")) {
    throw new Exception("check code, bankCode='' not allowed to get
    same behavior from DB2 and Oracle");
    // if set, quote the bankCode
    bankCode="""+bankCode+""";
    return getAccounts(Account.class,"bankCode=="+bankCode);
    protected Collection getAccounts(Class accountClass, String filterAdd)
    throws Exception {
    PersistenceManager pm = MyHelper.getPersistenceManager();
    String filter="";
    if (filterAdd!=null && !filterAdd.trim().equals("")) {
    filter+=filterAdd + " && ";
    filter += "myAccountMgr==_accMgr";
    Query query = pm.newQuery(accountClass, filter);
    query.declareParameters("AccountMgr _accMgr");
    return (Collection) query.execute(this);
    As you can see, in the first method I have to set the bankCode into
    quotes, when it's not null.
    This is because otherwise a filter like "bankCode=1234" will be translated
    in a way, where 1234 is send as a BigDecimal to the database:
    [...] executing statement <4239745>: (SELECT [...] FROM JDO_ACCOUNT t0
    WHERE t0.BANKCODE = ? : [reused=1;params={(BigDecimal) 1234}]
    Marc Prud'hommeaux [email protected]
    SolarMetric Inc. http://www.solarmetric.com

  • NULL and Empty String

    Hi There,
    As far as I know, Null is not the same as an empty string; however, when I try this out, I get some unexpected results (well, at least unexpected for my liking):
    SQL> CREATE TABLE TS (MID NUMBER,
      2  MDESC VARCHAR2(20) DEFAULT '' NOT NULL);
    Table created.
    SQL> INSERT INTO TS VALUES(1,'');
    INSERT INTO TS VALUES(1,'')
    ERROR at line 1:
    ORA-01400: cannot insert NULL into ("TT"."TS"."MDESC")So, according to the above scenario, I can't insert an empty string!! However, an empty string is a valid string that doesn't have tuples/data!!
    How come Oracle translates the null string '' as NULL?
    Thanks

    William Robertson wrote:
    There is a special case to do with CHAR values, whereby '' counts as a string and so gets blank-padded, whereas NULL does not.Are you referring to:
    SQL> DECLARE
      2      flag CHAR(2);
      3      PROCEDURE check_null (p_flag IN CHAR)
      4      IS
      5      BEGIN
      6        IF p_flag = '  '
      7        THEN
      8          dbms_output.put_line ('flag is equal to ''  ''');
      9        ELSIF p_flag IS NULL
    10        THEN
    11          dbms_output.put_line ('flag is null');
    12        ELSE
    13          dbms_output.put_line ('other');
    14        END IF;
    15      END;
    16    BEGIN
    17      flag := '';
    18      check_null (flag);
    19      flag := NULL;
    20      check_null (flag);
    21    end;
    22  /
    flag is equal to '  '
    flag is null
    PL/SQL procedure successfully completed.
    SQL> alter session set events '10932 trace name context forever, level 16384';
    Session altered.
    SQL> DECLARE
      2      flag CHAR(2);
      3      PROCEDURE check_null (p_flag IN CHAR)
      4      IS
      5      BEGIN
      6        IF p_flag = '  '
      7        THEN
      8          dbms_output.put_line ('flag is equal to ''  ''');
      9        ELSIF p_flag IS NULL
    10        THEN
    11          dbms_output.put_line ('flag is null');
    12        ELSE
    13          dbms_output.put_line ('other');
    14        END IF;
    15      END;
    16    BEGIN
    17      flag := '';
    18      check_null (flag);
    19      flag := NULL;
    20      check_null (flag);
    21    end;
    22  /
    flag is null
    flag is null
    PL/SQL procedure successfully completed.
    SQL> SY.
    P.S. Don't ask me why normal (or at least consistent) behavior is not the default.

  • Null and empty string not being the same in object?

    Hello,
    I know that null and empty string are interpreted the same in oracle.
    However I discovered the strange behaviour concerning user defined objects:
    create or replace
    TYPE object AS OBJECT (
    value VARCHAR2(2000)
    declare
    xml xmltype;
    obj object;
    begin
    obj := object('abcd');
    xml := xmltype(obj);
    dbms_output.put_line(xml.getStringVal());
    obj.value := '';
    xml := xmltype(obj);
    dbms_output.put_line(xml.getStringVal());
    obj.value := null;
    xml := xmltype(obj);
    dbms_output.put_line(xml.getStringVal());
    end;
    When creating xml from object, all not-null fields are transformed into xml tag.
    I supposed that obj.value being either '' or null will lead to the same result.
    However this is output from Oracle 9i:
    <OBJECT_ID><VALUE>abcd</VALUE></OBJECT_ID>
    <OBJECT_ID><VALUE></VALUE></OBJECT_ID>
    <OBJECT_ID/>
    Oracle 10g behaves as expected:
    <OBJECT><VALUE>abcd</VALUE></OBJECT>
    <OBJECT/>
    <OBJECT/>
    However Oracle 9i behaviour leads me to the conclusion that oracle
    must somehow distinguish between empty string and null in user defined objects...
    Can someone clarify this behaviour?
    Thus is it possible to test if object's field is empty or null?

    However Oracle 9i behaviour leads me to the conclusion that oracle
    must somehow distinguish between empty string and null in user defined objects...
    Can someone clarify this behaviour?
    Thus is it possible to test if object's field is empty or null?A lot of "fixes" were done, relating to XML in 10g and the XML functionality of 9i was known to be buggy.
    I think you can safely assume that null and empty strings are treated the same by Oracle regardless. If you're using anything less than 10g, it's not supported any more anyway, so upgrade. Don't rely on any assumptions that may appear due to bugs.

  • Difference in Null and Empty String

    Hi,
    I have been wondering about the difference between Null and Empty String in Java. So I wrote a small program like this:
    public class CompareEmptyAndNullString {
         public static void main(String args[]) {
              String sNull = null;
              String sEmpty = "";
              try {
                   if (sNull.equalsIgnoreCase(sEmpty)) {
                        System.out.println("Null and Empty Strings are Equal");
                   } else {
                        System.out.println("Null and Empty Strings are Equal");
              } catch (Exception e) {
                   e.printStackTrace();
    This program throws Exception: java.lang.NullPointerException
         at practice.programs.CompareEmptyAndNullString.main(CompareEmptyAndNullString.java:10)
    Now if I change the IF Clause to if (sEmpty.equalsIgnoreCase(sNull)) then the Program outputs this: Null and Empty Strings are Equal
    Can anyone explain why this would happen ?
    Thanks in Advance !!

    JavaProwler wrote:
    Saish,
    Whether you do any of the following code, the JUnit Test always passes: I mean he NOT Sign doesnt make a difference ...
    assert (! "".equals(null));
    assert ("".equals(null));
    You probably have assertions turned off. Note the the assert keyword has nothing to do with JUnit tests.
    I think that older versions of JUnit, before assert was a language keyword (which started in 1.4 or 1.5), had a method called assert. Thus, if you have old-style JUnit tests, they might still compile, but the behavior is completely different from what it was in JUnit, and has nothing to do with JUnit at all.
    If you turn assertions on (-ea flag in the JVM command line, I think), the second one will throw AssertionError.

  • Check for null and empty - Arraylist

    Hello all,
    Can anyone tell me the best procedure to check for null and empty for an arraylist in a jsp using JSTL. I'm trying something like this;
    <c:if test="${!empty sampleList}">
    </c:if>
    Help is greatly appreciated.
    Thanks,
    Greeshma...

    A null check might not be you best option.  If your requirement is you must have both the date and time component supplied in order to populate EventDate, then I would use a Script Functoid that takes data and time as parameters.
    In the C# method, first check if either is an empty string, if so return an empty string.
    If not, TryParse the data, if successful, return a valid data string for EventDate.  If not, error or return empty string, whichever satsifies the requirement.

  • Interactive Report view is empty

    Hi,
    I'm on CRM 7.0 EHP3. I'm encountering empty report criteria and display when open the Campaign effectiveness and all other interactive report page. Please see the screen shot below. There is no error message on the screen, as well as ST22.
    I've configured the interactive report and ran the configuration wizard /CRMBW/CONFIG_WIZARD successfully and no error found.
    Also the roles SAP_CRM_OR_ADMIN, SAP_CRM_OR_CONFIG and SAP_CRM_OR_USER and SAP_ALL are given to the user in both clients.
    Please let me know what could be the causes.
    Thanks in advance.
    cheers,
    julius

    Okay, problem seems solved. I don't know if it is a bug or a feature... (: Anyway, this view selects data from threads that had been created from a portal application. And if you create threads from WC_Collaboration server admin console, there's no data will be selected with FORUMCRAWLER_VW view. Sorry, have no time to check SQL query for those DB view, may be this behaviour is reasonable.
    Edited by: Insomnium on 17.01.2013 2:33

  • Print empty report

    Can I somehow print an empty report, and specify with a parameter how many times it should be repeated?
    The report is a form with checkboxes, and sometimes we want the empty one for someone to fill in when out on the field. And since this form is a subreport, we cant print the entire report over again, but need the subreport to be repeated, let's say five times.
    /Thank you!

    Please re-post if this is still an issue or purchase a case and have a dedicated support engineer work with you directly

  • My photos just became empty boxes, if I click on them they open, but I can't see them at a glance. Anyone know why? thanks

    My photos on iphotos just became empty boxes, bordered by white intermittent lines. If I click on a photo it comes up, but I can't see what each photo is at a glance. Any ideas how to resolve this? thanks

    Back Up and try rebuild the library: hold down the command and option (or alt) keys while launching iPhoto. Use the resulting dialogue to rebuild. Include the options to rebuild the thumbnails.
    Regards
    TD

  • Error while running fiori application in launchpad which is having image in its empty view

    Hi Experts,
                   I have created a fiori application using odata services and uploaded it into launchpad.I want to display image in its empty view. It is getting displayed when i run the application on eclipse but i am getting the error for the same when i run it on launchpad.
    Below is the error:
    "NetworkError: 404 NOT FOUND - http://ws-sapsvr01:8010/sap/bc/ui5_ui5/ui2/ushell/shells/abap/img/TeamSAP.jpg"
    Can any body help me solve this issue why i am getting this??
    Thanks & Regards.
    Rahul.

    Hi Masa,
    In my case, i've the file 'preco_ok.jpg' located inside my extended project (Z_MM_MyProject -> WebContent -> images)
    And I refer it as follow:
    <Image src="images/preco_ok.jpg" class="spaceIndicator"/>
    In the local enviroment it is ok, but on launchpad, the 404 error is shown:
    GET http://host:port/sap/bc/ui5_ui5/ui2/ushell/shells/abap/images/preco_ok.jpg 404 (NOT FOUND)
    Thank you for your support.

  • OBI 11G sUnquotedTableName.empty() error while creating a report

    hello guru's
    We have a problem when trying to build a report in OBI 11G. We have migrated an RPD from 10 to 11 and one 1 installation DEV all is OK, on TEST we get all kind of problems.
    One of the main issues is when trying to build a report and clicking on the + to expand a node of a dimension object we hget the sUnquotedTableName.empty() error
    When going to the logs I see the following details of the error.
    Does anyone have a clue and can help us out?
    Koen Verheyen
    ProblemhMessage Level 10
    Relationship ID 0:1
    Component OBIPS
    Module saw.httpserver.processrequest
    Host XXXXXXX
    Host IP Address XXXXXX
    Thread ID 2836335504
    ECID 0000Ijcd5UzFw000jzwkno1Clgr10001eK
    Message
    Assertion failure: !sUnquotedTableName.empty() at line 1936 of /scratch/aime1/adestore/views/aime1_dadvfa0138/bifndn/analytics_web/main/project/webutil/tablenameutils.cpp
    Supplemental Detail
    File:tablenameutils.cpp
    Line:1936
    Location:
    saw.httpserver.processrequest
    saw.rpc.server.responder
    saw.rpc.server
    saw.rpc.server.handleConnection
    saw.rpc.server.dispatch
    saw.threadpool
    saw.threads
    SessionID: 07vh3ae7bqk8nsnslpm32fhtcm9nsc5cd7va98q
    AuthProps: AuthSchema=UidPwd|PWD=******|UID=koen_verheyen|User=koen_verheyen|RunAs=koen_verheyen
    ecid: 0000Ijcd5UzFw000jzwkno1Clgr10001eK,0:1
    ThreadID: 2836335504
    HttpCommand: JSONRequestTableColumns
    RemoteIP: 10.10.1.15
    HttpArgs:

    Hi,
    I am newly using BI publisher . I am using 10.1.3.4.0 . I am just trying to create a report in test name. that is the first step to create a report where i am getting error. I am using default RPD paint , where all the user and Groups are defined .

  • Is there a way to prevent users from sending empty or incomplete PDF forms?

    Hi all,
    Using Acrobat Professional 8, I made a fillable form to individuals to fill in and submit to me as a pdf attachment to an e-mail or print out it and fill by hand.
    Question 1. I want to make sure they don't send incomplete or empty forms back to me. Is there a way to do that?
    2. The form is 8.5x15 inches. I want it to look like one continuous page on screen but print as 2 letter size pages. However, when i go to print it, acrobat scales it down to fit in one page which makes the text too small to read.
    Please advise! Thanks.
    Karen

    On Question 2:
    when you get to the Print menu in Acrobat/Reader look for scale to fit paper and uncheck if there is a reference to Full size check that.

  • How can I create an empty row on a #TempTable based on an input parameter

    So if my Line of Business is 'MC' or 'MG', I have to go over to Oracle and get its data accordingly. Then, when I create my final report result set, I think I'll want to UNION in that result set if my Parameter is 'MC' or 'MG'. I don't think I can UNION
    based on the value of the Parameter. So my thought process was to create an empty row on my #TempTable so when I UNION and my parameter is NOT 'MC' or 'MG' then it will have nothing to UNION in. My struggle is how do I create an empty row in my #TempTable
    if my parameter is NOT 'MC' or 'MG'
    If I am wwwaaayyy off here, please tell me so.
    This is my #TempTable Creation SQL...
    IF EXISTS
    (SELECT 1
    FROM [#TempTable_LineOfBusiness_Parameter]
    WHERE [#TempTable_LineOfBusiness_Parameter].[RESULT] IN ('MC','MG'))
    BEGIN
    SELECT *
    INTO [#TempTable_Market_Prominence_Member_Data]
    FROM OPENQUERY
    (RPDMHF,
    'SELECT HCFA_NAME_ORG.NAME_ID,
    HCFA_NAME_ORG.MEMBER_ID,
    HCFA_NAME_ORG.HIC_NUMBER,
    MEMBER.NAME_FIRST,
    MEMBER.NAME_LAST,
    HCFA_DATE.START_DATE,
    HCFA_DATE.END_DATE,
    HCFA_NAME_ORG.COUNTY_CODE,
    HCFA_NAME_ORG.PART_A_PAYMENT,
    HCFA_NAME_ORG.PART_B_PAYMENT,
    HCFA_NAME_ORG.STATUS,
    HCFA_NAME_ORG.ORG_ID,
    HCFA_NAME_ORG.PLAN,
    HCFA_NAME_ORG.ENROLL_DATE,
    HCFA_NAME_ORG.PBP_ID,
    HCFA_DATE.VALUE
    FROM SC_BASE.HCFA_DATE
    LEFT JOIN SC_BASE.HCFA_NAME_ORG
    ON HCFA_NAME_ORG.NAME_ID = HCFA_DATE.NAME_ID
    LEFT JOIN AMIOWN.MEMBER
    ON TRIM(MEMBER.MEMBER_NBR) = TRIM(HCFA_NAME_ORG.MEMBER_ID)
    WHERE HCFA_DATE.INDICATOR = ''plan''
    AND HCFA_DATE.START_DATE >= ''2015-01-01''
    END
    If I add an ELSE, it always comes back and tells me the #TempTable_Market_Prominence_Member_Data already exists. As if it's creating it regardless of the Top IF.
    Thanks for your review and am hopeful for a reply.

    Hi ITBobbyP,
    The error came back from your ELSE Statement most probably caused by the reason mentioned in Hoffmann's post.
    Regarding your requirement, I would suggest you CREATE the [#TempTable_Market_Prominence_Member_Data] explicitly.
    CREATE TABLE [#TempTable_Market_Prominence_Member_Data]
    NAME_ID INT,
    MEMBER_ID INT,
    HIC_NUMBER VARCHAR(99),
    NAME_FIRST VARCHAR(99),
    NAME_LAST VARCHAR(99),
    START_DATE DATE,
    END_DATE DATE,
    COUNTY_CODE VARCHAR(99),
    PART_A_PAYMENT MONEY,
    PART_B_PAYMENT MONEY,
    STATUS VARCHAR(99),
    ORG_ID INT,
    PALN VARCHAR(99),
    ENROLL_DATE VARCHAR(99),
    PBP_ID INT,
    VALUE INT
    IF EXISTS
    (SELECT 1
    FROM [#TempTable_LineOfBusiness_Parameter]
    WHERE [#TempTable_LineOfBusiness_Parameter].[RESULT] IN ('MC','MG'))
    BEGIN
    INSERT INTO [#TempTable_Market_Prominence_Member_Data]
    SELECT *
    FROM OPENQUERY
    (RPDMHF,
    'SELECT HCFA_NAME_ORG.NAME_ID,
    HCFA_NAME_ORG.MEMBER_ID,
    HCFA_NAME_ORG.HIC_NUMBER,
    MEMBER.NAME_FIRST,
    MEMBER.NAME_LAST,
    HCFA_DATE.START_DATE,
    HCFA_DATE.END_DATE,
    HCFA_NAME_ORG.COUNTY_CODE,
    HCFA_NAME_ORG.PART_A_PAYMENT,
    HCFA_NAME_ORG.PART_B_PAYMENT,
    HCFA_NAME_ORG.STATUS,
    HCFA_NAME_ORG.ORG_ID,
    HCFA_NAME_ORG.PLAN,
    HCFA_NAME_ORG.ENROLL_DATE,
    HCFA_NAME_ORG.PBP_ID,
    HCFA_DATE.VALUE
    FROM SC_BASE.HCFA_DATE
    LEFT JOIN SC_BASE.HCFA_NAME_ORG
    ON HCFA_NAME_ORG.NAME_ID = HCFA_DATE.NAME_ID
    LEFT JOIN AMIOWN.MEMBER
    ON TRIM(MEMBER.MEMBER_NBR) = TRIM(HCFA_NAME_ORG.MEMBER_ID)
    WHERE HCFA_DATE.INDICATOR = ''plan''
    AND HCFA_DATE.START_DATE >= ''2015-01-01''
    END
    Explicitly creating the temp table will offer below benefit in this case.
    The ELSE statement is no longer needed, if the no rows get inserted into that table, it has nothing to union an empty table.
    With the column datatype defined, you can avoid such conversion error
    SELECT NULL AS COL1,NULL AS COL2 INTO #T
    SELECT COL1,COL2 FROM #T
    UNION
    SELECT 1,'ABC'--Conversion failed when converting the varchar value 'ABC' to data type int.
    If you have any question, feel free to let me know.
    Eric Zhang
    TechNet Community Support

Maybe you are looking for