SCCM query not returning the results I want

I would like to use a query that will query my systems that have a particular piece of software (Flash), but I do not want it to include servers that are in a particular group.
Explanation: I have about 20 servers with Flash installed that require it.  About half of them I can update regularly, the other half I can't.  So, I have an AD group for each - the ones I can patch, and the ones I can't.  I want the query
to look for systems with "Adobe Flash" in the display name, but exclude the servers in both of these groups.  That way I can create a collection of computers that have Flash installed where it shouldn't be and can keep an eye on where it is
being installed.
The query looks like this in the criteria tab;
Add/Remove Programs.Display Name is like "%Adobe Flash%"
and
System Resource.System Group Name is not equal to "LAB\FlashPatchGroup"
The query language looks like this;
select distinct SMS_R_System.Name, SMS_R_System.description, SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName, SMS_G_System_ADD_REMOVE_PROGRAMS.Version from  SMS_R_System inner join SMS_G_System_ADD_REMOVE_PROGRAMS on SMS_G_System_ADD_REMOVE_PROGRAMS.ResourceID
= SMS_R_System.ResourceId where SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName like "%Adobe Flash%" and SMS_R_System.SystemGroupName != "LAB\\FlashPatchGroup"
The problem I am having is that when I run the query, it is pulling everything with Flash, including the ones in the AD group.  Anyone see a problem with the way I'm doing this?

Hi Jorgen,
   Thank you for that - very helpful because I actually knew nothing about sub-select queries.  So now the overall logic makes sense, but unfortunately the only examples I've been able to find don't cover exactly what I want to do.
The overall examples I have found work like this;
- Create a query to find computers with a particular application installed
- Create a subselect query that says find users that are NOT subject to the preceeding query
What I need to do, however, is this;
- A query finds computers with a particular piece of software installed
- It compares the computer to 2 Active Directory groups I have created.
- The query produces all computers with that particular piece of software that is NOT in the AD groups I have created.  This way I can easily identify servers that have Flash installed that shouldn't.
Any ideas?  I have been trying to follow the subselect queries to do something similar but I just cannot make it work.  I've tried to create a subselect query that says "Add/Remove Programs Display Name contains "%Adobe Flash%" but is not in (subselect
query)" and it just doesn't like it.
Regards
Juice

