Cannot execute an SQL query

Hello

I am a newbie in scripting SQL.

I am trying to build a script below, please suggest me where I'm going wrong,

When I run it I get the following:

ORA-00937: not a single group group function

00937 00000 - 'not a single-group function.

* Cause:

* Action:

Error on line: 1 column: 91

I really appreciate your help and if you have any suggestions to optimize the query, Yes please help me with this too.

The query is as follows:

SELECT "BATCH_ACTUAL" AS BATCH_NAME, "CDA" AS DATAVIEW, CALCACCTTYPE, TRIM (GBOBJ) 9. SUBSTR (('0000' ||)) (ACCOUNTS OF TRIM (GBSUB)), 0, 4),.

CASE

When (GBLT) TRIM <>TRIM (GBLT) <>'EU' AND 'US' THEN

TRIM (GBMCU)

WHEN TO_NUMBER (TO_CHAR (SYSDATE, 'YY'), 99) < 9 THEN

TRIM (GBMCU) | TRIM (GBLT)

ENTITY FINAL,

CASE

WHEN (TRIM (GBOBJ) < '5000' AND <>the SUM (PYC + AMOUNT) 0 AND SUBSTR (TRIM (GBLT), 0, 1) <>'U')

OR (TRIM (GBOBJ) > ' 5000' AND AMOUNT <>0 AND SUBSTR (TRIM (GBLT), 0, 1) <>'U')

OR (TRIM (GBOBJ) > = <>'A' AND the AMOUNT 0 AND SUBSTR (TRIM (GBLT), 0, 1) = 'U') THEN

PYC

WHEN TRIM (GBMCU) < '9400' OR TRIM (GBMCU) > '9800' OR TRIM (GBMCU) = '9500' THEN

PYC / 100

END PYC

Of

(

SELECT

GBMCU,

GBOBJ,

GBSUB,

GLBT,

GBSBLT,

GBSBL,

MCRP29,

GBAPYC ACE PYC,

GBCTRY,

GBFY,

CASE

WHEN)

CASE

WHEN TO_NUMBER (TO_CHAR (SYSDATE, 'MM'), 99)-9 < = 0

THEN (TO_NUMBER (TO_CHAR (SYSDATE, 'MM'), 99)-9) + 12

OF ANOTHER TO_NUMBER (TO_CHAR (SYSDATE, 'MM'), 99)-9

END) = 1

THEN GBAN01

WHEN)

CASE

WHEN TO_NUMBER (TO_CHAR (SYSDATE, 'MM'), 99)-9 < = 0

THEN (TO_NUMBER (TO_CHAR (SYSDATE, 'MM'), 99)-9) + 12

OF ANOTHER TO_NUMBER (TO_CHAR (SYSDATE, 'MM'), 99)-9

END) = 2

THEN GBAN01 + GBAN02

WHEN)

CASE

WHEN TO_NUMBER (TO_CHAR (SYSDATE, 'MM'), 99)-9 < = 0

THEN (TO_NUMBER (TO_CHAR (SYSDATE, 'MM'), 99)-9) + 12

OF ANOTHER TO_NUMBER (TO_CHAR (SYSDATE, 'MM'), 99)-9

END) = 3

THEN GBAN01 + GBAN02 + GBAN03

WHEN)

CASE

WHEN TO_NUMBER (TO_CHAR (SYSDATE, 'MM'), 99)-9 < = 0

THEN (TO_NUMBER (TO_CHAR (SYSDATE, 'MM'), 99)-9) + 12

OF ANOTHER TO_NUMBER (TO_CHAR (SYSDATE, 'MM'), 99)-9

END) = 4

THEN GBAN01 + GBAN02 + GBAN03 + GBAN04

WHEN)

CASE

WHEN TO_NUMBER (TO_CHAR (SYSDATE, 'MM'), 99)-9 < = 0

THEN (TO_NUMBER (TO_CHAR (SYSDATE, 'MM'), 99)-9) + 12

