Question of SQL statement

I have this PreExpression at a stage of SQL statement:

Locals.SQL_LatestResult = "SELECT UUT_RESULT.ID, UUT_RESULT. UUT_SERIAL_NUMBER, UUT_RESULT. START_DATE_TIME UUT_RESULT WHERE (((UUT_RESULT. UUT_SERIAL_NUMBER) =------"' + Locals.serial + ' \ ') AND ((UUT_RESULT." START_DATE_TIME) = (SELECT MAX (UUT_RESULT2. START_DATE_TIME) OF UUT_RESULT AS UUT_RESULT2 WHERE UUT_RESULT. UUT_SERIAL_NUMBER = UUT_RESULT2. UUT_SERIAL_NUMBER))); »

Locals.SQL_LatestResult has this value after the PreExpression:

SELECT UUT_RESULT.ID, UUT_RESULT. UUT_SERIAL_NUMBER, UUT_RESULT. START_DATE_TIME UUT_RESULT WHERE (((UUT_RESULT. UUT_SERIAL_NUMBER) = "15514011") AND ((UUT_RESULT. START_DATE_TIME) = (SELECT MAX (UUT_RESULT2. START_DATE_TIME) OF UUT_RESULT AS UUT_RESULT2 WHERE UUT_RESULT. UUT_SERIAL_NUMBER = UUT_RESULT2. UUT_SERIAL_NUMBER)));

I get the number of records = 0, if I run the sequence.

If I copy the exact same SQL query in access I get what I want to know a record.

If I remove that part of the query:

