Sql Queries - adding calculated variables to views

Hello:
I'm trying to do add a calculated variable to my view that isn't an Entity
Attribute, its simple really but i don't know if I'm leaving something out or
not.
I add the "new Attribute" , call it nCompleted, type - number
I then check off everything as is required(as documented in Help)
for an Sql Derived Attribute, the following code is entered in the
Expression Box :
Select group_services.office, count(client_group_services.clnt_group_services_id) as nCompleted
Where group_services_id=client_group_services_id(+)
And client_group_services_id.result="Completed";
It isn't working, what am I missing????

Hello:
I'm trying to do add a calculated variable to my view that isn't an Entity
Attribute, its simple really but i don't know if I'm leaving something out or
not.
I add the "new Attribute" , call it nCompleted, type - number
I then check off everything as is required(as documented in Help)
for an Sql Derived Attribute, the following code is entered in the
Expression Box :
Select group_services.office, count(client_group_services.clnt_group_services_id) as nCompleted
Where group_services_id=client_group_services_id(+)
And client_group_services_id.result="Completed";
It isn't working, what am I missing???? Sheena:
It probably isn't working because of missing 'group by' clause. I don't know the exact detail of your query statement, but suppose you want to count number of employees in a dept, then you're query should look like:
select dept.deptno, dept.dname, count(emp.empno) as nCount
   from dept, emp where dept.deptno = emp.deptno(+)
   group by dept.deptno, dept.dname  // This group-by is important
OR if you want to use nested SELECT
select dept.deptno, dept.dname,
   (select count(emp.empno) from emp where dept.deptno=emp.deptno(+)) as nCount
   from dept

