SQL Statement Works In sqlplus, Not Grid Ctl For User Defined Metric

I'm trying these queries:
Query 1:
select '0', '0' from dual
union
SELECT
to_char(d.sid),
to_char(d.serial#)
FROM v$sql a,
dba_Users c,
v$session d
WHERE
c.Username = 'SYSADM'
AND (a.Elapsed_Time * 0.000001 > 5
OR a.Executions > 1000)
AND a.Executions > 0
AND c.User_Id = a.ParSing_User_Id
AND (Round(a.Elapsed_Time * 0.000001 / a.Executions)) > 10
AND a.last_active_time > (sysdate - 1)
and a.sql_id = d.sql_id
Query 2:
select 0, 0 from dual
union
SELECT
d.sid,
d.serial#
FROM v$sql a,
dba_Users c,
v$session d
WHERE
c.Username = 'SYSADM'
AND (a.Elapsed_Time * 0.000001 > 5
OR a.Executions > 1000)
AND a.Executions > 0
AND c.User_Id = a.ParSing_User_Id
AND (Round(a.Elapsed_Time * 0.000001 / a.Executions)) > 10
AND a.last_active_time > (sysdate - 1)
and a.sql_id = d.sql_id
As you can see, Query 1 is selecting character results, Query 2 is selecting numerical results. Both work from sqlplus on the host. Trying to run either of them in a user defined metric in Grid Control returns: ORA-00918: column ambiguously defined
1. Why is the error returned in Grid Control?
2. Is there a way to see exactly which column Grid Control has the issue with?

Never mind, I got it.

Similar Messages

  • Error: property is not set correctly for User Defined Fields.

    Hi Gurus,
    I am trying to define a new field Department of type Lookup. For this i have created a new field in user defined fields. But when i click on create user in web console it give me "property is not set correctly for User Defined Fields."
    I created a lookup field for department , but looks like i have to some kind of mapping. How can it be done?
    Thanks,
    sat

    Hi Kevin,
    I couldnt get it done. This is what I had done so far.
    Created Lookup.Users.Dept ( with code code=23 & decode=treasury)
    Added two field in xlwebadmin.properties & xlwebadmin_en.properties
    lookupfield.header.users.deptcode=Department code
    lookupfield.header.users.deptname=Department name
    In my lookfield properties in
    column caption=Department code,Department name
    Column query= Not sure what to give? here
    Thanks,
    sat

  • Sql statement in a table not accepting variable

    I have the following problem on 10.1.0.3.0 with varialbe in an execute immediate statement
    here is the code that I am using
    declare
    remote_data_link varchar2(25) := 'UDE_DATATRANSFER_LINK';
    FROM_SCHEMA VARCHAR2(40) := 'UDE_OLTP';
    l_last_process_date date := to_date(to_char(sysdate,'mm-dd-yyyy hh:mi:ss'),'mm-dd-yyyy hh:mi:ss') - 1;
    stmt varchar2(4000) := 'MERGE into applicant_adverseaction_info theTarget USING (select * from '||FROM_SCHEMA||'.applicant_adverseaction_info@'||remote_data_link||' where last_activity > :l_last_process_date ) theSource ON(theTarget.applicant_id = theSource.applicant_id) WHEN MATCHED THEN UPDATE SET theTarget.cb_used = theSource.cb_used, theTarget.cb_address = theSource.cb_address, theTarget.scoredmodel_id = theSource.scoredmodel_id, theTarget.last_activity = theSource.last_activity WHEN NOT MATCHED THEN INSERT(CB_USED, CB_ADDRESS, SCOREDMODEL_ID, APPLICANT_ID, LAST_ACTIVITY) values(theSource.cb_used, theSource.cb_address, theSource.scoredmodel_id, theSource.applicant_id, theSource.last_activity)';
    stmt2 varchar2(4000) := 'MERGE into edm_application theTarget USING (select * from '||from_schema||'.edm_application@'||remote_data_link||' where last_activity > :l_last_process_date) theSource ON (theTarget.edm_appl_id = theSource.edm_appl_id) WHEN MATCHED THEN UPDATE SET theTarget.APP_REF_KEY = theSource.APP_REF_KEY, theTarget.IMPORT_REF_KEY = theSource.IMPORT_REF_KEY, theTarget.LAST_ACTIVITY = theSource.LAST_ACTIVITY WHEN NOT MATCHED THEN INSERT (EDM_APPL_ID, APP_REF_KEY, IMPORT_REF_KEY, LAST_ACTIVITY) values(theSource.EDM_APPL_ID, theSource.APP_REF_KEY, theSource.IMPORT_REF_KEY, theSource.LAST_ACTIVITY)';
    v_error varchar2(4000);
    T_MERGE VARCHAR2(4000);
    stmt3 varchar2(4000);
    BEGIN
    select merge_sql
    INTO T_MERGE
    from transfertables
    where table_name= 'edm_application';
    remote_data_link:= 'UDE_DATATRANSFER_LINK';
    FROM_SCHEMA := 'UDE_OLTP';
    --DBMS_OUTPUT.PUT_LINE(SUBSTR(stmt2,1,200));
    --STMT2 := T_MERGE;
    dbms_output.put_line(from_schema||' '||remote_data_link||' '||l_last_process_date);
    EXECUTE IMMEDIATE stmt2 using l_last_process_date;
    --execute immediate stmt3 ;
    dbms_output.put_line(from_schema||' '||remote_data_link||' '||l_last_process_date);
    dbms_output.put_line(substr(stmt2,1,200));
    commit;
    EXCEPTION
    WHEN OTHERS THEN
    V_ERROR := SQLCODE||' '||SQLERRM;
    v_ERROR := V_ERROR ||' '||SUBSTR(stmt2,1,200);
    DBMS_OUTPUT.PUT_LINE(V_ERROR);
    --dbms_output.put_line(substr(stmt2,1,200));
    END;
    This works perfectly
    but if I change it to get the same statement in a db table
    declare
    remote_data_link varchar2(25) := 'UDE_DATATRANSFER_LINK';
    FROM_SCHEMA VARCHAR2(40) := 'UDE_OLTP';
    l_last_process_date date := to_date(to_char(sysdate,'mm-dd-yyyy hh:mi:ss'),'mm-dd-yyyy hh:mi:ss') - 1;
    stmt varchar2(4000) := 'MERGE into applicant_adverseaction_info theTarget USING (select * from '||FROM_SCHEMA||'.applicant_adverseaction_info@'||remote_data_link||' where last_activity > :l_last_process_date ) theSource ON(theTarget.applicant_id = theSource.applicant_id) WHEN MATCHED THEN UPDATE SET theTarget.cb_used = theSource.cb_used, theTarget.cb_address = theSource.cb_address, theTarget.scoredmodel_id = theSource.scoredmodel_id, theTarget.last_activity = theSource.last_activity WHEN NOT MATCHED THEN INSERT(CB_USED, CB_ADDRESS, SCOREDMODEL_ID, APPLICANT_ID, LAST_ACTIVITY) values(theSource.cb_used, theSource.cb_address, theSource.scoredmodel_id, theSource.applicant_id, theSource.last_activity)';
    stmt2 varchar2(4000) := 'MERGE into edm_application theTarget USING (select * from '||from_schema||'.edm_application@'||remote_data_link||' where last_activity > :l_last_process_date) theSource ON (theTarget.edm_appl_id = theSource.edm_appl_id) WHEN MATCHED THEN UPDATE SET theTarget.APP_REF_KEY = theSource.APP_REF_KEY, theTarget.IMPORT_REF_KEY = theSource.IMPORT_REF_KEY, theTarget.LAST_ACTIVITY = theSource.LAST_ACTIVITY WHEN NOT MATCHED THEN INSERT (EDM_APPL_ID, APP_REF_KEY, IMPORT_REF_KEY, LAST_ACTIVITY) values(theSource.EDM_APPL_ID, theSource.APP_REF_KEY, theSource.IMPORT_REF_KEY, theSource.LAST_ACTIVITY)';
    v_error varchar2(4000);
    T_MERGE VARCHAR2(4000);
    stmt3 varchar2(4000);
    BEGIN
    select merge_sql
    INTO T_MERGE
    from transfertables
    where table_name= 'edm_application';
    remote_data_link:= 'UDE_DATATRANSFER_LINK';
    FROM_SCHEMA := 'UDE_OLTP';
    --DBMS_OUTPUT.PUT_LINE(SUBSTR(stmt2,1,200));
    STMT2 := T_MERGE;
    dbms_output.put_line(from_schema||' '||remote_data_link||' '||l_last_process_date);
    EXECUTE IMMEDIATE stmt2 using l_last_process_date;
    --execute immediate stmt3 ;
    dbms_output.put_line(from_schema||' '||remote_data_link||' '||l_last_process_date);
    dbms_output.put_line(substr(stmt2,1,200));
    commit;
    EXCEPTION
    WHEN OTHERS THEN
    V_ERROR := SQLCODE||' '||SQLERRM;
    v_ERROR := V_ERROR ||' '||SUBSTR(stmt2,1,200);
    DBMS_OUTPUT.PUT_LINE(V_ERROR);
    --dbms_output.put_line(substr(stmt2,1,200));
    END;
    I get ora-00900 invalid sql statement
    can somebody explain why this happens
    Thanks

    I agree with jan and anthony. Your post is too long and ill-formatted. However here's my understanding of your problem (with examples though slightly different ones).
    1- I have a function that returns number of records in a any given table.
      1  CREATE OR REPLACE FUNCTION get_count(p_table varchar2)
      2     RETURN NUMBER IS
      3     v_cnt number;
      4  BEGIN
      5    EXECUTE IMMEDIATE('SELECT count(*) FROM '||p_table) INTO v_cnt;
      6    RETURN v_cnt;
      7* END;
    SQL> /
    Function created.
    SQL> SELECT get_count('emp')
      2  FROM dual
      3  /
    GET_COUNT('EMP')
                  14
    2- I decide to move the statement to a database table and recreate my function.
    SQL> CREATE TABLE test
      2  (stmt varchar2(2000))
      3  /
    Table created.
    SQL> INSERT INTO test
      2  VALUES('SELECT count(*) FROM p_table');
    1 row created.
    SQL> CREATE OR REPLACE FUNCTION get_count(p_table varchar2)
      2     RETURN NUMBER IS
      3     v_cnt number;
      4     v_stmt varchar2(4000);
      5  BEGIN
      6     SELECT stmt INTO v_stmt
      7     FROM test;
      8     EXECUTE IMMEDIATE(v_stmt) INTO v_cnt;
      9     RETURN v_cnt;
    10  END;
    11  /
    Function created.
    SQL> SELECT get_count('emp')
      2  FROM dual
      3  /
    SELECT get_count('emp')
    ERROR at line 1:
    ORA-00942: table or view does not exist
    ORA-06512: at "SCOTT.GET_COUNT", line 8
    ORA-06512: at line 1
    --p_table in the column is a string and has nothing to do with p_table parameter in the function. And since there's no p_table table in my schema function returns error on execution. I suppose this is what you mean by "sql statement in a table not accepting variable"
    3- I rectify the problem by recreating the function.
      1  CREATE OR REPLACE FUNCTION get_count(p_table varchar2)
      2     RETURN NUMBER IS
      3     v_cnt number;
      4     v_stmt varchar2(4000);
      5  BEGIN
      6     SELECT replace(stmt,'p_table',p_table) INTO v_stmt
      7     FROM test;
      8     EXECUTE IMMEDIATE(v_stmt) INTO v_cnt;
      9     RETURN v_cnt;
    10* END;
    SQL> /
    Function created.
    SQL> SELECT get_count('emp')
      2  FROM dual
      3  /
    GET_COUNT('EMP')
                  14
    Hope this gives you some idea.-----------------------
    Anwar

  • SQL statement works as a View... however

    Question: Why does a SQL statement works in the "View" or in
    a stored procedure works, however when I turn it into
    <cfquery> it does not work. Does anyone have any
    ideas?

    What is the db and what is the sql? Also, in what way does it
    not work?

  • How to create user defined metrics for SQL Server target?

    The customer is not able to create a user defined metrics for SQL Server target.
    This is very important for him to use this product.
    He is asking how to create user defined metrics?
    I sent him Note 304952.1 How to Create a User-Defined SQL Metric in EM 10g Grid Control
    But it would work for an Oracle DB, but his target is SQL Server DB
    Not able to find the "User-Defined Metrics" link from Database home page.
    How to create user defined metrics for SQL Server target?

    http://download-uk.oracle.com/docs/cd/B14099_19/manage.1012/b16241/Monitoring.htm

  • Is it possible to create user defined metrics in Grid Control 10.2.0.1 ?

    Hi,
    Is it possible to create user defined metrics(my SQL statement) in Grid Control 10.2.0.1
    (not 10.2.0.3) Linux/AIX ?
    Łukasz

    I am not sure if I am correct, but for reasons best known to them, Oracle replaced rather than add.
    Even if you want to do a smart search using the part# (e.g B16242-03) in oracle.com, you get a whole list of results, but when you click on them, you get http://www.oracle.com/errors/404.html
    I found this copy http://www.oracle.polcreate.pl/em.102/b16242/toc.htm

  • Does SQL Server agent/IIS plugin support User-Defined metrics?

    Hi,
    Does anyone know if there is a way to add a user-defined metric that connects to a SQL Server database?
    Thanks

    Recently, I released a full MySQL plug-in, for example - http://www.pythian.com/blogs/mysql-plug-in-for-oracle-grid-control
    For me it's not very difficult but it takes some time to get used to.
    I did presentations on creating Management plug-ins and couple articles in IOUG SELECT Magazine. The latest presentation and whitepaper is here - http://www.pythian.com/blogs/466/ioug-collaborate-07-oracle-10g-grid-control
    Official extensibility guide has much more details and is priceless reference but, still, not everything is documented there.

  • SQL Developer 3.1 EA3 unable to import / export user defined reports

    Hi gentlemen,
    Name says it all. Import / Export do not appear anymore neither in dropdown menu for User Defined Reports, nor export for other reports (DD reports or shared reports).
    Best Regards,
    Olivier.

    Those are now Save As / Open...
    Hope that helps,
    K.

  • SQL statement works with SQL/Plus - but not with ODBC

    Hi all,
    I have a rather copmplex SQL statement:
    BEGIN
    UPDATE ContentDataTable
    SET SYMBOLIC_PATH_PARENT = N'/Test',
    SYMBOLIC_NAME = N'HAWK01.GIF',
    VERSION_NUMBER = 1 +
    SELECT MAX(VERSION)
    FROM
    (SELECT MAX(VERSION_NUMBER) AS VERSION
    FROM ContentDataTable WHERE
    SYMBOLIC_PATH_PARENT = N'/Test' AND
    SYMBOLIC_NAME = N'HAWK01.GIF'
    UNION
    SELECT MAX(VERSION_NUMBER) AS VERSION
    FROM RevisedContentDataTable WHERE
    SYMBOLIC_PATH_PARENT = N'/Test' AND
    SYMBOLIC_NAME = N'HAWK01.GIF'))
    WHERE SYMBOLIC_PATH_PARENT = N'/Test' AND SYMBOLIC_NAME = N'HAWK02.GIF' AND VERSION_NUMBER = 1;
    END;
    It works fine in SQL/Plus or SQL Worksheet and does what it should do ;-)
    But when using it via ADO (ODBC Driver) I get the following error:
    PLS-00103 found 'string' but expected one of the following: 'string'"}
    Any idaes?
    Thanx,
    Christian
    null

    Pardon my ignorance, but what's the significance of the N'<string>' construction? That's not one I'm familar with.
    Justin

  • Running Totals, formula statement works one way, not the other

    Here is the problem in a nutshell...
    I am designing a report where I am using 2 running totals based on whether a SQL Stored Proc dataset field (text) is Null or Not Null...  So I design the 2 running totals and put this code in each "Evaluate"
    IsNull({usp_rpt_RemediationData;1.Action})
    - and -
    NOT IsNull({usp_rpt_RemediationData;1.Action})
    The FIRST one works.  The SECOND one does not - that is, it does not add a count for it.
    In other words, I am just cycling through a table and counting 1 field, checking whether its Null, or not.
    Why doesnt this rather simple and straight forward thing work!!!!????
    Any help would be most appreciated.

    The statement...
    NOT IsNull({usp_rpt_RemediationData;1.Action})
    DID NOT work when used as part of a running total - even adding the check for blank instead of just null (though the field is truly null).
    However, using the EXACT same statement in a formula written for running totals - it does work...?  Go figure...  I cant explain it.
    But thanks for the help!

  • SQL Devloper working fine but not SQL Plus

    Hi,
    I am facing a problem that I can connect to oracle server via SQL Developer but cannot connect to the same using SQL*Plus.
    ORA-12154: TNS:could not resolve service name
    I checked many forums and followed each advices but in vein. To make sure that I have got only one instance of tnsnames.ora file, I removed oracle completely from my system and did the fresh installation of the same.Again, SQL Developer worked but not SQL*Plus.
    Also, I updated dummy value in the tnsnames.ora file to check if SQLDeveloper is pointing to correct ora file, it failed means that its pointing to correct one only.
    Also, this is not the problem with single machine rather my colleague is also facing the same problem while connecting to the same oracle. It suggest me that its rather problem with server side then client one but what do you people think the actual problem can be.
    Kindly advice
    I am using oracle 10.2 and OS window server 2003 standard edition.
    Cheers,
    D
    Edited by: user9022426 on 20-Jan-2010 14:25

    The problem is client side.
    The error message means that you're not getting
    Are you using a TNS connection for SQL Developer?
    If so, this error suggests that SQL Developer and SQL*Plus are not going through the same ORACLE_HOME and/or TNSNAMES.ORA.
    For example, do you have the environment variable TNS_ADMIN set?
    If you have metalink access, then there is a troubleshooting guide for ORA-12154 in Metalink note 114085.1

  • Error trying to run SSIS Package via SQL Server Agent: DTExec: Could not set \Package.Variables[User::VarObjectDataSet].Properties[Value] value to System.Object

    Situation:
    SSIS Package designed in SQL Server 2012 - SQL Server Data Tools
    Windows 7 - 64 bit.
    The package (32 bit) extracts data from a SQL Server db to an Excel Output file, via an OLE DB connection.
    It uses 3 package variables:
    *) SQLCommand (String) to specify the SQL Statement to be executed by the package
    Property path: \Package.Variables[User::ExcelOutputFile].Properties[Value]
    Value: f:\Output Data.xls
    *) EXCELOutputFIle (String) to specify path and filename of the Excel output file
    Property path: \Package.Variables[User::SQLCommand].Properties[Value]
    Value: select * from CartOrder
    *) VarObjectDataSet (Object) to hold the data returned by SQL Server)
    Property path: \Package.Variables[User::VarObjectDataSet].Properties[Value]
    Value: System.Object
    It consists out of 2 components:
    *) Execute SQL Task: executes the SQL Statement passed on via a package variable. The resultng rows are stored in the package variable VarObjectDataSet
    *) Script Task: creates the physical output file and iterates VarObjectDataSet to populate the Excel file.
    Outcome and issue:The package runs perfectly fine both in SQL Server Data Tools itself and in DTEXECUI.
    However, whenever I run it via SQL Server Agent (with 32 bit runtime option set), it returns the errror message below.
    This package contains 3 package variables but the error stating that a package variable can not be set, pops up for the VarObjectDataSet only.  This makes me wonder if it is uberhaupt possible to set the value of a package variable
    of type Object.
    Can anybody help me on this please ?
    Message
    Executed as user: NT Service\SQLSERVERAGENT. Microsoft (R) SQL Server Execute Package Utility  Version 11.0.2100.60 for 32-bit  Copyright (C) Microsoft Corporation. All rights reserved.    Started:  6:40:20 PM  DTExec: Could
    not set \Package.Variables[User::VarObjectDataSet].Properties[Value] value to System.Object.  Started:  6:40:20 PM  Finished: 6:40:21 PM  Elapsed:  0.281 seconds.  The package execution failed.  The step failed.
    Thank you very much in advance
    Jurgen

    Hi Visakh,
    thank you for your reply.
    So, judging by your reply, not all package variables used inside a package need to be set a value for when run in DTEXEC ?
    I already tried that but my package ended up in error (something to do with "... invocation ...." and that error is anything but clearly documented. Judging by the error message itself, it looks like it could be just about anything. that is why I asked my
    first question about the object type package variable.
    Now, I will remove it from the 'set values' list and try another go cracking the unclear error-message " ... invocation ...". Does an error message about " ... invocation ..." ring any bells, now that we are talking about it here ?
    Thx in advance
    Jurgen
    Yes exactly
    You need to set values only forthem which needs to be controlled from outside the package
    Any variable which gets its value through expression set inside package or through a query inside execute sql task/script task can be ignored from DTExec
    Ok I've seen the invocation error mostly inside script task. This may be because some error inside script written in script task. If it appeared after you removed the variable then it may because some reference of variable existing within script task.
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • Work email field not filling in for mail enabled security groups in sharepoint

    I've recently been trying to setup alerts to send to mail enabled security groups on our sharepoint site.
    I've created universal mail enabled security groups for this purpose, and populated them with users, and then set those in the alert field, but no one is getting alerts.
    After a lot of investigation, I've found that this is likely because the security groups listed under sharepoint in the people and groups section don't have work email fields filled in. Theres a couple of groups that work which do have this field filled
    in, but everything created recently is missing this. I can't seem to set this field up to be editable instead of importing from AD either. I've confirmed the AD import is working fine, all user details and work email fields are filled out correctly, it is
    only the security groups that are having problems.
    Does anyone have any experience with this?

    As per your description I assume that individual user gets email alert, right ?
    If no then go to central administration > operation > timer job definitions > “web application” view > select your web application in the menu bar to check if Immediate alerts working fine
    If not, please run the following operations:
    stsadm -o setproperty -propertyname alerts-enabled -propertyvalue false -url http://...
     stsadm -o setproperty -propertyname alerts-enabled -propertyvalue true -url http://...
     stsadm -o setproperty -propertyname job-immediate-alerts -propertyvalue "every 5 minutes"  -url http://...
    And then try again.
     At last, if the issue is still there, please check your email server settings in terms of the following articles:
    http://www.sharepoint-tips.com/2007/10/email-alerts-not-getting-sent-while.html
    http://social.technet.microsoft.com/Forums/en-US/sharepointworkflow/thread/36c3b5b5-af03-4f8a-b202-b62db330c21c/
     And if individual user gets an alert then you can create cutomized alert for Sec group
     Please refer
     http://sptoolbox.codeplex.com/releases/view/8255
     hope this will help you
    Regards, Pratik Vyas | SharePoint Consultant | http://sharepointpratik.blogspot.com/

  • Not able to edit user defined reports

    Hi,
    I've run into an issue recently with user defined reports. After some time, I'm not able to edit them. This only happens on some of them. Is there a way to work around this?
    Thanks.

    Hi,
    The platform is Windows XP Pro (32 bit) sp3, sql developer 1.5.5 (although I've seen this happen on earlier versions as well). After some time, some reports become un-editable. If I right click on the report and click edit, nothing happens. I've also tried exporting and re-importing the reports, but that doesn't seem to help.
    Also, I open it up via sqldeveloper.exe, but no console window come up.

  • Event 3351, SQL database login for 'DB_Config' on instance failed. Additional error information from SQL server is mentioned below. Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'.

    category-database
    event id-3351
    source-sharepoint foundation
    SQL database login for 'DB_Config' on instance 'DB\instance' failed. Additional error information from SQL Server is included below:
    Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'.
    I have been getting this error every hour on only 1 application server of the 2.
    My farm consists of 2 app servers, 2 wfes & 2 sql nodes.
    My public site is working fine. Authentication is NTLM.
    SharePoint VSS Writer is disabled.None of my appPool accounts are running under local system.
    I have read many forums/blogs, but couldnt find a solution for this.
    Any help would be appreciated!

    Hi,
    As I understand, you found event id 3351 in event log. Please collect more information as below:
    Check if the error also occurs on other servers in your farm.
    Check if backup job is scheduled at the time when the event id occurs.
    Please run Config Wizard or psconfig.exe -cmd secureresources on all servers and test the issue again.
    Regards,
    Rebecca Tu
    TechNet Community Support

Maybe you are looking for