((UUT_RESULT. UUT_SERIAL_NUMBER) =------"" + Locals.serial + "\") "

I get 388 records which is correct and it run directly in access.

What's not here?

I was too fast for this post... it's my fault, the database link was wrong, so data were there...

Statements are very good!

Tags: NI Software

Similar Questions

  • question on the sql statement

    Hi expert,

    I have after sql statement, the function 'hiroc_get_delta_amount1' and 'hiroc_get_delta_amount2' are used separately in select and where subparagraph. These two functions are exactly the same, except that there is a log insert inside statement. for the 'hiroc_get_delta_amount1' function, newspapers are supposed to write the newspaper of table1, while for the function "hiroc_get_delta_amount2", newspapers are supposed to write the newspaper of table2. After you run this sql, I got the data loaded in the table2 newspaper, however, no data is loaded into newspaper table1.

    could you please tell me why there is no data in table2 journal for function

    1. sql statement;

    Select
    pp.policy_premium_pk,
    pp.policy_fk,
    pp.policy_term_fk,
    pp.risk_fk,
    pp.coverage_fk,
    pp.transaction_log_fk,
    pp.coverage_component_code,
    hiroc_rpt_user.hiroc_get_delta_amount1 (pp.policy_fk, pp.policy_term_fk, pp.risk_fk, pp.coverage_fk, pp.transaction_log_fk, pp.coverage_component_code),
    pp.rate_period_from_date
    PRODBKUPDW_MART.rmv_policy_premium pp
    where pp.rate_period_type_code = 'TERM_COVG. '
    and pp.coverage_component_code <>'NETPREM '.
    and hiroc_rpt_user.hiroc_get_delta_amount2 (pp.policy_fk, pp.policy_term_fk, pp.risk_fk, pp.coverage_fk, pp.transaction_log_fk, pp.coverage_component_code). = 0
    Pp.policy_premium_pk group,
    pp.policy_premium_pk,
    pp.policy_fk,
    pp.policy_term_fk,
    pp.risk_fk,
    pp.coverage_fk,
    pp.transaction_log_fk,
    pp.coverage_component_code,
    pp.rate_period_from_date;

    2. Insert the statement used for two functions of journal:

    (1) function "hiroc_get_delta_amount1".

    insert into HIROC_RPT_USER. Values of LOG_TEST1 (v_start, sysdate,
    p_policy_fk, p_policy_term_history_fk, p_risk_fk, p_coverage_fk, p_transaction_log_fk, p_comp_code);
    COMMIT;


    (2) function "HIROC_GET_DELTA_AMOUNT_1".

    insert into HIROC_RPT_USER. Values of LOG_ZB_TEST_1 (v_start, sysdate,
    p_policy_fk, p_policy_term_history_fk, p_risk_fk, p_coverage_fk, p_transaction_log_fk, p_comp_code);
    COMMIT;

    WRONG FORUM!

    Welcome to the forum!

    Unfortunately, you have posted on the SQL Developer forum which, as the title of the forum is NOT for questions of SQL and PL/SQL.

    Please mark this thread ANSWERED and transfer your question in the forum SQL and PL/SQL
    SQL and PL/SQL

    When repost you your question, you must provide the DDL for the two functions, not only a query in them. And unless these functions use the pragma AUTONOMOUS_TRANSACTION and VALIDATION and then inserts into a table 'log' what they do will be not permanent anyway.

    You will also need to provide the number of rows that the SELECT query returns since if no line is activated, the first function cannot even be called.

    Where this question: why are you recording of information in the context of a still SELECT query? What goal are you trying to achieve this returns the loss of performance you pay?

  • What are these SQL statements?

    Hello!

    We are our applications running on Windows Server 2003 where it works fine, using Oracle via OCI 12.1.

    Now, we have the application installed on Windows Server 2012 and it works very slowly.

    When comparing these two environments trace files came a surprise: Oracle generates a lot of SQL statements when run on Windows Server 2012!  By operating on Windows2003 it only executes the SQL from the applicaton instructions.  These additional SQL statements must be the reason for the slowness, but why Oracle it generates them and how could we get arrested?

    An example:

    PARSING IN CURSOR #46985062096816 len = 210 dep = 2 uid = 0 oct = cover 3 = 0 tim = hv 1439277877325893 = ad 864012087 = "4db599f28" sqlid = "96g93hntrzjtr."

    Select / * + rule * / bucket_cnt, row_cnt, cache_cnt, null_cnt, timestamp #, sample_size, minimum, maximum, distcnt, lowval, hival, density, col #, spare1, spare2, hist_head avgcln $ where obj #=: 1 and intcol #=: 2

    END OF STMT

    ANALYSIS #46985062096816:c = 1000, e = 456, p = 0, cr = 0, cu = 0, put = 1, r = 0, dep = 2, og = 3, plh = 0, tim = 1439277877325890

    EXEC #46985062096816:c = 0, e = 498, p = 0, cr = 0, cu = 0, put = 1, r = 0, dep = 2, og = 3, plh = 2239883476, tim = 1439277877326455

    FETCH #46985062096816:c = 0, e = 56, p = 0, cr = 3, cu = 0, set = 0, r = 1, dep = 2, og = 3, plh = 2239883476, tim = 1439277877326533

    STAT #46985062096816 id = 1 cnt = 1 pid = 0 obj = op 411 = pos = 1 "TABLE ACCESS BY INDEX ROWID HIST_HEAD$ (cr = 3 pr = 0 pw = time 0 = 55 US)"

    "STAT #46985062096816 id = 2 cnt = 1 pid = 1 pos = 1 obj = op 413 ='INDEX RANGE SCAN I_HH_OBJ #_INTCOL # (cr = 2 pr = 0 pw = time 0 = 32 US)"

    OUTCOME #46985062096816:c = 0, e = 37, dep = 2, type = 3, tim = 1439277877326601

    EXEC #46985062096816:c = 0, e = 23, p = 0, cr = 0, cu = 0, set = 0, r = 0, dep = 2, og = 3, plh = 2239883476, tim = 1439277877326702

    FETCH #46985062096816:c = 0, e = 18, p = 0, cr = 3, cu = 0, set = 0, r = 1, dep = 2, og = 3, plh = 2239883476, tim = 1439277877326738

    OUTCOME #46985062096816:c = 0, e = 8, dep = 2, type = 3, tim = 1439277877326765

    EXEC #46985062096816:c = 0, e = 19, p = 0, cr = 0, cu = 0, set = 0, r = 0, dep = 2, og = 3, plh = 2239883476, tim = 1439277877326837

    FETCH #46985062096816:c = 0, e = 21, p = 0, cr = 3, cu = 0, set = 0, r = 1, dep = 2, og = 3, plh = 2239883476, tim = 1439277877326923

    OUTCOME #46985062096816:c = 0, e = 10, dep = 2, type = 3, tim = 1439277877326954

    Thank you very much in advance!

    Best regards

    Jaakko Terhonen

    Thank you all for the reply!  This time, the reason was a problem in network traffic (TCP protocol): a lot of retransmissions for a still unknown reason.  If it had nothing to do with Oracle after all.

    I cried for help here because as a common application programmer, I wasn't familiar with the Interior details of SQL analysis and after seeing it in the trace, I assumed that these strange SQL statements - which, for some reason, is appeared only in W2012-trace - were the reason for the slowness.

    Thank you, I'm a little wiser now - and I hope that many others find this thread before asking the same question!

    Best regards

    Jaakko Terhonen

  • Several SQL statements with zero executions in the region of SQL

    Hello

    one of my databases has a large number of statements in the SQL box with zero executions. Some of them analyzed several times without a single run. Why the database stores these statements and how to avoid or reduce them?

    My problem is that the only time or zero time sql statements take the largest part of the area of sql:

    -sql statement and only once and without executing sql statements

    Select

    Count (1) num_sql_total,.

    sum (decode (executions, 1, 1, 0)) num_one_use_sql,.

    sum (decode (executions, 0, 1, 0)) num_no_use_sql,.

    Sum (RUNTIME_MEM) / 1024/1024 mb_used,.

    sum (decode (executions, sharable_mem, 1, 0)) / 1024/1024 mb_for_one_use_sql,.

    sum (decode (executions, 0, sharable_mem, 0)) / 1024/1024 mb_for_no_use_sql

    Of

    GV$ sqlarea

    where

    RUNTIME_MEM > 0;

    NUM_SQL_TOTAL NUM_ONE_USE_SQL NUM_NO_USE_SQL MB_USED MB_FOR_ONE_USE_SQL MB_FOR_NO_USE_SQL

    23318

    8739

    8027

    1420,95619106293

    381,41183757782

    530,999855041504

    Concerning

    Thomas

    This is not unusual. Another app could analyze for example hard the most often used SQLs in upstairs app - making benefit of further processing (in theory) of sweet analysis when you use these SQLs.

    In fact, I remember reading something to this effect as a performance for some factor or another Oracle document or note?

    So unless you have serious questions of shared pool, why bother with these sliders? What would be the problem?

  • create a dynamic help based on a sql statement

    Hello

    A few years ago, I asked the same question, but I had no adequate answer to my problem:

    I have to build a text of dynamic help for items diaplayed (bubble help or better pop-up window). When I go to a header element there is a? Displays and when I click on the left mouse button it will be a constant display text. Now, I have a table with explanation (build on documentation in the table) for each column on each page. If I want to start an SQL statement when I click the button and the text should be displayed in the pop-up window.

    An example everywhere or can someone help me otherways?

    Concerning

    Siegwin

    fixed for you, the changes are:

    1. added onclick = "getItemHelpText('#CURRENT_ITEM_NAME#'); call to your model of 'Optional with Help' for all items using this model will have the same call in.
    2. adding the global page, page 0,
    3. moved JavaScript "getItemHelpText" on page 0 to become a global function, so you can use it anywhere in the application
    4. added item globle P0_DYNAMIC_HELP_TEXT page 0
    5. update your application process to set the value of P0_DYNAMIC_HELP_TEXT on the convening of AJAX, you must fix the help text.
    6. help text changed to P41_ENAME in & P0_DYNAMIC_HELP_TEXT.

    That's all I think, tested worked.

    good luck with the rest...

  • FDM generated SQL statement in the log file?


    Hello everyone, hopefully a simple question:

    When you perform an import using FDM, I know that behind the scenes of a SQL SELECT statement statement composed and performed on the database server. My question: the actual SQL statement is retained in a newspaper somewhere (so that we can see it?) In our case, it's an Oracle DB server and we use the ERPI adapter; not sure if it's relevant. We would like to enter this SQL statement and use it as a starting point for other things.

    Thanks in advance for anything you can offer.

    The statement SQL is not written in the journal of the adapter.  The only things that are registered are what show in the file card log if you enable loggin to the adapter source ERPi in action 'Get Data'.

  • PL/SQL: Statement ignored SQL error (SELECTing row, expression arithmetic/s)

    Quick question, on the execution of the query of the ff, I do

    Select a.column, sum (decode(a.column,'string',1,'etc...')

    But when I include a func or procedure, it won't allow me too and that he would give a PL/SQL: SQL statement ignored error and it will compile only if I remove the first a.column as follows

    Select sum (decode(a.column,'string',1,'etc...')

    Why is it so? And how should it be rewritten to include the select a.column?

    Start

    Select a.gameid, sum (decode(a.nscores,'Perfect',100,'Excellent',95,'Good',80,'Poor',50) 'scores'

    in x,y

    Of...

    where the...

    return x

    end myFunc;


    Fundamentals of the PL/SQL language


    Concerning

    Etbin

  • sql statements run correctly

    Hello

    It is a question of certification.

    Question: 3
    Examine the structure of the table of PROGRAMS:
    Name Null? Type
    ---------- ------------- ---------------
    PROG_ID NOT NULL NUMBER (3)
    PROG_COST NUMBER (8.2)
    START_DATE DATE NULL NOT
    END_DATE DATE
    The two SQL statements would be run successfully? (Choose two.)
    A. SELECT NVL (ADD_MONTHS(END_DATE,1), SYSDATE) OF programs;
    B. SELECT TO_DATE (NVL (SYSDATE-END_DATE, SYSDATE)) OF programs;
    C. SELECT NVL (MONTHS_BETWEEN (start_date, end_date), 'Ongoing') OF programs;
    D. SELECT NVL (TO_CHAR (MONTHS_BETWEEN (start_date, end_date)), 'Ongoing') OF
    programs;

    Answers: A, D

    My question is:
    If A and D are correct woud B and C run successfully also right?

    Please specify.

    What? You are able to do this in your test db?
    You get an error for B and C for this reason - the expressions in the two queries will assess a number. B trying to do a TO_DATE on a NUMBER, and C tries to substitute a VARCHAR2 string where a NUMBER is expected.

  • Can I write merge SQL statement having count (*)?

    Hi, this is a follow-up to my previous post question. I tried to use a SQL statement of merger to solve my problem, but now I come across another problem.
    Now, I have a table where the field updated necessary is a partial PK
    When you use a SQL statement of merger, I put a where clause clause that check if count (*) = 1 because of the constraint of PK
    Where I put the count ()) = 1 clause?

    Here are the details:
    I have two tables TA and TB, where TA contains the fields IDS, FULLNAME, TYPE and tuberculosis contains the fields ID, NAME
    I want to update the names in TB for TA names where TB.ID = TA.ID and TA. TYPE = 'ABC '.
    {ID, first NAME} are PKs but for the same ID, there may be more than 1 firstname.
    for example
    TA
    -------------------------------
    ID | FULLNAME | TYPE
    1 Caroline T ABC
    2 Mary C DEF
    3 Peter J ABC

    TB
    ----------------------
    ID | FIRSTNAME
    1 Caroline
    1 Carol
    1 C,
    3 Peter

    I need to update TB with the new names of TA where type is 'ABC', but only for those areas that have count (TB.ID) = 1
    When I try to run this SQL statement

    merge into TB B using TA A
    on (A.ID = B.ID and A.TYPE = 'ABC')
    when matched, then update the value B.FIRSTNAME = substr (A.FULLNAME, 1, instr (A.FULLNAME, ',') - 1)

    I got this error SQL error: ORA-00001: unique constraint (TEST.) PK_TB) violated
    which I believe is because I've updated these fields say ID = 1, with 'Caroline '.
    This means that I'll have to add a clause with count (TB.ID) = 1
    How would you do it?

    Server Oracle 11 g is
    Thank you!

    Hello

    One way is to join your and tb in the USING clause and eliminate duplicates it.

    MERGE INTO     tb     dst
    USING   (
             SELECT    ta.id
             ,           REGEXP_SUBSTR ( MIN (ta.fullname)
                                    , '^[^,]*'
                            )     AS firstname
             FROM      ta
             JOIN      tb  ON  ta.id     = tb.id
             WHERE     ta.type      = 'ABC'
             GROUP BY  ta.id
             HAVING    COUNT (*)     = 1
         )                   src
    ON     (scr.id      = dst.id)
    WHEN MATCHED THEN UPDATE
    SET     dst.firstname     = src.firstname
    ;
    

    If you would care to post CREATE TABLE and INSERT statements for your sample data, and then I could test this.

    I used REGEXP_SUBST instead of SUBSTR and INSTR to search for the first name, because I find it a little cleaner, and because it returns something even when there is none "," fullname, which I assume is what you really want. (None of the fullnames in your sample data have ','s.) You can use SUBSTR and INSTR instead.

  • How to 'show' a static pseudo index using SQL statement select?

    Hello again,

    I have to post a time of 24 hours as an index. (00:00 - 23:00)
    It's easy, if data are available.

    But, if the data are not regularly exist on specific time (the time is not regular, IE: 00:00, 01:00, 05:00, 08:00, 10:00, 11:00, 23:00), then it of OK for a TABLE, but not for a CHART.

    Here is the story:

    I've written a SQL statement that can 'choose' what to display respectively the time available. The result will appear on the map: days or the time is used for the x-axis and the respective value on axis y.
    Example:
    + If the data consists of 'days' (ie: the last 5 days from now on, 16/07/2012, 17/07/2012, 18/07/2012, 19/07/2012, 20/07/2012), the chart will display these dates on the x-axis.
    + If the data consists of 'hours' (ie: only 1 day, hour 00:00 - 23:00), then the chart shows the hours on the x-axis.

    If the 'hours' are not regular, means: there is no data on the specific hours, the result of the query is not as regular, average: the value of X - axis "jumps" irregularly.

    Question:
    Is it possible to interrogate our own static value?
    for example:
    Select 'Hello' from dual-> result: 'Hello', 1 column, 1 line
    But how to display it into several lines, i.e.:

    Time
    *****
    0
    1
    2
    3
    4
    5
    ...
    ...
    23


    Note:
    the x-axis on the graph model can be customized only for 1 single mode, example: 'Days',
    but of course it will not appear correctly if the result of the query are "hours."
    This means: I have to find the workaround on the SQL query.


    DB: ORA 11


    Thank you and best regards.

    You can generate mulltiple rows if you use LEVEL and CONNECT BY:

    SQL> select level
      2  from   dual
      3  connect by level <= 10;
    
         LEVEL
    ----------
             1
             2
             3
             4
             5
             6
             7
             8
             9
            10
    
    10 rows selected.
    
    SQL>  select sysdate+level-1
      2  from   dual
      3   connect by level <= 10;
    
    SYSDATE+LEVEL-1
    -------------------
    20-07-2012 12:48:26
    21-07-2012 12:48:26
    22-07-2012 12:48:26
    23-07-2012 12:48:26
    24-07-2012 12:48:26
    25-07-2012 12:48:26
    26-07-2012 12:48:26
    27-07-2012 12:48:26
    28-07-2012 12:48:26
    29-07-2012 12:48:26
    
    10 rows selected.
    
    SQL> select to_char(trunc(sysdate), 'hh24')+level-1
      2  from  dual
      3  connect by level <= 24;
    
    TO_CHAR(TRUNC(SYSDATE),'HH24')+LEVEL-1
    --------------------------------------
                                         0
                                         1
                                         2
                                         3
                                         4
                                         5
                                         6
                                         7
                                         8
                                         9
                                        10
                                        11
                                        12
                                        13
                                        14
                                        15
                                        16
                                        17
                                        18
                                        19
                                        20
                                        21
                                        22
                                        23
    
    24 rows selected.
    
  • Capture the SQL statement before it runs

    Hello world

    I have a question about the capture of query sql statement in Oracle before he run? Is it possible to do and can give you the answer to this problem? Enter here means I can catch the declaration of all applications (like SQL, I * sqlplus or another application making the request to the database). I want to do this because my teacher asks me to analyze the request and if it violates any policy = > stop before Oracle run it.

    I tried this solution
    [Select trigger for Oracle | http://technology.amis.nl/2005/09/26/select-trigger-in-oracle-database-introducing-fine-grained-auditing/].
    but I think he looks not the answer. Because for the audit of the refined, the event handler is called when the first row is obtained. This is the average Oracle a analyze this quere and run to get the first row.

    Please help me with this problem

    Edited by: pirent420 at 04:05 06/05/2012

    Hello
    That's what you ask...

    www.Oracle.com/technetwork/Products/Database-Firewall/index.html

    Some other related things are:

    the database Vault control many things related to this in terms of what time of the day and access where data etc.

    Resource Manager can block statements if they want to use too many resources.

    The standard model of privilege/role/grant prevents access you something, that you are not allowed to see.

    Views can hide columns if necessary.

    DTV and RLS can hide lines

    It depends exactly on the requirement.

    See you soon,.
    Harry

  • DDL or SQL statement

    Guyz,

    I created ODBC for access when I import tables from MS SQL Server 2005 through ODBC and MS Access links MS Access to Oracle 9i which works very well...

    can someone tell me where can I see SCRIPT DDL or SQL statement in the block properties or form in oracle forms after creating the block. as example below.
    SELECT OTb_num,OTb_Acc,OTb_ename,OTb_aname,OTb_Remark FROM DBO_COMPANY
    I use oracle 9i with forms 6i.

    Concerning

    Houda

    Published by: houda Shareef on 6 March 2012 23:23

    Do not create with Create table as select you will find the same question on the column names.
    Create manually the new table with no quotation marks around the column name, and then fill it with:

    insert into table2 select * as table1
    

    François

  • I need help in the sql statement

    Hi all
    im working in the hr schema
    I need sql statement to answer my question
    I need information to all employees
    where average wage = average wage department 50
    Sorry I can't speak English very well
    I thank all

    There is no need to do so in the two motions. All you need is:

    select  *
      from  (
             select  e.*,
                     avg(case department_id when 50 then salary end) over() dept_50_avg_sal
               from  hr.employees e
            )
      where salary <= dept_50_avg_sal
    / 
    
    EMPLOYEE_ID FIRST_NAME           LAST_NAME                 EMAIL                     PHONE_NUMBER         HIRE_DATE JOB_ID         SALARY COMMISSION_PCT MANAGER_ID DEPARTMENT_ID DEPT_50_AVG_SAL
    ----------- -------------------- ------------------------- ------------------------- -------------------- --------- ---------- ---------- -------------- ---------- ------------- ---------------
            198 Donald               OConnell                  DOCONNEL                  650.507.9833         21-JUN-07 SH_CLERK         2600                       124            50      3475.55556
            199 Douglas              Grant                     DGRANT                    650.507.9844         13-JAN-08 SH_CLERK         2600                       124            50      3475.55556
            115 Alexander            Khoo                      AKHOO                     515.127.4562         18-MAY-03 PU_CLERK         3100                       114            30      3475.55556
            116 Shelli               Baida                     SBAIDA                    515.127.4563         24-DEC-05 PU_CLERK         2900                       114            30      3475.55556
            117 Sigal                Tobias                    STOBIAS                   515.127.4564         24-JUL-05 PU_CLERK         2800                       114            30      3475.55556
            118 Guy                  Himuro                    GHIMURO                   515.127.4565         15-NOV-06 PU_CLERK         2600                       114            30      3475.55556
            119 Karen                Colmenares                KCOLMENA                  515.127.4566         10-AUG-07 PU_CLERK         2500                       114            30      3475.55556
            125 Julia                Nayer                     JNAYER                    650.124.1214         16-JUL-05 ST_CLERK         3200                       120            50      3475.55556
            126 Irene                Mikkilineni               IMIKKILI                  650.124.1224         28-SEP-06 ST_CLERK         2700                       120            50      3475.55556
            127 James                Landry                    JLANDRY                   650.124.1334         14-JAN-07 ST_CLERK         2400                       120            50      3475.55556
            128 Steven               Markle                    SMARKLE                   650.124.1434         08-MAR-08 ST_CLERK         2200                       120            50      3475.55556
    
    EMPLOYEE_ID FIRST_NAME           LAST_NAME                 EMAIL                     PHONE_NUMBER         HIRE_DATE JOB_ID         SALARY COMMISSION_PCT MANAGER_ID DEPARTMENT_ID DEPT_50_AVG_SAL
    ----------- -------------------- ------------------------- ------------------------- -------------------- --------- ---------- ---------- -------------- ---------- ------------- ---------------
            129 Laura                Bissot                    LBISSOT                   650.124.5234         20-AUG-05 ST_CLERK         3300                       121            50      3475.55556
            130 Mozhe                Atkinson                  MATKINSO                  650.124.6234         30-OCT-05 ST_CLERK         2800                       121            50      3475.55556
            131 James                Marlow                    JAMRLOW                   650.124.7234         16-FEB-05 ST_CLERK         2500                       121            50      3475.55556
            132 TJ                   Olson                     TJOLSON                   650.124.8234         10-APR-07 ST_CLERK         2100                       121            50      3475.55556
            133 Jason                Mallin                    JMALLIN                   650.127.1934         14-JUN-04 ST_CLERK         3300                       122            50      3475.55556
            134 Michael              Rogers                    MROGERS                   650.127.1834         26-AUG-06 ST_CLERK         2900                       122            50      3475.55556
            135 Ki                   Gee                       KGEE                      650.127.1734         12-DEC-07 ST_CLERK         2400                       122            50      3475.55556
            136 Hazel                Philtanker                HPHILTAN                  650.127.1634         06-FEB-08 ST_CLERK         2200                       122            50      3475.55556
            138 Stephen              Stiles                    SSTILES                   650.121.2034         26-OCT-05 ST_CLERK         3200                       123            50      3475.55556
            139 John                 Seo                       JSEO                      650.121.2019         12-FEB-06 ST_CLERK         2700                       123            50      3475.55556
            140 Joshua               Patel                     JPATEL                    650.121.1834         06-APR-06 ST_CLERK         2500                       123            50      3475.55556
    
    EMPLOYEE_ID FIRST_NAME           LAST_NAME                 EMAIL                     PHONE_NUMBER         HIRE_DATE JOB_ID         SALARY COMMISSION_PCT MANAGER_ID DEPARTMENT_ID DEPT_50_AVG_SAL
    ----------- -------------------- ------------------------- ------------------------- -------------------- --------- ---------- ---------- -------------- ---------- ------------- ---------------
            142 Curtis               Davies                    CDAVIES                   650.121.2994         29-JAN-05 ST_CLERK         3100                       124            50      3475.55556
            143 Randall              Matos                     RMATOS                    650.121.2874         15-MAR-06 ST_CLERK         2600                       124            50      3475.55556
            144 Peter                Vargas                    PVARGAS                   650.121.2004         09-JUL-06 ST_CLERK         2500                       124            50      3475.55556
            180 Winston              Taylor                    WTAYLOR                   650.507.9876         24-JAN-06 SH_CLERK         3200                       120            50      3475.55556
            181 Jean                 Fleaur                    JFLEAUR                   650.507.9877         23-FEB-06 SH_CLERK         3100                       120            50      3475.55556
            182 Martha               Sullivan                  MSULLIVA                  650.507.9878         21-JUN-07 SH_CLERK         2500                       120            50      3475.55556
            183 Girard               Geoni                     GGEONI                    650.507.9879         03-FEB-08 SH_CLERK         2800                       120            50      3475.55556
            186 Julia                Dellinger                 JDELLING                  650.509.3876         24-JUN-06 SH_CLERK         3400                       121            50      3475.55556
            187 Anthony              Cabrio                    ACABRIO                   650.509.4876         07-FEB-07 SH_CLERK         3000                       121            50      3475.55556
            190 Timothy              Gates                     TGATES                    650.505.3876         11-JUL-06 SH_CLERK         2900                       122            50      3475.55556
            191 Randall              Perkins                   RPERKINS                  650.505.4876         19-DEC-07 SH_CLERK         2500                       122            50      3475.55556
    
    EMPLOYEE_ID FIRST_NAME           LAST_NAME                 EMAIL                     PHONE_NUMBER         HIRE_DATE JOB_ID         SALARY COMMISSION_PCT MANAGER_ID DEPARTMENT_ID DEPT_50_AVG_SAL
    ----------- -------------------- ------------------------- ------------------------- -------------------- --------- ---------- ---------- -------------- ---------- ------------- ---------------
            194 Samuel               McCain                    SMCCAIN                   650.501.3876         01-JUL-06 SH_CLERK         3200                       123            50      3475.55556
            195 Vance                Jones                     VJONES                    650.501.4876         17-MAR-07 SH_CLERK         2800                       123            50      3475.55556
            196 Alana                Walsh                     AWALSH                    650.507.9811         24-APR-06 SH_CLERK         3100                       124            50      3475.55556
            197 Kevin                Feeney                    KFEENEY                   650.507.9822         23-MAY-06 SH_CLERK         3000                       124            50      3475.55556
    
    37 rows selected.
    
    SQL> 
    

    SY.

  • SQL statement causes the database to hang

    Guys,

    a DBA told me that there is something wrong with this SQL statement and causes a blockage of database...

    Please check.

    SELECT field1 FROM table1 WHERE Field1 LIKE ' %% ' AND field2 = '123456' ORDER BY Field2 ASC

    Tell me, what is the problem with statement above. The LIKE operator is?

    Thanks for the help!

    Are not specifically related to your question, but having a clause such as ' where Field2 ='123456 "and then you place your order on Field2 is not really going to do much for you, all values will be identical!

    Carl

  • SQL SQL statement generator

    I see a source code for web site developers to use SQL Builder to build about 300 queries to SQL Server, but it can be done by a stored procedure or a group clause in the SQL statement.

    The performance of the web site seems OK,

    I would like to know ColdFusion runs the SQL Server 300 times or he is smart enough to know and convert it to face once the server only once.

    Is there a performance impact ColdFusion or SQL Server-side?

    Your information and your help is much appreciated,

    Kind regards

    iccsi,

    iccsi wrote:

    My question is that 300 queries can be simplified as a simple SQL as

    Select MyName, count (MyID) from myTable

    where myname = "Name1".

    Group by MyName

    Select MyName, count (MyID) from myTable

    where myname = "Name2".

    Group by MyName

    Select MyName, count (MyID) from myTable

    where myName = 'Name3 '.

    Group by MyName

    Maybe a couple of uses as follows

    Select MyName, count (MyID) from myTable

    Group by MyName

    or save it as a stored procedure that the web server or web page only the database server a hit instead of 300 times.

    I would like to know ColdFusion is smart enough to know the SQL are similar and only execute SQL against dabase server.

    In my view, query-of-a-query is a smart enough solution for the problem. In the following example, ColdFusion visits the database only once!

    Select MyName, count (MyID) from myTable

    Group by MyName

    Select *.

    from myQuery

    where myname = "Name1".

    Select *.

    from myQuery

    where myname = "Name2".

    ...

    ...

    Select *.

    from myQuery

    where myname = "Name300."

Maybe you are looking for