OF ANOTHER TO_NUMBER (TO_CHAR (SYSDATE, 'MM'), 99)-9

END) = 5

THEN GBAN01 + GBAN02 + GBAN03 + GBAN04 + GBAN05

WHEN)

CASE

WHEN TO_NUMBER (TO_CHAR (SYSDATE, 'MM'), 99)-9 < = 0

THEN (TO_NUMBER (TO_CHAR (SYSDATE, 'MM'), 99)-9) + 12

OF ANOTHER TO_NUMBER (TO_CHAR (SYSDATE, 'MM'), 99)-9

END) = 6

THEN GBAN01 + GBAN02 + GBAN03 + GBAN04 + GBAN05 + GBAN06

WHEN)

CASE

WHEN TO_NUMBER (TO_CHAR (SYSDATE, 'MM'), 99)-9 < = 0

THEN (TO_NUMBER (TO_CHAR (SYSDATE, 'MM'), 99)-9) + 12

OF ANOTHER TO_NUMBER (TO_CHAR (SYSDATE, 'MM'), 99)-9

END) = 7

THEN GBAN01 + GBAN02 + GBAN03 + GBAN04 + GBAN05 + GBAN06 + GBAN07

WHEN)

CASE

WHEN TO_NUMBER (TO_CHAR (SYSDATE, 'MM'), 99)-9 < = 0

THEN (TO_NUMBER (TO_CHAR (SYSDATE, 'MM'), 99)-9) + 12

OF ANOTHER TO_NUMBER (TO_CHAR (SYSDATE, 'MM'), 99)-9

END) = 8

THEN GBAN01 + GBAN02 + GBAN03 + GBAN04 + GBAN05 + GBAN06 + GBAN07 + GBAN08

WHEN)

CASE

WHEN TO_NUMBER (TO_CHAR (SYSDATE, 'MM'), 99)-9 < = 0

THEN (TO_NUMBER (TO_CHAR (SYSDATE, 'MM'), 99)-9) + 12

OF ANOTHER TO_NUMBER (TO_CHAR (SYSDATE, 'MM'), 99)-9

END) = 9

THEN GBAN01 + GBAN02 + GBAN03 + GBAN04 + GBAN05 + GBAN06 + GBAN07 + GBAN08 + GBAN09

WHEN)

CASE

WHEN TO_NUMBER (TO_CHAR (SYSDATE, 'MM'), 99)-9 < = 0

THEN (TO_NUMBER (TO_CHAR (SYSDATE, 'MM'), 99)-9) + 12

OF ANOTHER TO_NUMBER (TO_CHAR (SYSDATE, 'MM'), 99)-9

END) = 10

THEN GBAN01 + GBAN02 + GBAN03 + GBAN04 + GBAN05 + GBAN06 + GBAN07 + GBAN08 + GBAN09 + GBAN10

WHEN)

CASE

WHEN TO_NUMBER (TO_CHAR (SYSDATE, 'MM'), 99)-9 < = 0

THEN (TO_NUMBER (TO_CHAR (SYSDATE, 'MM'), 99)-9) + 12

OF ANOTHER TO_NUMBER (TO_CHAR (SYSDATE, 'MM'), 99)-9

END) = 11

THEN GBAN01 + GBAN02 + GBAN03 + GBAN04 + GBAN05 + GBAN06 + GBAN07 + GBAN08 + GBAN09 + GBAN10 + GBAN11

WHEN)

CASE

WHEN TO_NUMBER (TO_CHAR (SYSDATE, 'MM'), 99)-9 < = 0

THEN (TO_NUMBER (TO_CHAR (SYSDATE, 'MM'), 99)-9) + 12

OF ANOTHER TO_NUMBER (TO_CHAR (SYSDATE, 'MM'), 99)-9

END) = 12