Similar Messages

  • Basic NOT EXISTS query not returning any results

    DB Version: 10gR2
    One of our tables in the test schema is having less number of columns than the PROD shema.
    To determine which are missing columns in this table in Test schema i did the following.
    -----In Test Schema
    CREATE TABLE XYZ2
    (COL1 NUMBER);        ----------only one column
    SQL > CREATE TABLE tables_test_list AS SELECT TABLE_NAME,COLUMN_NAME FROM USER_TAB_COLS;
    Table created.--- In the prod schema
    SQL> CREATE TABLE XYZ2
      2  (COL1 NUMBER,
      3  COL2 NUMBER       ----------- same table name with an extra column
      4  );
    Table createdAnd from the PROD schema i execute the following SQL to determine what are the columns that are missing in the TEST schema
    select column_name from User_Tab_Cols  outer
    where table_name='XYZ2'
    and not exists (select 1 from TEST_SCHEMA.tables_test_list inner where outer.TABLE_NAME=inner.TABLE_NAME )But the above query is not returning any results. Any idea why?

    Actually, the example from the link I posted earlier:
    [email protected]> (
      2  select 'IN T1, NOT T2', column_name,data_type,data_length
      3    from user_tab_columns
      4   where table_name = 'T1'
      5  MINUS
      6  select 'IN T1, NOT T2', column_name,data_type,data_length
      7    from user_tab_columns
      8   where table_name = 'T2'
      9  )
    10  UNION ALL
    11  (
    12  select 'IN T2, NOT T1', column_name,data_type,data_length
    13    from user_tab_columns
    14   where table_name = 'T2'
    15  MINUS
    16  select 'IN T2, NOT T1', column_name,data_type,data_length
    17    from user_tab_columns
    18   where table_name = 'T1'
    19  )
    20  /

  • IPTObjectManager.Query not returning correct result (Java)

    Hi,
    I am having a problem with the IPTObjectManager.Query method. The code is given below. The issue I am having is, that when I search for a community in a specific folder not results are returned. However if I search in all folders (using -1 as the second parameter to the method) it returns multiple communities including the one I need. Anyone else had the same issue with this??
    // THIS CODE WORKS AND RETURN MULTIPLE COMMUNITIES
    // THE hotelCode VARIABLE IS A STRING VARIABLE CONTAINING A VALUE
    // WHICH IS THE COMMUNITY NAME.
    // Create a ObjectManager object
    IPTObjectManager objectManager = session.GetObjectManagers(ObjectClass.Community.toInteger());
    // define the query based on the passed string
    Object[][] vQueryFilter = {
         new Object[]{new Integer(PT_PROPIDS.PT_PROPID_NAME)},
         new Object[]{new Integer(PT_FILTEROPS.PT_FILTEROP_CONTAINS)},
         new Object[]{hotelCode}};
    // Run the query and return results
    IPTQueryResult ptQueryResult = objectManager.Query(
         PT_PROPIDS.PT_PROPID_ALL, -1, PT_PROPIDS.PT_PROPID_NAME, 0, -1, vQueryFilter);
    // THIS CODE DOES NOT WORK. I AM PASSING IS THE FOLDER ID OF THE
    // FOLDER WHICH CONTAINS THE COMMUNITY
    // Create a ObjectManager object
    IPTObjectManager objectManager = session.GetObjectManagers(ObjectClass.Community.toInteger());
    // define the query based on the passed string
    Object[][] vQueryFilter = {
         new Object[]{new Integer(PT_PROPIDS.PT_PROPID_NAME)},
         new Object[]{new Integer(PT_FILTEROPS.PT_FILTEROP_CONTAINS)},
         new Object[]{hotelCode}};
    // Run the query and return results
    IPTQueryResult ptQueryResult = objectManager.Query(
         PT_PROPIDS.PT_PROPID_ALL, 303, PT_PROPIDS.PT_PROPID_NAME, 0, -1, vQueryFilter);

    I don't know about G6, however in version 5 there does not appear an easy way of doing it. I guess the "easiest" way would be to query sub-folders first, build and array of their ids, and then query for communities in those folders. This is using server API. Something like this (.NET):
    publicvoidGetFolderCommunities(intfolderId){    IPTAdminFolder folder =this.session.GetAdminCatalog().OpenAdminFolder(folderId, false);    IPTQueryResult qr =folder.QuerySubfolders(PT_PROPIDS.PT_PROPID_ALL, [b]1, null, 0, -1, newobject[][] {             newobject[] { PT_PROPIDS.PT_PROPID_FOLDER_FOLDERTYPE }, newobject[] { PT_FILTEROPS.PT_FILTEROP_EQ } , newobject[] { PT_ADMIN_FOLDER_TYPES.PT_ADMIN_FOLDER_TYPE_COMMUNITYFOLDER } } ); int[] folderIds =newint[qr.RowCount()]; Console.WriteLine("------ sub-folders for communities -------"); for(inti =0; i <qr.RowCount(); i++) {        intobjectId =qr.ItemAsInt(i, PT_PROPIDS.PT_PROPID_OBJECTID);        stringobjectName =qr.ItemAsString(i, PT_PROPIDS.PT_PROPID_NAME);        intparentFolderId =qr.ItemAsInt(i, PT_PROPIDS.PT_PROPID_FOLDER_PARENTFOLDERID);        folderIds[i] =objectId; Console.WriteLine("{0}: {1}; parent: {2}", objectId, objectName, parentFolderId); } qr =this.session.GetCommunities().Query( PT_PROPIDS.PT_PROPID_ALL, -1, (object) null, 0, -1, newobject[][] {            newobject[] { PT_PROPIDS.PT_PROPID_FOLDERID }, newobject[] { PT_FILTEROPS.PT_FILTEROP_IN } , newobject[] { folderIds } } ); Console.WriteLine("------ communities from sub-folders -------"); for(inti =0; i <qr.RowCount(); i++) {        intobjectId =qr.ItemAsInt(i, PT_PROPIDS.PT_PROPID_OBJECTID);        stringobjectName =qr.ItemAsString(i, PT_PROPIDS.PT_PROPID_NAME);        int parentFolderId =qr.ItemAsInt(i, PT_PROPIDS.PT_PROPID_FOLDERID);        Console.WriteLine("{0}: {1}; folder: {2}", objectId, objectName, parentFolderId); }}
    Or you could use EDK RPC search. Again, in .NET:
    publicvoidSearchForCommunities(intfolderId){ IPortalSearchRequest searchRequest =this.ptSession.GetSearchFactory().CreatePortalSearchRequest(); searchRequest.SetObjectTypesToSearch(newObjectClass[] { ObjectClass.Community }); searchRequest.SetDocFoldersToSearch(newint[] {}, true); searchRequest.SetAdminFoldersToSearch(newint[] { folderId}, true); searchRequest.SetResultsCount(0, 100); searchRequest.SetResultsOrderBy(PortalField.OBJECT_ID); searchRequest.SetFieldsToReturn(newPlumtreeField[] {}); searchRequest.SetQuery("*"); ISearchResponse searchResponse =searchRequest.Execute(); intreturnedMatches =searchResponse.GetReturnedCount(); ISearchResultSet resultSet =searchResponse.GetResultSet(); IEnumerator enumerator =resultSet.GetResults(); while(enumerator.MoveNext()) { ISearchResult result =(ISearchResult) enumerator.Current; Console.WriteLine( result.GetFieldAsInt(PortalField.OBJECT_ID) +": "+ result.GetFieldAsString(PlumtreeField.NAME) ); }}
    Ruslan.

  • Search-Mailbox Search Query not returning correct results.

    Hi,
    I'd appreciate some assistance with the search and delete I'm trying to I'm run.
    I'm using the following command to find messages with a certain message class received before 01/01/14 in a mailbox.
    Get-Mailbox xxxxxxxxxxxxxxx | Search-Mailbox -SearchQuery '(Received:< 01/01/14) AND ("IPM.Note.Worksite.Ems.Filed")' -EstimateResultOnly | select displayname, success, resultitemscount,Resultitemssize
    When I first ran the command it returned 130,000 items, I ran it again with a -DeleteContent switch, all the items were successfully removed from the mailbox, great! However, when I look in the mailbox I can see ~1000 items with the message class in the command
    and dated 2013 or earlier, they meet the search criteria so I don't understand why when I run the command again it returns 0 items.
    Help!

    Hello,
    Based on your description, your cmdlet is ok.
    When you run the cmdlet with a -DeleteContent switch, the messages are not delete permanently. please try to run the cmdlet with a -DeleteContent switch and -Force switch to check the result.
    Besides, please use get-mailboxstatistics | fl cmdlet to check information about mailbox.
    Cara Chen
    TechNet Community Support

  • Validator not returning the results.

    Hi All,
    I have extended the StringValidator class in order the create a username validator. When a new user is being registered, the username is validated on the server to check if it exists.
    The code is not throwing errors and i know the remoteobject calls work. The push sets the message, but the problem is that the result is not returned.
    Is the flow correct?
    public class PosUsernameValidator extends StringValidator {
              private var userServiceRO:RemoteObject = new RemoteObject();
              private var validatorResults:Array = new Array();
              public function PosUsernameValidator(){
                   super();
                   userServiceRO.destination = "UserService";
                   userServiceRO.getUserByUserName.addEventListener("result", getUserByUserNameRH);
                   userServiceRO.getUserByUserName.addEventListener("fault", getUserByUserNameFH)
              override protected function doValidation(value:Object):Array {
                   validatorResults = super.doValidation(value);
                   return doForUserName(value);
              private function doForUserName(value:Object):Array{
                   userServiceRO.getUserByUserName(String(value));
                   return validatorResults;
              private function getUserByUserNameRH(r:ResultEvent, t:Object = null):void{
                   var user:User = r.result as User;
                   if(user!=null){
                        validatorResults.push(new ValidationResult(true, null, "Username error","Username already taken!"));
              private function getUserByUserNameFH(f:FaultEvent, t:Object = null):void{
                   Alert.show(ObjectUtil.toString(f));

    At first glance I would say that trying to combine your client-side and server-side validation into a single class like that is not a good idea. In doForUserName() you are making an asyncronous server call. The validatorResults will get returned immediately, so by the time your handler method executes it is already too late. Rather than trying to do both sets of validation at once, remove the server-side code from this class and use it as a normal flex validator. Then in your component (or better yet in your controller class if you follow an MVC pattern) call your service method after the client side validator returns a valid result.

  • Report query not returning the field value from external table

    hi
    I have an issue regarding reports. I have a query having 4 fields from external table and remaining from db tables. the report query returns all the fields from the db tables and only 2 fields from external table. but the same query if I tried in plsql developer it returns all the fields values.
    Can anyone please help me in this issue.
    Thanks and Regards
    kk

    Duplicate post?
    value not displaying in report whereas it returns in plsql developer
    value not displaying in report whereas it returns in plsql developer
    Please log a SR if you do not get any reply to your thread instead of creating new one.
    Thanks,
    Hussein

  • Query not executing the results

    Hi,
    I have created a Custom Virtual Cube with a custom function module. This Cube displays data when i check it through the transaction code - LISTCUBE.
    I have a query which has to be executed on this Virtual Cube. When i execute this Query , it does not display any data at all. It always displays "No applicable data found".
    I have tried with the combination of inputs for which the data is available in the cube. but still it gives "No applicable data found".
    Can someone suggest me what i have to do to correct this problem.
    Thanks
    Maddy

    Hi Maddy,
    I also encountered similar problem in BI 7.0, which doesn't happen in BW 3.5, though I was using Basic Cube, not Virtual Cube. I could finally work it out. Here are the steps I used:
    - Right click on the InfoCube > choose "Manage".
    - In the "Requests" tab, click the traffic light button in the "Request Status" column, set it to "Status OK".
    - The "Request for Reporting Available" column will show the "Request is available for reporting" icon automatically.
    - Try to execute your query again.
    Hope this might be relevant to your situation as well.
    Regards,
    arie

  • BAPI_SALESORDER_CREATEFROMDAT2 does not return the results of ATP

    we are developing an interface from the customer software to our SAP-system. We are getting Sales Order and perform the with BAPI_SALESORDER_CREATEFROMDAT2. In the case the customer ordes more than available a schedule line is created but confirmed quantitiy is 0. There is no error log or atp message in the BAPI.
    Our idea is to get the available quantity as confirmed quantity.
    Does somebody know how I can solve this?
    kind regards,
    Thomas Robier

    close (not answerdeD)

  • SQL Query Not Returning Correct Results

    I am trying to pull all records that are set for mailing and
    are from every state except for Nebraska and some counties in Iowa.
    It isn't pulling correctly. Any help would be greatly appreciated.
    SELECT HS_SATCode.School, HS_SATCode.Add1, HS_SATCode.City,
    HS_SATCode.State, HS_SATCode.[Zip Code], HS_SATCode.county,
    HS_SATCode.mail_list
    FROM HS_SATCode
    WHERE (((HS_SATCode.State)<>'NE') AND
    ((HS_SATCode.mail_list)=1)) OR (((HS_SATCode.State)='IA') AND
    ((HS_SATCode.county)<>'Adair' And
    (HS_SATCode.county)<>'adams' And
    (HS_SATCode.county)<>'audubon' And
    (HS_SATCode.county)<>'buena vista' And
    (HS_SATCode.county)<>'calhoun' And
    (HS_SATCode.county)<>'carroll' And
    (HS_SATCode.county)<>'cass' And
    (HS_SATCode.county)<>'cherokee' And
    (HS_SATCode.county)<>'clay' And
    (HS_SATCode.county)<>'crawford' And
    (HS_SATCode.county)<>'dickinson' And
    (HS_SATCode.county)<>'fremont' And
    (HS_SATCode.county)<>'greene' And
    (HS_SATCode.county)<>'guthrie' And
    (HS_SATCode.county)<>'harrison' And
    (HS_SATCode.county)<>'ida' And
    (HS_SATCode.county)<>'lyon' And
    (HS_SATCode.county)<>'mills' And
    (HS_SATCode.county)<>'monona' And
    (HS_SATCode.county)<>'montgomery' And
    (HS_SATCode.county)<>'o''brien' And
    (HS_SATCode.county)<>'osceola' And
    (HS_SATCode.county)<>'page' And
    (HS_SATCode.county)<>'pottawattamie' And
    (HS_SATCode.county)<>'plymouth' And
    (HS_SATCode.county)<>'ringold' And
    (HS_SATCode.county)<>'sac' And
    (HS_SATCode.county)<>'shelby' And
    (HS_SATCode.county)<>'sioux' And
    (HS_SATCode.county)<>'tayland' And
    (HS_SATCode.county)<>'union' And
    (HS_SATCode.county)<>'woodbury') AND
    ((HS_SATCode.mail_list)=1))
    ORDER BY HS_SATCode.mail_list, HS_SATCode.State,
    HS_SATCode.county

    Wow, that's a lotta brackets. And most of them are
    unnecessary. Let's reduce it a bit.
    WHERE
    HS_SATCode.State)<>'NE' AND HS_SATCode.mail_list =1
    OR (HS_SATCode.State='IA' AND
    HS_SATCode.county<>'Adair' )
    Can you see how this will send mail to Nebraska?

  • How I can change this query? to get the results I want

    This query
    select
    SHRTGPA_pidm,
    SZSTCLA_TERM_CODE,
    SHRTGPA_GPA_HOURS
    from  szstcla,SHRTGPA
    where szstcla_pidm = 74246
    and SHRTGPA_pidm = szstcla_pidm
    and SZSTCLA_TERM_CODE <> SZSTCLA_TERM_CODE_MATRIC
    and SHRTGPA_TERM_CODE = SZSTCLA_TERM_CODEreturns
    74246     201020     4
    74246     201120     4
    74246     201110     4
    74246     201210     4
    74246     201220     4 I want to aggregate so the query will return
    74246 201020     4
    74246 201120     8
    74246 201110     12
    74246 201210     16201220     20

    Hi,
    So, instead of shrtgpa_gpa_hours, you want a cumulative total of shrtgpa_gpa_hours, adding up all the previous values.
    That's a job for the analytic SUM function:
    select
    SHRTGPA_pidm,
    SZSTCLA_TERM_CODE,
    SUM (SHRTGPA_GPA_HOURS) OVER (ORDER BY x)  as running_shrtgpa_gpa_hours     -- *****  CHANGED  *****
    from  szstcla,SHRTGPA
    where szstcla_pidm = 74246
    and SHRTGPA_pidm = szstcla_pidm
    and SZSTCLA_TERM_CODE  SZSTCLA_TERM_CODE_MATRIC
    and SHRTGPA_TERM_CODE = SZSTCLA_TERM_CODEwhere x is the expression (or list of expressions) that determines what are the "previous" rows.
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables involved, and also post the results you want from that data.
    Explain, using specific examples, how you get those results from that data.
    Always say which version of Oracle you're using (e.g., 11.2.0.2.0).
    See the forum FAQ {message:id=9360002}

  • The statement did not return a result set in ireport

    Hi,
        I am Building a Report in iReport(Jasper Reports). I called a stored procedure from iReport by passing a parameter in Query Editor. I am getting an exception saying "The statement did not return a result set". When
    i use Temp Tables in stored procedure i am getting the exception.
    If there is no temptable in Stored procedure there wont be any exception.
    This is my Stored procedure
    Create PROCEDURE [XUSP_REPORT_SOPRINT] @BNUM VARCHAR(20) AS
    BEGIN
    DECLARE @FQTY BIGINT
    DECLARE @ITNAME VARCHAR(100)
    DECLARE @COUNT INT=0
    DECLARE @COUNT1 INT=0
    CREATE TABLE #BILL_PRINT(
        [BNUM] [varchar](20) NOT NULL,
        [CNAME] [varchar](30) NOT NULL,
        [CNUM] [int] NOT NULL,
        [ITNAME] [varchar](100) NOT NULL,
        [ITEM#] [int] NOT NULL,
        [QTY] [int] NOT NULL DEFAULT 0,
        [UNIT] [varchar](5) NOT NULL,
        [PRICE] [float] NOT NULL DEFAULT 0,
        [BASIC] [float] NOT NULL DEFAULT 0,
        [DISCOUNT] [float] NOT NULL DEFAULT 0,
        [FRQTY] [int] NOT NULL DEFAULT 0,
        [BADDR] [varchar](300) NULL,
        [CADDR] [varchar](300) NOT NULL,
        [BDATE] [datetime] NULL DEFAULT (sysdatetime()),
        [BILLBY] [varchar](50) NOT NULL,
        [ROUTE] [varchar](200) NULL,
        [AMT] [float] NOT NULL DEFAULT 0,
        [VAT] [float] NOT NULL DEFAULT 0,
        [VAT AMT] [float] NOT NULL DEFAULT 0,
        [AMT_AF_DISC] [float] NOT NULL DEFAULT 0,
        [AMT_AF_VAT] [float] NOT NULL DEFAULT 0,
        [TOT_DISC] [float] NOT NULL DEFAULT 0,
        [ROUND_OFF] [float] NOT NULL DEFAULT 0,
        [TOT_VAT] [float] NOT NULL DEFAULT 0,
        [AMT_UNDER_VAT] [float] NOT NULL DEFAULT 0,
        [NETT] [float] NOT NULL DEFAULT 0,
        [TOS] [varchar](30) NULL DEFAULT 0,
        [CDISC] [float] NOT NULL DEFAULT 0,
        [SDISC] [float] NOT NULL DEFAULT 0
    insert into #BILL_PRINT SELECT [BNUM]
          ,[CNAME]
          ,[CNUM]
          ,[ITNAME]
          ,[ITEM#]
          ,[QTY]
          ,[UNIT]
          ,[PRICE]
          ,[BASIC]
          ,[DISCOUNT]
          ,[FRQTY]
          ,[BADDR]
          ,[CADDR]
          ,[BDATE]
          ,[BILLBY]
          ,[ROUTE]
          ,[AMT]
          ,[VAT]
          ,[VAT AMT]
          ,[AMT_AF_DISC]
          ,[AMT_AF_VAT]
          ,[TOT_DISC]
          ,[ROUND_OFF]
          ,[TOT_VAT]
          ,[AMT_UNDER_VAT]
          ,[NETT]
          ,[TOS]
          ,[CDISC]
          ,[SDISC]
      FROM [SALES_DETAILS] WHERE BNUM=@BNUM
    CREATE TABLE #ITNAME_0
    ITEM VARCHAR(100) NOT NULL,
    FREE BIGINT NOT NULL
    INSERT INTO #ITNAME_0 SELECT ITNAME,FRQTY FROM SALES_DETAILS WHERE FRQTY<>0 AND BNUM=@BNUM
    --SELECT * FROM #ITNAME_0
    SET @COUNT=(SELECT COUNT(*) FROM #ITNAME_0)
    WHILE @COUNT!=0
    BEGIN
    SET @FQTY=(SELECT TOP(1) FREE FROM #ITNAME_0)
    SET @ITNAME=(SELECT TOP(1) ITEM FROM #ITNAME_0)
    SET @COUNT1=(SELECT COUNT(*) FROM #BILL_PRINT WHERE ITNAME=@ITNAME AND BNUM=@BNUM)
    IF @COUNT1=2
    BEGIN
        UPDATE #BILL_PRINT
        SET FRQTY+=@FQTY
        WHERE ITNAME=@ITNAME AND QTY<>0
        DELETE FROM #ITNAME_0 WHERE ITEM=@ITNAME AND FREE=@FQTY
        DELETE FROM #BILL_PRINT WHERE  ITNAME=@ITNAME AND QTY=0
    END
    SET @COUNT=@COUNT-1
    END
    --SELECT *FROM sales_details
    SELECT *FROM #BILL_PRINT where bnum=@bnum
    DROP TABLE #BILL_PRINT
    DROP TABLE #ITNAME_0
    END
    Please help me out in this.
    Thanks,
    Shreyas M

    This is a forum for Reporting Services (SSRS). If you're using Jasper reports then you should be posting in relevenat forums. I'm not sure there would be enough people with Jasper report experience here to help you out!
    Anyways in SSRS when  we use Temp tables in procedure it will throw exception in editor but when you save and run it will still work fine. Did you try saving it and executing report? Did the error still persisted?
    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • I need return the result of a query on a stored procedure

    I need return the result of a query on a stored procedure, I mean when I execute a stored procedure it returns a result set as a select query.
    Best regards...

    If you want some pl/sql code that can be used in a query as it were a table you may be interested in table functions:
    SQL> create or replace type
      2  t_emp is object (
      3  name            varchar2(30),
      4  hire_date date,
      5  salary       number);
      6  /
    Tipo creato.
    SQL> create or replace type
      2  t_emptab is table of t_emp;
      3  /
    Tipo creato.
    SQL> create or replace function tab_fun(p_dept in number)
      2  return t_emptab is
      3  e t_emptab;
      4  begin
      5    select t_emp(ename,hiredate,sal)
      6      bulk collect into e
      7      from emp
      8     where deptno=p_dept;
      9
    10    return dip;
    11  end;
    12  /
    Funzione creata.
    SQL> select *
      2  from table(tab_fun(20));
    NAME                           HIRE_DATE  SALARY
    SMITH                          17-DIC-80        800
    JONES                          02-APR-81       2975
    SCOTT                          09-DIC-82       3000
    ADAMS                          12-GEN-83       1100
    FORD                           03-DIC-81       3000A procedure cannot be used in a select statement.
    Max
    http://oracleitalia.wordpress.com

  • Why this query does not show the result?

    Why the query with the schema prefixed does not show the result and the query without schema display the correct results?
    SQL> select data_object_id,object_type from dba_objects where object_name='HR'.'JOBS';
    select data_object_id,object_type from dba_objects where object_name='HR'.'JOBS'
    ERROR at line 1:
    ORA-00933: SQL command not properly ended
    SQL> select data_object_id,object_type from dba_objects where object_name='HR.JOBS';
    no rows selected
    SQL> select data_object_id, OWNER, object_type from dba_objects where object_name='JOBS';
    DATA_OBJECT_ID     OWNER                          OBJECT_TYPE
    69662              HR                                 TABLE
                       OE                                 SYNONYM
    SQL> SELECT USER FROM DUAL;
    USER
    SYS

    Hi,
    the column object_name refers to a object_name which is 'JOBS', the column owner refers to the owner 'HR', the value isn't stored together, so you have to select the two columns. It is the same behaviour as every other table/view. Have a look at the values in the view DBA_OBJECTS.
    Herald ten Dam
    Superconsult.nl

  • TABLE(CAST()) function not returning the correct results in few scenarios.

    I am using TABLE(CAST()) operation in PL/SQL and it is returning me no data.
    Here is what I have done:
    1.     Created Record type
    CREATE OR REPLACE TYPE target_rec AS OBJECT
    target__id          NUMBER(10),
    target_entity_id NUMBER(10),
    dd           CHAR(3),
    fd           CHAR(3),
    code      NUMBER(10),
    target_pct      NUMBER,
    template_nm VARCHAR2(50),
    p_symbol      VARCHAR2(10),
    pm_init          VARCHAR2(3),
    target_name     VARCHAR2(20),
    targe_type     VARCHAR2(30),
    target_caption     VARCHAR2(30),
    sort_order      NUMBER (4)
    2.     Created Table type
    CREATE OR REPLACE TYPE target_arr AS TABLE OF target_rec
    3.     Created Stored procedure which accepts parameter of type target_arr and runs the Table(Cast()) function on it.
         Following is the simplified form of my procedure.
         PROCEDURE get_target_weights
         p_in_template_target IN target_arr,
         p_out_count          OUT NUMBER,
         IS
         BEGIN
              SELECT count(*) into p_out_count
         FROM TABLE(CAST(p_in_template_target AS                     target_arr)) arr;
         END;
    I am calling get_target_weights from my java code and passing p_in_template_target with 10140 records.
    Scenario 1: If target_pct in the last record is 0, p_out_count returned from the procedure is 0.
    Scenario 2: If target_pct in the last record is any other value(say 0.01), p_out_count returned from the procedure is 10140.
    Please help me understand why the Table(Cast()) is not returning the correct results in Scenario 1. Also adding or deleting any record from the test data returns the correct results (i.e. if keep target_pct in the last record as 0 but add or delete any record).
    Let me know how can I attach the test data I am using to help you debugging as I don’t see any Attach file button on Post Message screen on the forum.

    I am not able to reproduce this problem with a small data set. I can only reproduce with the data having 10140 records.
    I am not sure if this is the memory issue as adding a new record also solves the problem.
    This should not be the error because of wrong way of filling the records in java as for testing purpose I just saved the records which I am sending from java in a table. I updated the stored procedure as well to read the data from the table and then perform TABLE(CAST()) operation. I am still getting 0 as the output for scenario 1 mentioned in my last mail.
    Here is what I have updated:
    1.     Created the table target_table
    CREATE Table target_table
    target_id          NUMBER(10),
    target_entity_id NUMBER(10),
    dd           CHAR(3),
    fd           CHAR(3),
    code      NUMBER(10),
    target_pct      NUMBER,
    template_nm VARCHAR2(50),
    p_symbol      VARCHAR2(10),
    pm_init          VARCHAR2(3),
    target_name     VARCHAR2(20),
    target_type     VARCHAR2(30),
    target_caption     VARCHAR2(30),
    sort_order      NUMBER (4)
    2.     Inserted data into the table : The script has around 10140 rows. Pls let me know how can I send it to you
    3.     Updated procedure to read data from table and stored into variable of type target_arr. Run Table(cast()) operation on target_arr and get the count
    PROCEDURE test_target_weights
    IS
         v_target_rec target_table%ROWTYPE;
         CURSOR wt_cursor IS
         Select * from target_table;
         v_count NUMBER := 1;
         v_target_arr cws_target_arr:= target_arr ();
         v_target_arr_rec target_rec;
         v_rec_count NUMBER;
         BEGIN
         OPEN wt_cursor;
         loop
              fetch wt_cursor into v_target_rec; -- fetch data from table into local           record.
              exit when wt_cursor%notfound;
              --move data into target_arr
              v_target_arr_rec :=                     cws_curr_pair_entity_wt_rec(v_target_rec target_id,v_target_rec. target_entity_id,
                        v_target_rec.dd,v_target_rec.fd,v_target_rec.code,v_target_rec.target_pct,
         v_target_rec.template_nm,v_target_rec.p_symbol,v_target_rec.pm_init,v_target_rec.template_name,
         v_target_rec.template_type,v_target_rec.template_caption,v_target_rec.sort_order);
              v_target_arr.extend();
              v_target_arr(v_count) := v_target_arr_rec;
              v_count := v_count + 1;
         end loop;
         close wt_cursor;
         -- run table cast on target_arr
         SELECT count(*) into v_rec_count
         FROM TABLE(CAST(v_target_arr AS target_arr)) arr;
         DBMS_OUTPUT.enable;
         DBMS_OUTPUT.PUT_LINE('p_out_count ' || v_rec_count);
         DBMS_OUTPUT.PUT_LINE('v_count ' || v_count);
    END;
    Output is
    p_out_count 0
    v_count 10140
    Expected output
    p_out_count 10140
    v_count 10140

  • Returning the result of a database query to a client

    glassfish
    JAX-WS 2.0
    NetBeans 5.5
    Is it possible to send a CachedRowSet object to a client?
    I get an error when i try to do so. (I can't deploy the web service method that returns the CachedRowSet)
    Is there a better way to return the result of database query to a client?
    I'd appreciate any suggestions or sample code.

    Hi!
    The result of this query will be the max ID of users' IDs.
    Let say we have:
    String sql="select max(users.id) from users";
    Statement st = ctx.conn.createStatement();
    ResultSet rs = st.executeQuery(sql);
    rs.next();     
    So you can get the max Id in the following way:     
    int maxId=rs.getInt("id");
    Regards,
    Rossi

Maybe you are looking for