Similar Messages

  • ADF BC connection to SQL Server with parameterized variable for View Object

    Hi everyone
    I'm developing a BPM Application using Oracle BPM 11.1.1.5.0 and JDeveloper 11.1.1.5.0
    Following the thread from the link below, since this is a new topic, I decided to open a new thread.
    Re: ADF method call to fetch data from DB before the initiator page loads
    what I'm trying to do is to get a record from a database and show it to the user on the initiator UI using ADF BC and not the Database Adapter.
    I have been able to work with ADF BC and View Objects to get all the rows and show them to the user in a table.
    However, when I try to run the same query in the parameterized form to just return a single row, I hit a wall.
    In short, My problem is like this:
    I have an Application Module which has an entity object and a view object.
    My database is SQL Server 2008.
    when I try to create a new read only view object to return a single row I face the problem.
    The query I have in the query section of my View Object is like this:
    select *
    from dbo.Employee
    where EmployeeCode= 99which works fine.
    However when I define a bind variable, input_code for example, and change the query to the following it won't validate.
    select *
    from dbo.Employee
    where EmployeeCode= :input_codeIt just keeps saying
    >
    incorrect syntax near ":"
    >
    I don't know if this has to do with my DB not being Oracle or I'm doing something wrong.
    Can someone help me with this problem please?
    thanks in advance

    Hi
    This all seems complicated to me so I think my simplest way would be to use the java code in the aformentioned thread by Sudipto:
    public String getUserLogin() throws WorkflowException,
    BPMIdentityException,
    BPMUnsupportedAttributeException {
    String userId = "";
    IWorkflowServiceClient wfSvcClient;
    ITaskQueryService queryService;
    IWorkflowContext wfContext;
    // Get username of User Login
    String contextStr = ADFWorklistBeanUtil.getWorklistContextId();
    wfSvcClient = WorkflowService.getWorkflowServiceClient();
    queryService = wfSvcClient.getTaskQueryService();
    wfContext = queryService.getWorkflowContext(contextStr);
    userId = wfContext.getUser();
    return userId;
    } I don't know where and how I should put the code to be called when the view object loads though.
    I have created a class in the java class section of my view object which has two methods related to the bind variable input_empCode:
    getinput_empcode and setinput_empcode , as expected.
    however any code i try to put in those two would not be called at all!
    for example:
        public Integer getinput_empCode() {
            //return (Integer)getNamedWhereClauseParam("input_empCode");
            return 1444;
        }and
        public void setinput_empCode(Integer value) {
            //setNamedWhereClauseParam("input_empCode", value);
            setNamedWhereClauseParam("input_empCode", 666);
        }It just keeps filled with the values in the bind variable section.
    I don't know what I'm doing wrong here.
    would you show me the way?
    Thanks again

  • Problem occured when create a tree table for master-detail view objects using SQL queries?

    I am programming a tree table for master-detail view objects using SQL queries and these 2 view objects are not simple singel tables queries, and 2 complex SQL are prepared for master and view objects. see below:
    1. Master View object (key attribute is SourceBlock and some varaible bindings are used for this view object.)
    SELECT  cntr_list.SOURCE_BLOCK,                   
            sum(                   
             case when cntr_list.cntr_size_q = '20'                   
                  then cntr_list.cntr_qty                   
                  else 0 end ) as cntr20 ,                   
            sum(                   
             case when cntr_list.cntr_size_q = '40'                   
                  then cntr_list.cntr_qty                   
                  else 0 end ) as cntr40 ,                   
             sum(                   
             case when cntr_list.cntr_size_q = '45'                   
                  then cntr_list.cntr_qty                   
                  else 0 end ) as cntr45                    
    FROM (       
        SELECT yb1.BLOCK_M as SOURCE_BLOCK,       
               scn.CNTR_SIZE_Q,        
               count(scn.CNTR_SIZE_Q) AS cntr_qty        
        FROM  SHIFT_CMR scm, SHIFT_CNTR scn, YARD_BLOCK yb1, YARD_BLOCK yb2       
        WHERE       
        scm.cmr_n = scn.cmr_n             
        AND (scm.plan_start_dt BETWEEN to_date(:DateFrom,'YYYY/MM/DD HH24:MI:SS') AND to_date(:DateTo,'YYYY/MM/DD HH24:MI:SS')                 
        OR scm.plan_end_dt BETWEEN to_date(:DateFrom,'YYYY/MM/DD HH24:MI:SS') AND to_date(:DateTo,'YYYY/MM/DD HH24:MI:SS'))                 
        AND scm.shift_mode_c = :ShiftModeCode                           
        AND scm.end_terminal_c = :TerminalCode      
        AND scm.start_terminal_c = yb1.terminal_c                  
        AND scm.start_block_n = yb1.block_n                  
        AND substr(scn.start_location_c,(instr(scn.start_location_c,',',1,5)+1),instr(scn.start_location_c,',',1,6)-(instr(scn.start_location_c,',',1,5)+1)) BETWEEN yb1.slot_from_n AND yb1.slot_to_n                  
        AND scm.end_terminal_c = yb2.terminal_c                  
        AND scm.end_block_n = yb2.block_n                  
        AND substr(scn.end_location_c,(instr(scn.end_location_c,',',1,5)+1),instr(scn.end_location_c,',',1,6)-(instr(scn.end_location_c,',',1,5)+1)) BETWEEN yb2.slot_from_n AND yb2.slot_to_n           
        AND scn.status_c not in (1, 11)             
        AND scn.shift_type_c = 'V'             
        AND scn.source_c = 'S'       
        GROUP BY yb1.BLOCK_M, scn.CNTR_SIZE_Q       
    ) cntr_list       
    GROUP BY cntr_list.SOURCE_BLOCK
    2. Detail View object (key attributes are SourceBlock and EndBlock and same varaible bindings are used for this view object.)
    SELECT  cntr_list.SOURCE_BLOCK, cntr_list.END_BLOCK,                
            sum(                     
             case when cntr_list.cntr_size_q = '20'                     
                  then cntr_list.cntr_qty                     
                  else 0 end ) as cntr20 ,                     
            sum(                     
             case when cntr_list.cntr_size_q = '40'                     
                  then cntr_list.cntr_qty                     
                  else 0 end ) as cntr40 ,                     
             sum(                     
             case when cntr_list.cntr_size_q = '45'                     
                  then cntr_list.cntr_qty                     
                  else 0 end ) as cntr45                      
    FROM (         
        SELECT yb1.BLOCK_M as SOURCE_BLOCK,     
               yb2.BLOCK_M as END_BLOCK,  
               scn.CNTR_SIZE_Q,          
               count(scn.CNTR_SIZE_Q) AS cntr_qty          
        FROM  SHIFT_CMR scm, SHIFT_CNTR scn, YARD_BLOCK yb1, YARD_BLOCK yb2         
        WHERE         
        scm.cmr_n = scn.cmr_n               
        AND (scm.plan_start_dt BETWEEN to_date(:DateFrom,'YYYY/MM/DD HH24:MI:SS') AND to_date(:DateTo,'YYYY/MM/DD HH24:MI:SS')                   
        OR scm.plan_end_dt BETWEEN to_date(:DateFrom,'YYYY/MM/DD HH24:MI:SS') AND to_date(:DateTo,'YYYY/MM/DD HH24:MI:SS'))                   
        AND scm.shift_mode_c = :ShiftModeCode                             
        AND scm.end_terminal_c = :TerminalCode        
        AND scm.start_terminal_c = yb1.terminal_c                    
        AND scm.start_block_n = yb1.block_n                    
        AND substr(scn.start_location_c,(instr(scn.start_location_c,',',1,5)+1),instr(scn.start_location_c,',',1,6)-(instr(scn.start_location_c,',',1,5)+1)) BETWEEN yb1.slot_from_n AND yb1.slot_to_n                    
        AND scm.end_terminal_c = yb2.terminal_c                    
        AND scm.end_block_n = yb2.block_n                    
        AND substr(scn.end_location_c,(instr(scn.end_location_c,',',1,5)+1),instr(scn.end_location_c,',',1,6)-(instr(scn.end_location_c,',',1,5)+1)) BETWEEN yb2.slot_from_n AND yb2.slot_to_n             
        AND scn.status_c not in (1, 11)               
        AND scn.shift_type_c = 'V'               
        AND scn.source_c = 'S'         
        GROUP BY yb1.BLOCK_M, yb2.BLOCK_M, scn.CNTR_SIZE_Q         
    ) cntr_list         
    GROUP BY cntr_list.SOURCE_BLOCK, cntr_list.END_BLOCK
    3. I create a view link to create master-detail relationship for these 2 view objects.
    masterview.SourceBlock (1)->detailview.SourceBlock (*).
    4. I create a tree table using these 2 view objects with master-detail relationship.
    When I set default value for variable bindings of these 2 view objects and the matching records exist, tree table can work well. I can expand the master row to display detail row in UI.
    But I need to pass in dymamic parameter value for variable bindings of these 2 view objects, tree table cannnot work again. when I expand the master row and no detail row are displayed in UI.
    I am sure that I pass in correct parameter value for master/detail view objects and matching records exist.
    Managed Bean:
            DCIteratorBinding dc = (DCIteratorBinding)evaluteEL("#{bindings.MasterView1Iterator}");
            ViewObject vo = dc.getViewObject();
            System.out.println("Before MasterView1Iterator vo.getEstimatedRowCount()="+ vo.getEstimatedRowCount());
            System.out.println("Before MasterView1Iterator ShiftModeCode="+ vo.ensureVariableManager().getVariableValue("ShiftModeCode"));
            vo.ensureVariableManager().setVariableValue("DateFrom", dateFrom);
            vo.ensureVariableManager().setVariableValue("DateTo", dateTo);
            vo.ensureVariableManager().setVariableValue("ShiftModeCode", shiftModeC);
            vo.ensureVariableManager().setVariableValue("TerminalCode", terminalCode);
            vo.executeQuery();
            System.out.println("MasterView1Iterator vo.getEstimatedRowCount()="+ vo.getEstimatedRowCount());
            DCIteratorBinding dc1 = (DCIteratorBinding)evaluteEL("#{bindings.DetailView1Iterator}");
            ViewObject vo1 = dc1.getViewObject();
            System.out.println("Before DetailView1Iterator vo1.getEstimatedRowCount()="+ vo1.getEstimatedRowCount());
            System.out.println("Before DetailView1Iterator ShiftModeCode="+ vo1.ensureVariableManager().getVariableValue("ShiftModeCode"));
            vo1.ensureVariableManager().setVariableValue("DateFrom", dateFrom);
            vo1.ensureVariableManager().setVariableValue("DateTo", dateTo);
            vo1.ensureVariableManager().setVariableValue("ShiftModeCode", shiftModeC);
            vo1.ensureVariableManager().setVariableValue("TerminalCode", terminalCode);
            vo1.executeQuery();
            System.out.println("after DetailView1Iterator vo1.getEstimatedRowCount()="+ vo1.getEstimatedRowCount());
    5.  What's wrong in my implementation?  I don't have no problem to implement such a tree table if using simple master-detail tables view object, but now I have to use such 2 view objects using complex SQL for my requirement and variable bindings are necessary for detail view object although I also think a bit strange by myself.

    Hi Frank,
    Thank you and it can work.
    public void setLowHighSalaryRangeForDetailEmployeesAccessorViewObject(Number lowSalary,
                                                                              Number highSalary) {
            Row r = getCurrentRow();
            if (r != null) {
                RowSet rs = (RowSet)r.getAttribute("EmpView");
                if (rs != null) {
                    ViewObject accessorVO = rs.getViewObject();
                    accessorVO.setNamedWhereClauseParam("LowSalary", lowSalary);
                    accessorVO.setNamedWhereClauseParam("HighSalary", highSalary);
                executeQuery();
    but I have a quesiton in this way. in code snippet, it is first getting current row of current master VO to determine if update variables value of detail VO. in my case, current row is possibly null after executeQuery() of master VO and  I have to change current row manually like below.
    any idea?
                DCIteratorBinding dc = (DCIteratorBinding)ADFUtil.evaluateEL("#{bindings.SSForecastSourceBlockView1Iterator}");
                ViewObject vo = dc.getViewObject();           
                vo.ensureVariableManager().setVariableValue("DateFrom", dateFrom);
                vo.ensureVariableManager().setVariableValue("DateTo", dateTo);
                vo.ensureVariableManager().setVariableValue("ShiftModeCode", shiftModeC);
                vo.ensureVariableManager().setVariableValue("TerminalCode", terminalCode);
                vo.executeQuery();
                vo.setCurrentRowAtRangeIndex(0);
                ((SSForecastSourceBlockViewImpl)vo).synchornizeAccessorVOVariableValues();

  • Out of memory Error while querying SQL Script based Calculation View

    Hi All,
    I wanted to test the performance of Graphical and SQL Script based Calculation views.
    Created Graphical (CA_GRPH) and SQL Script (CA_SQL) Calculation views.
    Analytic View (AN_GRPH) for both Calculation views are the same which is Graphical based (90 Attributes and 5 Measures)
    In Analytic View data foundation I have a Fact table which has 1.5 Billion records and 9 Dimension Tables –collectively 500 million records (7 Attribute Views). 9 Referential joins with cardinality N:1 and 1 Referential join with cardinality N:N.
    I wanted to keep (CA_GRPH) and (CA_SQL) as a base Calculation views and leverage those to create various calculation views (Will be creating different Calc views for respective Business segments)
    In order to test this I have created below calc views on top of base calc views.
    Graphical Based: Created (CA_GRAPH_XYZ) by having CA_GRPH in projection with 30 Calculated Columns. – This retrieves data in 13 secs
    SQL Script Based: Created (CA_GRPH_ABC) by having CA_SQL in projection view with 30 calculated columns – This errors out after 1.50 mins.
    Could not execute 'SELECT "COLUMN_A","COLUMN _B"," COLUMN _C"," COLUMN _D", SUM("COLUMN _REVENUE") AS ...' in 1:50.480 minutes .
    SAP DBTech JDBC: [2048]: column store error:  [2048] column store error: search table error: [1000002] Error executing physical plan: exception 1000002:
    ltt/impl/memory.cpp:63
    Out of memory ; $size$=1507711; $name$=ihm; $type$=pool; $inuse_count$=170104; $allocated_size$=219215007925
    exception 1000002:
    Any suggestion / help in fixing this issue will be greatly appreciated.
    Regards,
    Av

    Hi Raj,
    Thanks for your time, please find edited snap hot of Analytic View (AN_GRPH) below,
    Calculation view(CA_SQL)
            /********* Begin Procedure Script ************/
    BEGIN
           var_out =
         SELECT
                "COLUMN_1"
                "COLUMN_2",
                "COLUMN_84",
                "COLUMN_85;",
                SUM("REVN") AS "REVN",
                SUM("MGN") AS "MGN",
                SUM("ORD_QTY") AS "ORD_QTY",
                SUM("SYS_QTY1") AS "SYS_QTY1",
                SUM("SYS_QTY") AS "SYS_QTY"
    FROM
          "_SYS_BIC"."XYZ/AN_GRPH"
    GROUP BY
                "COLUMN_1"
                "COLUMN_2",
                "COLUMN_84",
                "COLUMN_85";
    END
    /********* End Procedure Script ************/
    Later i have built one more Calculation view(CA_GRPH_ABC) using (CA_SQL)in projection. i have 30 calculated measures in this final calc view. this final calc view is throwing above mentioned error.
    Not sure if i can use SQL script based calc view in graphical based calc views?
    Regards,
    AV

  • How to change sql expression of SQL-Calculated Attribute of view object ?

    Hi
    jdev 11.1.1.5
    I have a view object with a SQL-Calculated Attribute (sumAnalytic) how can I change sql expression of this attribute in runtime?
    for example in application module method??

    Hi Mr Timo
    Thanks for your reply but I do not need dynamic vo because I can not change all of my vo
    I only need to change expression of SQL-Calculated Attribute of view object in run time.
    For this I set expression in view object something like this 'select 2 from dual' and in run time in my AM method I get the vo query and replace 'select 2 from dual' with something like 'selet sum(amnt) over (partition by 1)' and set new query.
    But I think the better solution must exist
    Thanks

  • Need help in SQL Queries using GUI controls or variables

    Hello, all
    I have a big problem (I have already had with Visual Basic a few mounths ago) with Java while writing my SQL Queries.
    I would like to know how I must do to use variable data or GUI control data in my SQL Query to select only some records.
    Here, my first Query that works without any problem (no WHERE clause !!!) :
    Statement requeteBedes = connectBedes.createStatement();
    ResultSet resultatSeries = requeteBedes.executeQuery("SELECT * FROM Series");
    initComboBoxSeries(resultatSeries);the method "initComboBoxSeries" fills a JComboBox with all the names of the series in my database.
    Here comes my problem.I would like to use the value of the selected "series" in the JComboBox to search in another table of the same Database. I made another statement but it returns a Null ResultSet :
    ResultSet resultatSearchAlbumsFromSeries = requeteBedes.executeQuery("SELECT * FROM bandes_dess WHERE  ser_nom = '" + strComboBoxSeriesSelected + "' "); The variable strComboBoxSeriesSelected contains the value of the selected line in the combobox with all the series, filled after the first query that is here above and that works very well.
    Could some one help me and tell me how I must use variables or GUI controls values in my SQL Queries or tell me if there is a place where I could find an explanation of that kind of problems (like more "advanced SQL Queries", as the ones currently used in all the Learning Java 2 books)
    Thank you all for your help.
    Christian.

    executeQuery() will never return null. At least that's what the spec says. You are probably catching an exception (probably a syntax error caused by a single quote in strComboBoxSeriesSelected) and ignoring it. Or do you mean the ResultSet contains no rows?
    Anyway, to use parameterized queries, take a look at PreparedStatements. Your code should look like this using PreparedStatement:Statement requeteBedes = connectBedes.prepareStatement("SELECT * FROM bandes_dess WHERE  ser_nom = ?");
    requeteBedes.setString(1, strComboBoxSeriesSelected);
    ResultSet resultatSeries = requeteBedes.executeQuery();Alin.

  • [DW 8.02 + PHP] how to use variables in advanced SQL queries

    Hi all,
    I can't find a way to use variables in an SQL query after
    updating
    dreamweaver 8.02.
    I always get error messages that says: 'missing variable
    type:myvariablename', undefined#myvariablename... and so on.
    What is the correct way to use variables?
    I usually set a variable in a PHP statement (example: <?
    $today=date('Y-m-d'); ?>)
    and then I compare this variable in the SQL query.
    What is the correct syntax for variable in DW 8.02 in
    advanced SQL
    queries?
    TIA
    tony

    sweetman wrote:
    > I'm editing a website created with DW 8.01 and MX
    Kollection.
    >
    > I updated DW to 8.02 and now I can't edit an existing
    SQL query.
    > I always get an error message 'Missing variable type'
    and I can't go
    > on.
    InterAKT released a new version of Kollection to cope with
    the 8.0.2
    changes. AFAIK, you should be able to download the updated
    version from
    your InterAKT account area.
    David Powers, Adobe Community Expert
    Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
    Author, "PHP Solutions" (friends of ED)
    http://foundationphp.com/

  • Added Schemas can be viewed in SQL workshop but can't while creating Form

    Hi Friends
    We are using APEX 3.1 and Oracle 10.2.0 at back end.
    I can assign other schemas to a work space successfully.
    The Problem is that
    Added schemas can be viewed in SQL Workshop (SQL commands)
    But can not view the added schemas in the list when want to create a form based on table
    Regards
    Jazib

    Jazib,
    When you select an application the application's Owner attribute determines which tables/views you see in the wizard LOVs. If your application owner (parsing schema) is FOO and you want to create a form on table BAR.T then you have to grant select on BAR.T to FOO.
    Scott

  • SQL Queries don’t recognize Package member variables.

    Hi,
    I have a package defined like this:
    CREATE OR REPLACE PACKAGE PROD.PKG_BSYS_COMMON
    AS
    MAX_RETURN_ROWS NUMBER(6) :=1000;
    END PKG_BSYS_COMMON;
    The problem is that I cannot use MAX_RETURN_ROWS in my SQL queries:
    SELECT
    FROM
    CLIENT
    WHERE
    ROWNUM < PROD.PKG_BSYS_COMMON.MAX_RETURN_ROWS
    Is there any way to use that package member variable in my queries?
    This is a simplified explanation of our problem and it is very important for our business to avoid hardcoding constants in queries and define all of them in a central location. Is there a better way doing this?
    Any help would be appreciated,
    Alan

    CREATE OR REPLACE PACKAGE PKG_BSYS_COMMON
    AS
    function max_return_rows return number ;
    END PKG_BSYS_COMMON;
    CREATE OR REPLACE PACKAGE body PKG_BSYS_COMMON  as
    function max_return_rows return number is
    begin
    return(1000);
    end;
    end PKG_BSYS_COMMON;
    select pkg_bsys_common.max_return_rows from dual;
    MAX_RETURN_ROWS
               1000                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • SQL queries against a database view from an external system?

    Hi,
    I have a question about Database views in se11.
    Is it possible to create a database view and that do SQL queries against this  view from an
    external system, Not a SAP system?
    Please, I need you help.
    Best Regards
    Annika

    Hi Annika,
    it is possible , yes... but depends on your database systems in the SAP source DB and the external DB
    (easier if they are the same,  i.e. both ORACLE) - check out with your BASIS team (they have to create something like a "database link" in the external DB system  that you can use to access the tables in the SAP source).
    In the external DB you sure can create a view on these "remote" tables.
    We used this to pull data form SAP DB  to another DB system (both ORACLE based).
    But this is NOT supported by SAP , so be carefull. Below is the restriction for ORACLE (as well for other DB systems )
    see SAP note 581312 "Oracle database: licensing restrictions"
    As of point 3, it follows that direct access to the Oracle database is
    only allowed for tools from the areas of system administration and
    monitoring. If other software is used, the following actions, among
    other things, are therefore forbidden at database level:
    * Querying/changing/creating data in the database
    * Using ODBC or other SAP external access methods
    This means that additional application software is only allowed if this
    accesses the database through SAP interfaces (for example, RFC, SAP J2EE
    or BAPI).
    I would say if you KNOW the tables involved (using valid WHERE conditions and joins )
    and don't start queries from hell (ad-hoc type) wich can bring down your SAP system performance
    you can try it.
    But be warned...
    good luck...
    bye
    yk

  • View SQL queries during runtime

    In the Jdev tutorials I noticed the running tab displaying the sql queries that are being run in the application. How can I turn this on? Using 10.1.3.0.4
    thanks

    Please see sections "5.5.3.2 Enabling ADF Business Components Debug Diagnostics" , "8.3.4 Debugging the Application Module Using the Business Components Tester", and "Chapter 24 Testing and Debugging Web Applications" of the ADF Developer's Guide for Forms/4GL Developers on the ADF Learning Center at http://www.oracle.com/technology/products/adf/learnadf.html for more useful information on this.

  • Gtksql pkgbuild. Simple GUI for sql queries.

    This is simple program for running sql queries. I made this pkgbuild some time ago but I'm not sure how much it is good. Gtksql should support both mysql and postgresql but postgresql support is broken (probably to old). Developer promises a brand new gtk2 based application. We will see...
    Since I can't make this pkgbuild any better I'm just posting it.
    gtksql PKGBUILD
    pkgname=gtksql
    pkgver=0.4.2
    pkgrel=1
    pkgdesc="Gtk front-end for sql queries"
    url="http://gtksql.sourceforge.net/"
    depends=('lua' 'gtk')
    makedepends=('mysql')
    source=(http://dl.sourceforge.net/sourceforge/gtksql/$pkgname-$pkgver.tar.gz)
    md5sums=('a0ba598027cd49f69f951a31342b51fd')
    build() {
    cd $startdir/src/$pkgname-$pkgver
    ./configure --prefix=/usr
    --with-mysql
    --with-lua
    make || return 1
    make prefix=$startdir/pkg/usr install

    Hello:
    I'm trying to do add a calculated variable to my view that isn't an Entity
    Attribute, its simple really but i don't know if I'm leaving something out or
    not.
    I add the "new Attribute" , call it nCompleted, type - number
    I then check off everything as is required(as documented in Help)
    for an Sql Derived Attribute, the following code is entered in the
    Expression Box :
    Select group_services.office, count(client_group_services.clnt_group_services_id) as nCompleted
    Where group_services_id=client_group_services_id(+)
    And client_group_services_id.result="Completed";
    It isn't working, what am I missing???? Sheena:
    It probably isn't working because of missing 'group by' clause. I don't know the exact detail of your query statement, but suppose you want to count number of employees in a dept, then you're query should look like:
    select dept.deptno, dept.dname, count(emp.empno) as nCount
       from dept, emp where dept.deptno = emp.deptno(+)
       group by dept.deptno, dept.dname  // This group-by is important
    OR if you want to use nested SELECT
    select dept.deptno, dept.dname,
       (select count(emp.empno) from emp where dept.deptno=emp.deptno(+)) as nCount
       from dept

  • Monitoring Oracle SQL queries in VBA

    I currently use VBA with Excel to generate reports based on data within an Oracle 9 database. The amount of data is very large and the reports can take a long time to process. I have added status bar progress indicators for the majority of the report processing tasks to inform the user of what is going on.
    The problem is that I need to be able to monitor the progress of the main SQL queries since they take upwards of a few minutes to run each (mainly because I need to rank and order data). I currently use code similar to that shown below to query the database from VBA.
    Sub simpleVersion()
    Dim username As String
    Dim password As String
    Dim sid As String
    Dim objSession As Object
    Dim objdatabase As Object
    Dim OraDynaset As Object
    Dim strSQL As String
    username = "user"
    password = "pass"
    sid = "database"
    ' connect to database
    Set objSession = CreateObject("OracleInProcServer.XOraSession")
    Set objdatabase = objSession.OpenDatabase(sid, username & "/" & password, 0&)
    strSQL = "select latitude, longitude, otherdata from scatter where otherdata > 50 order by latitude, longitude"
    ' This command takes a long time to execute when doing ranks/order bys
    Set OraDynaset = objdatabase.DBCreateDynaset(strSQL, 0&)
    Do While OraDynaset.EOF = False
    'Process the data and put on a spreadsheet
    'Status bar messages can be used here without problems
    OraDynaset.MoveNext
    Loop
    Set OraDynaset = Nothing
    Set objSession = Nothing
    objdatabase.Close
    Set objdatabase = Nothing
    End Sub
    When the DBCreateDynaset command is executed VBA waits until the dynaset data is retrieved from oracle. I would like to be able to do something similar to the pseudo code below.
    Execute SQL to create dynaset
    Do while still obtaining dynaset
    Check v$session_longops - Indicate time taken / remaining on status bar
    Loop
    I have found that if you execute a large query without any tasks that require the whole dataset before they can begin (ranks, ordering etc) the dynaset is created almost instantly and excel does not freeze up.
    With non dynaset operations such as inserts it is possible to run the query in non blocking mode. I am able to monitor the progress of the query and indicate it to the user.
    Dim myStatement As OraSqlStmt
    Set myStatement = objdatabase.CreateSql(strSQL, ORASQL_NONBLK)
    Do While myStatement.NonBlockingState = ORASQL_STILL_EXECUTING
    DoEvents
    Select Case intSpinCount
    Case 1
    Application.StatusBar = "Please Wait. Calculating data /"
    Case 2
    Application.StatusBar = "Please Wait. Calculating data -"
    Case 3
    Application.StatusBar = "Please Wait. Calculating data \"
    Case 4
    Application.StatusBar = "Please Wait. Calculating data |"
    intSpinCount = 0
    End Select
    Application.Wait TimeSerial(Hour(Now()), Minute(Now()), Second(Now()) + 1)
    intSpinCount = intSpinCount + 1
    Loop
    Non blocking mode is explained here. However dynasets are not supported.
    http://download-west.oracle.com/docs/cd/A91202_01/901_doc/win.901/a90173/o4o00022.htm
    I have tried using pl/sql to insert the data requested into a temporary table and then the normal select statement to get the data back out. However since the data stored in a table is not ordered it isn’t much help to me since I still have to do the order by command.
    Anyone got any ideas?
    All help is much appreciated.

    Dear taktang
    I'm a newbie. I'd be grateful if you would tell me where to find "oracle-base"
    thanks
    mik3

  • Maintaining SQL Queries in a separate text file

    Hi,
    I am working on web based project using Spring MVC framework and I am maintaining all SQL queries in a separate text file so that I can change them any time when needed. I just want to know am I doing right, it this a optmistict way of coding??

    >
    I am working on web based project using Spring MVC framework and I am maintaining all SQL queries in a separate text file so that I can change them any time when needed. I just want to know am I doing right, it this a optmistict way of coding??
    >
    The best place to store the queries, and HOW to store them depends on your architecture and on how your application is being used.
    Is this a single-user application on a user's pc? Or is your application located on an application server in the middle-tier?
    The queries should be stored where they will be used. Your queries should be stored in the tier where your application code will reside. On the client PC for a single-user app, on the application server for a 3-tier app and incorporated into stored procedures/functions/packages if part of a database app.
    If your application is totally external to the database (e.g. a reporting app) then it doesn't make sense for you to become part of the database architecture. An org isn't going to let you create objects in the database to store your queries when your queries are not part of the database application. That puts the burden on them to backup your objects, restore them for your and provide support to you and your application.
    What format to store the queries in is a different issue. A major criteria is the type of queries you are using and how they are used. Many apps that query the database cannot just use hard-coded queries that are never modified. Users need to be able to provide parameters (e.g. name, ID, state, etc) to select just the data that they want.
    That means the base query itself may not even be valid syntax but needs to have a WHERE clause added. Prepared statements and queries that use bind variables ('WHERE ID = ?') are typically used for these.
    One method of storage is to use Java property files that use name=value pairs. Using property files makes it easy to use Java to find a query by name and load it for you. Then your code would have functionality to modify the query to provide the parameter 'bind' values and execute it.
    There are also frameworks available for handling database related functionality. There is no need for you to write your own libraries for this. I suggest you locate a suitable framework to use.

  • Monitoring SQL Queries

    I work with IBM Cognos Business Intelligence software. Clients create reports. The data is on SQL Server 2008 R2. The client writes reports and behind the scenes Cognos creates SQL queries to retrieve the data for the report. I do not have access within
    Cognos to view all the SQL queries used to create a report. Sometimes the reports are really complicated, with many calculations on large amounts of data, and they can run for hours. How can i see the actual queries that are causing the problems? I would
    need to limit it to a specific database at a minimum.

    Your question is very general. The slowness could be caused be missing index, resource bottleneck etc.  You need start investigate where sql server is waiting the time,this can done by wait stats analysis.  use the code bellow find out the wait 
    WITH Waits AS
    (SELECT wait_type, wait_time_ms / 1000. AS wait_time_s,
    100. * wait_time_ms / SUM(wait_time_ms) OVER() AS pct,
    ROW_NUMBER() OVER(ORDER BY wait_time_ms DESC) AS rn
    FROM sys.dm_os_wait_stats
    WHERE wait_type NOT IN ('CLR_SEMAPHORE','LAZYWRITER_SLEEP','RESOURCE_QUEUE','SLEEP_TASK'
    ,'SLEEP_SYSTEMTASK','SQLTRACE_BUFFER_FLUSH','WAITFOR', 'LOGMGR_QUEUE','CHECKPOINT_QUEUE'
    ,'REQUEST_FOR_DEADLOCK_SEARCH','XE_TIMER_EVENT','BROKER_TO_FLUSH','BROKER_TASK_STOP','CLR_MANUAL_EVENT'
    ,'CLR_AUTO_EVENT','DISPATCHER_QUEUE_SEMAPHORE', 'FT_IFTS_SCHEDULER_IDLE_WAIT'
    ,'XE_DISPATCHER_WAIT', 'XE_DISPATCHER_JOIN', 'SQLTRACE_INCREMENTAL_FLUSH_SLEEP'))
    SELECT W1.wait_type,
    CAST(W1.wait_time_s AS DECIMAL(12, 2)) AS wait_time_s,
    CAST(W1.pct AS DECIMAL(12, 2)) AS pct,
    CAST(SUM(W2.pct) AS DECIMAL(12, 2)) AS running_pct
    FROM Waits AS W1
    INNER JOIN Waits AS W2
    ON W2.rn <= W1.rn
    GROUP BY W1.rn, W1.wait_type, W1.wait_time_s, W1.pct
    HAVING SUM(W2.pct) - W1.pct < 99 OPTION (RECOMPILE);
    Also pls see the link 
    http://technet.microsoft.com/en-us/library/dd672789(v=sql.100).aspx
    vt
    Please mark answered if I've answered your question and vote for it as helpful to help other user's find a solution quicker

Maybe you are looking for

  • MSI 770-C45 locking up/blue screening/other errors on boot

    I recently built a new HTPC and have been having allot of problems getting it to boot.  It may take 10-15min of trying to boot up over and over with random blue screens, lockups, or errors that the C drive needs to be checked for consistency before W

  • My iphone 4 is not syncing with itunes

    I just updated iTunes to the lastest version so that I could update my iphone4 to the iOS 5 operating system, but since I've updated itunes its no longer syncing with my phone when I plug it in.  It was working just fine right before the update of iT

  • Xml document transfer from JSP app to an ASP app

    Hello, The client has an existing Active Server Pages application. In-house we have built another application in JSP. We need to send an xml document that we are generating in Java Server Pages along with session login data to the existing ASP applic

  • Strange new issue

    I was in the midst of compiling my code and running it, making changes and saving them under a new name and then compiling and running the new java file(to preserve the origingal file). I wasn't having any issues compiling or running and then all of

  • I have an internet light, but my internet does not work.

    Ok so here's the deal.  My knowledge of computers definetly above average, but i'm not a genius.  OK.  I have a westell modem\router combo.  The signal is so weak on it that i can't even connect my psp with it in the next room.  So i bought a Linksys