THEN GBAN01 + GBAN02 + GBAN03 + GBAN04 + GBAN05 + GBAN06 + GBAN07 + GBAN08 + GBAN09 + GBAN10 + GBAN11 + GBAN12

ENDING AMOUNT

DTA. F0902,

DTA. F0006

WHERE GBCTRY = SUBSTR (TO_CHAR (SYSDATE, 'YYYY'), 0, 2)

AND GBFY =)

CASE

WHEN (TO_NUMBER (TO_CHAR (SYSDATE, 'MM'), 99)-9) < = 0

THEN TO_NUMBER (TO_CHAR (SYSDATE, 'YY'), 99)-1

OF ANOTHER TO_NUMBER (TO_CHAR (SYSDATE, 'YY'), 99)

END)

AND (TRIM (GBLT) = 'AA'

OR TRIM (GBLT) = "TO THE".

OR TRIM (GBLT) = 'EN '.

OR TRIM (GBLT) = 'EU')

AND PREPPY < 20000

AND (TRIM (GBMCU) < = '9500')

OR TRIM (GBMCU) > '9800')

AND GBMCU = MCMCU) JDE

Hello

your problem is with the following line

AND THE SUM (PYC + AMOUNT) <>0

You cannot use the SUM here my e function you just use

AND PYC + AMOUNT <>0

Concerning

Salim

Tags: Database

Similar Questions

  • Cannot create the SQL query view object

    I'm having a lot of trouble to create a display of a SQL object.

    The query is as follows:

    Select CalBruker.BRUK_ID,
    CalBruker.EMAIL,
    CalBruker.ETTERNAVN,
    CalBruker.PASSORD,
    CalBruker.DATO_OPPRETTET,
    CalBruker.AKTIV,
    CalBruker.FORNAVN,
    CalBruker.ROLL_ROLL_ID,
    CalBruker.AVDE_AVDE_ID,
    CalRoller.NAVN,
    CalRoller.ROLL_ID,
    CalAvdelinger.NAVN AS NAVN1,
    CalAvdelinger.AVDE_ID,
    CalRoller.BESKRIVELSE,
    CalForlag.NAVN AS NAVN2,
    CalForlag.FORL_ID,
    CalAvdelinger.navn,
    CalForlag.navn AS BrukForlag,
    CalBruker.FRIEKS_PROSENT_GRENSE,
    CalBruker.LOGIN_NAVN
    Of CAL_BRUKER CalBruker, CAL_ROLLER CalRoller, CAL_AVDELINGER CalAvdelinger, CAL_FORLAG CalForlag
    Where CalBruker.ROLL_ROLL_ID = CalRoller.ROLL_ID AND CalBruker.AVDE_AVDE_ID = CalAvdelinger.AVDE_ID AND CalAvdelinger.FORL_FORL_ID = CalForlag.FORL_ID


    If I create a new view object and paste the SQL query in there, I get no automatic attribute mappings, and I can't understand how I'm supposed to map the attributes manually.

    Basically, I get a display without her attributes object.

    JDeveloper version 11.1.2.0

    Help if you give alias names in your columns?
    Something like:

    Select CalBruker.BRUK_ID BRUK_ID,
    EMAIL CalBruker.EMAIL,
    CalBruker.ETTERNAVN ETTERNAVN,
    ...

  • Cannot execute the sql command line

    Please someone help me trobleshooting the following error.

    SQL * MORE: Relese 11.2.0.2.0 production on 19 July 2013 Fri 12-34-23

    Copyright (c) 1982,2010,oracle.all rights reserved.

    Enter the user name: System

    Enter the password: "when I tried to enter the master password is not accept, then if I press on enter, I get the following error,

    Error:

    ORA - 01017:invalid username or password; connection refused

    Enter the user name: System

    Instead of trying to system

    Enter the user name: / as sysdba

    If your OS username is a member of the OSDBA Group (normally dba on ORA_DBA on Windows, Linux/Unix), you should be able to connect. When you do that, you can do what you want (you are the user SYS), for example to change password:

    SQL > alter the system of the user identified by ;

  • Classic report shows wrong "could not parse the SQL query: ORA-00942" error after migrating app to the new environment

    After migrating my APEX 4.1 application to a new environment, one classic report displays a "cannot parse the SQL query: ORA-00942: table or view does not exist" error when the page is displayed. Change the region to report SQL source to somehow (e.g., remove spaces, changing the order of the variables in the WHERE clause) immediately solves the problem, but by returning to the source of the region causes the report error again (the source region valid code without error, however).

    Throw the error message:

    Select v.id,

    v.Col1

    of view_vw v

    where (: P1_FILTER is null or)

    v.col2 = :P1_FILTER)

    Do not throw error:

    Select v.id,

    v.Col1

    of view_vw v

    where (:P1_FILTER is null or)

    v.col2 = :P1_FILTER)

    Changing the order of column in the report has the same effect; i.e. He arranges, but return back to the original column order causes the error to display.

    It's as if a cached result for the correct select statement used by the report is displayed. However, the application does not use the caching of page/region. Any ideas of what could be the cause?

    He solved. Ultimately, all that was necessary was to clear the DB cache using:

    alter system flush shared_pool;

  • Table error ' can not analyze the SQL query!

    Hi all

    I created a view on my database called VIEW_MEMBER_PARTIC_PROJECTS

    If I run a query showing the results of the view:

    SELECT * FROM VIEW_MEMBER_PARTIC_PROJECTS

    I get the following data

    ProjectsParticipants
    131 S
    241
    319
    43
    53
    61
    72

    Now, I wanted to represent this diagram in the APEX so I created a graphic region and entered the Source query generator and the manufacturer produces the following code

    Select null, label projects, value1 Participant link

    of "SCHEMANAME." "" VIEW_MEMBER_PARTIC_PROJECTS ".

    With this code, I get an error:

    Cannot parse the SQL query!

    Select the link null, label projects, value1 "SCHEMANAME Participant." "" VIEW_MEMBER_PARTIC_PROJECTS ".

    Some queries can be run when you run your application, if your query is syntactically correct, you can save your query without validation (see options below the source of the query).

    The code looks OK, but I do not see to save options as the error code is mentioned.

    No one knows how to fix this?

    Thank you

    JaReg wrote:

    I finally found the problem.

    I looked at the code for the view and changed the start of:

    CREATE OR REPLACE FORCE EDITIONABLE VIEW "SCHEMANAME." "" VIEW_MEMBER_PARTIC_PROJECTS "("Participant","Projects")

    AS

    TO

    CREATE OR REPLACE VIEW "SCHEMANAME." "" VIEW_REPEAT_PARATIC ".

    AS

    And that seemed to fix it. I'm not entirely sure why though.

    The view was created using the quoted identifiers for column names. This makes them sensitive and means that they must always be referenced using double quotes. In the absence of quotation marks, Oracle is not case insensitive and automatically converts all uppercase identifiers. The application of graph:

    Select the link null, label projects, value1 "SCHEMANAME Participant." "" VIEW_MEMBER_PARTIC_PROJECTS ".

    has therefore been interpreted by Oracle:

    SELECT THE LINK NULL, LABEL, VALUE1 "SCHEMANAME PARTICIPANT PROJECTS." "" VIEW_MEMBER_PARTIC_PROJECTS ".

    and PROJECTS and PARTICIPANT columns were not recognized because the columns defined for the view have been 'Participant' and 'projects '. The graphic request should have been:

    Select the link null, the label of "Projects", "Participant" value1 "SCHEMANAME." "" VIEW_MEMBER_PARTIC_PROJECTS ".

    As you have now discovered, quoted identifiers are a source of nothing but obscure bugs and should never be used for database objects. He also pointed out the reason why you should always use a standardized, form tiny, coding style as it is faster to type, easy to read and less prone to errors.

  • Looking for a SQL query to retrieve callvariables + ECC to a RESULTS of SCRIPT EXECUTE (translation VRUS)

    Hi team,

    I'm looking for a SQL query check data (ECC + CallVariable) due to a RESULT of SCRIPT EXECUTE when you ask an external VRU with a translation route to VRU with a 'run external Script '.

    In my view, that the data are analyzed between the termination call detail + termination call Variable.

    If you have already such a SQL query I would be very grateful to have.

    Thanks and greetings

    Nick

    Omar,

    respectfully, shorten the interval of a day might not be an option for a history report ;-)

    I recommend to take a look at the following SQL query:

    DECLARE @dateFrom DATETIME, @dateTo DATETIME

    SET @dateFrom = ' 2014-01-24 00:00:00 '

    SET @dateTo = ' 2014-01-25 00:00:00 '

    SELECT

    TCV. DateTime,

    TCD. RecoveryKey,

    TCD. RouterCallKeyDay,

    TCD. RouterCallKey,

    VME. EnterpriseName AS [ECVEnterpriseName],

    TCV. ArrayIndex,

    TCV. ECCValue

    OF Termination_Call_Variable tcv

    JOIN THE

    (SELECT RouterCallKeyDay, RouterCallKey, RecoveryKey IN Termination_Call_Detail WHERE DateTime > @dateFrom AND DateTime)< @dateto)="">

    THE tcv. TCDRecoveryKey = tcd. RecoveryKey

    LEFT OUTER JOIN Expanded_Call_Variable VME ON tcv. ExpandedCallVariableID = VME. ExpandedCallVariableID

    WHERE the tcv. DateTime > @dateFrom AND tcv. DateTime<>

    With variables, you can set up your code (for example, you could write SET @dateFrom =? and let the calling application to fill in the DateTime for you).

    In addition, join two large tables with all the lines, as you did (TCD - TCV) is never a good option.

    Another aspect to consider: all the ECC is actually arrays (always), is not good to leave aside the index value (tcv. ArrayIndex).

    G.

  • SQL query can be executed through TOAD, but not through discoverer

    Hello, everyone:

    You have another problem. A SQL query can be executed through TOAD, but when I want to run by a discoverer worksheet, it still shows as no data.

    PS: I copied this query discoverer and TOAD, which means, this query is generated by the discoverer. Does anyone know how could it be?

    Thank you.

    Geng

    Hello

    If you are able to get the data into a TOAD with the same user credentials of the discoverer more then it will be indicates a problem with the discoverer.
    Otherwise, it is a question of privilege, your TOAD user has the right to select for the base objects (tables/views, etc.) while your used Disoverer does not work.

    Compare these 2 users privileges and you can narrow down the issue.

    Thank you
    Fati

  • SQL query for empty string

    I am trying to execute the following SQl query, SELECT * failure WHERE ID = '123 ' AND RepairAction =' '; using the DB tools run Query.vi. This query never find record in my database. My database contains a record where the registered ID contains the value '123' and the RepairAction field is an empty string. If I remove the declaration 'AND RepairAction' ';' my query text, the record is found. I think my problem is that I do not use the correct syntax to describe and an empty string. I tried the following: "," ",""," "and NULL as empty and none of these work string arguments.

    I was hoping someone might be able to tell me what the correct syntax is an empty string or if there is another approach that I take.

    Thanks in advance for your help,

    Jim

    Jim,

    Just to be sure, have you used 'is' instead of '=' in this command?

    This makes all the difference in this command.

    Cerati

  • How to get the value of a column in sql query?

    Hi, anyone knows how to get the value of a column in sql query?

    Here is my code, the value must be 1350079224397 in my PB, but I get 0

    QString query ("SELECT version FROM db_version");

    QVariant result = sda.execute (query);
    QVariantMap versionMap = result.toList () such () .toMap ();
    If (! versionMap.IsEmpty ())
    {
    qDebug()<"Version: "=""><>
    }

    OK, I have the solution

    QString query ("SELECT version as version FROM db_version");

  • A map of OWB (service line) SQL query

    If I trace a session, run a map OWB (base line), the trace file contains the actual SQL query?

    The problem with me is that when I execute this rank - based OWB card, is throw me an error CursorFetchMapTerminationRTV20007, BUT (most time consuming) when I take on the intermediate SQL insert query, it works very well (and also in a very short time)

    The executing State = COMPLETE

    message = text ORA-06502: PL/SQL: digital or value error: character string buffer too small

    CursorFetchMapTerminationRTV20007 = message text

    N ° of task errors = 0

    N ° task warnings = 2

    N ° errors = 1

    Since this card OWB (truncate insert) is the line in function of where I can't back-end of the generated pl/sql package request OWB so I was wondering if I trace the session, check the trace file, maybe I'll able to see the exact SQL query generated. But I wanted to confirm the same.

    Yes, the real run SQL in session will be in the trace file.

  • Database SQL query to get all virtual machines with comments enabled customization?

    Hello

    Does anyone know of a SQL query that can be executed against the vCloud Director DB for all virtual machines who invited enabled customization?

    I can't have PowerShell to pull these data on a global scale.

    Thank you

    jkasal

    Has taken a quick...

    Select top 10 v.id, v.name, v.vapp_name, v.vc_id, v.moref, ui_vapp_vm_list_view v.guest_customize_enabled v with (NOLOCK)

    seems to have if the setting is enabled or not.

  • Dynamic PL SQL query

    Hello

    I want to run and store the results of a dynamic sql query in a strored procedure.

    I get the following variables of the user running: v_column_names, v_table_name, v_col, v_value

    The query will be like:

    v_query: = 'SELECT'. v_column_names | ' A ' | v_table_name | ' WHERE ' | v_col |' = ' | v_value;

    for example v_column_names: = 'ACCOUNT_NUM, SYSTEM_ID, ENTITY_ID ';

    v_table_name: = 'ACCOUNT '.

    v_col: = 'COUNTRY_CODE ';

    v_value: = "USA";

    Here is what I tried

    DECLARE

    v_column_names VARCHAR (200): = 'ENTITY_ID, SYSTEM_ID, ACCOUNT_NUM;

    v_table_name VARCHAR (200): = 'ACCOUNT '.

    v_col VARCHAR (200): = 'COUNTRY_CODE ';

    v_value VARCHAR (200): = "'USA"';

    TYPE column_record () IS RENDERING

    VARCHAR2 (200) C1: = null;

    C2 VARCHAR2 (200): = null;

    C3 VARCHAR2 (200): = null

    );

    TYPE st_table IS TABLE OF column_record INDEX DIRECTORY.

    pk_table st_table;

    NUMBER of v1: = 1;

    BEGIN

    v_select: = 'SELECT'. v_column_names | ' A ' | v_table_name | ' WHERE ' | v_col |' = ' | v_value;

    EXECUTE IMMEDIATE v_select COLLECT LOOSE pk_table.

    I'm IN 1.pk_table.count LOOP

    DBMS_OUTPUT. Put_line (pk_table (v1). (C1);

    DBMS_OUTPUT. Put_line (pk_table (v1). (C2);

    DBMS_OUTPUT. Put_line (pk_table (v1). (C3);

    v1: = v1 + 1;

    END LOOP;

    END;

    The number of column names in v_column_names is dynamic, so I need a way to store the results and then manipulate them.

    I look forward to your reply.

    EDIT: The real question:

    1. in the settings I have pass the table name and the value of the primary key of the row I want to delete.

    2. He then checks if this line is referenced anywhere, removes the reference, and then deletes the current line. This can go, until all the rows that are referenced are removed.

    The above code, I have provided a small part of the largest of stored procedure.

    Thank you all, I found the tips very helpful. I found a solution to my problem:

    Oracle - how to build queries DELETE in PL/SQL, based on the tables of the FK relations? -Stack overflow

    It generates all removal requests to remove a specific line.  Not what I wanted, but this does not solve my problem.

    The reason why is that I discovered that we do not use the ON DELETE CASCADE that we don't remove a record accidentally, I know we have an option to restore, but it is just in case something goes wrong.

  • SQL Query - store the result for optimization?

    Good day experts,

    I'm looking for advice on a report. I did a lot of analytical functions to get the basic data that I have to do my report and its takes about 50 min for SQL finish. Now, with these data, I need to create 3 different reports and I can't use the SQL even since there are a lot of aggregation (example would be product group in one case and by customer in 2nd). For each of these different group garages I need another report.

    So how to create 3 reports of 1 SQL query without running the query 3 times?

    First thing that comes to mind is to store the result set in a fictitious table, and then query the table since I get the basic data are about 300 lines and then perform different garages group.

    Best regards

    Igor

    So how to create 3 reports of 1 SQL query without running the query 3 times?

    You already know the obvious answer - store data 'somewhere '.

    If any 'somewhere' depends on your needs and you have not provided ALL the.

    MV - if the query is always the same, you might use a MV and make a complete refresh when you want that new data. The data are permanent and can be queried by other sessions, but the query that accesses the data is frozen in the definition of MV.

    GTT (global temporary table) - If a NEW charge of data AND three reports will be ALWAYS executed by a single session and then data are no longer necessary so a TWG may work. The application that loads the TWG can be different for each race, but the data won't be available for a single session and ONLY for the duration of this session. So if something goes wrong and the session ends the data are missing.

    First thing that comes to mind is to store the result set in a fictitious table, and then query the table since I get the basic data are about 300 lines and then perform different garages group.

    Which is commonly called a "table of REPORT-READY." Those that are useful when data must be permanent and available for multiple sessions/users. Generally, there is a batch (for example the package procedure) that periodically refreshes / updates the data during a window of failure. Or the table can have a column (for example AS_OF) that allows it to contain multiple data sets and the update process let alone the existing data and creates a new set of data.

    If your database is about 300 lines you can consider a table report and even use it to contain multiple data sets. Then, the reports can be written to query the data by using a value AS_OF that wraps and returns the appropriate data. You don't need a window of failure since the oldest data are still available (but can be removed when you no longer need.

    If you need a set of data, you can use a partitioned table work (with only one partition) to collect the new set of data, then a SWAP PARTITION to 'swap' in the new data. Only, this "Exchange" takes a fraction of a second and avoids a window of failure. Once the swap done no matter what user query will get new data.

  • problem with bind variables in the SQL query view object

    Hi all

    I use JDev 11.1.2.4.0.

    I have a problem with bind variables in the SQL query view object.

    This is my original SQL

    SELECT sum(t.TIME) , t.legertype_id
    FROM LEDGER t
    WHERE t.nctuser_id = '20022' 
          AND to_char(t.insertdate,'YYYYMMDD') in ('20130930','20130929')
    group by t.legertype_id
    

    In my view .xml object query tab, I am writing this

    SELECT sum(t.TIME) , t.legertype_id
    FROM LEDGER t
    WHERE   t.nctuser_id = '20022'
        AND to_char(t.insertdate,'YYYYMMDD') in :dddd
    group by t.legertype_id
    

    Davis here is a variable of Type liaison: String, updatable and necessary.

    I try to deal with Davis as ('20130930 ', ' 20130929') hoping the view object, run as my original SQL.

    But failed. The view object retrieves 0 line after that I run.

    Why?

    Thank you! ('2original SQL0130930', '20130929') ('20130930 ', ' 20130929')

    A variable binding cannot be used as this is why you must use years table. Check decompilation binary ADF: using oracle.jbo.domain.Array with ViewCriteria to see a solution.

    Timo

  • Efficient SQL query

    Hello
    I need to write an efficient query because the query about 4 checks to be made on the lines before you return one row. Here's a sample script in query to create the table:

    CREATE TABLE "myschema". "" Complaint. "
    (
    "Compalint_ID" NUMBER (20.0).
    "ReplyTime' NUMBER,-it would be in a few minutes
    "CREATION_TIME' TIMESTAMP (6).
    NUMBER OF 'STATUS ',.
    "TYPE" NUMBER


    "CH_PKRTBL_Complaint_ID" ("Compalint_ID") PRIMARY KEY CONSTRAINT
    USING INDEX PCTFREE, INITRANS 10 2 MAXTRANS 255 CALCULATES STATISTICS
    STORAGE (INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645)
    PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 DEFAULT USER_TABLES)
    TABLESPACE 'myspace' ENABLE
    ) PCTFREE, PCTUSED, INITRANS 40 10 1 MAXTRANS 255 NOCOMPRESS SLAUGHTER
    STORAGE (INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645)
    PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 DEFAULT USER_TABLES)
    TABLESPACE "myspace";

    CREATE UNIQUE INDEX "myschema". "" CH_PKRTBL_Complaint_ID "WE"myschema ". "" Complaint "("Compalint_ID")
    PCTFREE, INITRANS 10 2 MAXTRANS 255 COMPUTE STATISTICS
    STORAGE (INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645)
    PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 DEFAULT USER_TABLES)
    TABLESPACE "myspace";

    ALTER TABLE 'myschema. ' ' KEY PRIMARY complaint ' ADD CONSTRAINT 'CH_PKRTBL_TKTID' ('Compalint_ID')
    USING INDEX PCTFREE, INITRANS 10 2 MAXTRANS 255 CALCULATES STATISTICS
    STORAGE (INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645)
    PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 DEFAULT USER_TABLES)
    TABLESPACE 'myspace' ENABLE;



    I want to write an efficient pl/sql-sql query with the least time to return a row based on four following priorities/controls in the order specified below:

    1 return any line that contains a TYPE = 11

    2. If no line found for 1 check then
    calculate a difference in time for all of the lines as: time_difference (CREATION_TIME - ReplyTime)
    and back to the line that has more big differene in - ve (it is the line which expired first)

    3. If now the found line to check then the 2
    rank next where STATUS = 22

    4. If no line found to check then the 3
    calculate a difference in time for all of the lines as: time_difference (CREATION_TIME - ReplyTime)
    and back to the line that has a smaller difference in + ve (it is the line that will expire then)


    Kindly help me in this task.

    Thank you.

    @1
    I have the suggestion of Daniel while avoiding reserved words and now I see an error in copy/paste complaint_ casetypestatus when 22 then 22 end check3

    @2
    Bilal already you made in the right direction, anyway: as many others pointed out that you can not combine functions of the group the way which you intend to so using functions analytical has been the only issue keeping all lines and the calculation of the required amounts and charges in the query internal to combine in the outer query.
    complaint_type case when 11 11 then end keeps only the 11 complaint_type all other complaint_type null values
    Max (case complaint_type when 11 11 then complete) on check1_max (order by NULL rows between unbounded preceding and following unbounded), calculates the global maximum of the expression (in all the rows of the table)

    @3
    I used systimestamp - (creation_time + reply_time / 60/24) just to produce a positive or negative number as your time_difference (CREATION_TIME - ReplyTime) somehow confused me (timestamp less number gives timestamp if positive or negative is not an appropriate question) so the above expression as used so far is something you know how (re) set. Other required clarification/explanation at this stage.

    @4
    If the fraction of the second precision is not necessary using the date data type should be sufficient (environmental CAR you cannot rule out dealing with the events with the same timestamp) and what is the thrown error using systimestamp

    Concerning

    Etbin

Maybe you are looking for