PL/SQL fetch statement.

Hi guys,.

I am a DBA and I have fair knowledge of PL/SQL. My developer argues me with code where he says he becomes RANK NEXT in each adverse FETCH that he wrote after the first FETCH statement below. He uses a lot these its FETCH to get the row in a cursor that has 17 million lines, too in a loop after extraction, for the first time. My understanding is if extraction is going to give you all of the defined file as returned by the cursor, unless otherwise stated. Please let me know if I'm correct, and how can I make him understand this.

-Open the cursor

Open c1;


-Read the column header record then record of first data

Fetch c1 into Field1, Field2, field3, field4 sphere5.

-IF found THEN % c1
-fetch c1 into Field1, Field2, field3, field4 sphere5.
-END IF;

-Loop main most project files.

< < draft_loop > >
While c1% LOOP

OK_flg: = TRUE;
Caution_flg: = FALSE;

-- NEW INPUT RECORD --------------------------------------------------------------------------------

IF field2 = n THEN

-Save data recording N

rec_serial_no: = TRIM (field4);
rec_agent: = TRIM (field5);

-Read the next record

Fetch c1 into Field1, Field2, field3, field4 sphere5.

ON THE OTHER

OK_flg: = FALSE;

dbms_output.put_line('ERR01:)) Current type is not TYPE = N: line =' | Field1 | ' Type =' | Field2);

END IF;

-- SOLD INPUT RECORD ------------------------------------------------------------------------------

IF field2 = the of ' OK_flg AND THEN

-Save the file S

rec_amount: = to_number (sphere5) / 100;
rec_sold_text: = TRIM (field4);
rec_sold_date: = to_date (field3, ' dd/mm/yyyy hh24:mi:ss');

-Read the next record

Fetch c1 into Field1, Field2, field3, field4 sphere5.


ELSIF Field2 = "C" AND OK_flg THEN

-Save data file C

rec_caution_date: = TO_DATE (field3, ' dd/mm/yyyy hh24:mi:ss');
rec_caution_no: = TO_NUMBER (field5);
rec_caution_text: = TRIM (field4);

caution_flg: = TRUE;

-Read the next record

Fetch c1 into Field1, Field2, field3, field4 sphere5.


ON THE OTHER

OK_flg: = FALSE;

dbms_output.put_line ('ERR02: current Type is not TYPE = S: line ='| field1 |) ' Type =' | Field2);

END IF;

darul75 wrote:

My question was however with the FETCH statement. I always thought that, as we open the cursor and then when we fetch we get whole dataset (can be limited to a few lines) and then we iterate through the value until we exhaust all what it several rows.

A cursor is not a data group. A call to fetch is much more than a simple data extraction.

SQL is the source code. The cursor is the binary SQL source code and compiled executable version. Want to see how this executable program, aka cursor looks like? See the execution plan. This explains the structure of executing this cursor/program.

An extraction run this slider. It loads the cursor to run, to find the rows (one or more) and then return rows found in the appellant. This explains, for example, "snapshot too old" - as when the cursor is (yet) run by an extraction, the cursor code cannot find all the lines that the version of the data, the cursor is responsible for finding, has now ceased to exist as the said container version redo buffer has been replaced.

If the cursor is a dataset that was built, what memory would hold this dataset? How this scale there are 1000's of opening sessions several sliders and each cursor requires a piece of memory of the server for all of its data?

This is not a method that would be globally, or deliver any kind of performance.

The best place to perform cursor processing is in the SQL engine. For example, your code example uses a cursor to read. The cursor is driven out of PL/SQL. The output of the cursor moves the engine SQL in variables of fetch in the PL/SQL engine. Then, the code example uses one or more write cursors - return the values of recoveries in the PL/SQL engine to the SQL engine. Data will leave a cursor to another cursor via a detour of PL/SQL. Why? This can NEVER evolve.

If instead you use a single slider to perform both read and write, the data doesn't have to travel via PL/SQL from reader to writer - as this unique time cursor reads and writes data. And because it's a stand-alone cursor, it can also be run in parallel when it comes for example from large chunks of data via a full table scan.

Opening a cursor in PL/SQL, browsing this slider in PL/SQL, data retrieval of this PL/SQL cursor - wrong most of the time. It's the 80's style COBOL record-by-record processing. An exception to the rule when it comes to databases, datasets and SQL data processing language.

Tags: Database

Similar Questions

  • SQL SELECT statement as a parameter in the procedure of string

    Hi all

    I'm new to PL/SQL and I must get a procedure as parameter select SQL select statement as a VARCHAR and the production output the result of the statement with a few changes. Can someone help me solve this problem?

    A possibility I thought at was to use a REF CURSOR. The following example works but binds me to a specific table (in the example of the "customers" table). However, I need the ability to specify arbitrary tables in the select statement parameter.
    SET SERVEROUTPUT ON
    DECLARE
      TYPE my_cur IS REF CURSOR;
      query_cursor my_cur;
    BEGIN
      OPEN query_cursor FOR 'SELECT * FROM customers';
      DECLARE
        record_type customers%ROWTYPE;
      BEGIN
         LOOP
            FETCH query_cursor INTO record_type;
            EXIT WHEN query_cursor%NOTFOUND;
            DBMS_OUTPUT.PUT_LINE('some output ... ');
         END LOOP;
      END;
      CLOSE query_cursor;
    END;
    /
    My idea was to modify this example to work in the following code, but it does not work (I get a compile error):
    SET SERVEROUTPUT ON
    DECLARE
      TYPE my_cur IS REF CURSOR;
      query_cursor my_cur;
    BEGIN
    
      OPEN query_cursor FOR 'SELECT * FROM customers';
    
      DECLARE
        record_type query_cursor%ROWTYPE;
      BEGIN
         LOOP
            FETCH query_cursor INTO record_type;
            EXIT WHEN query_cursor%NOTFOUND;
            DBMS_OUTPUT.PUT_LINE('some output ... ');
         END LOOP;
      END;
      
      CLOSE query_cursor;
    
    END;
    /
    Does anyone has an idea how can I solve my problem?

    Thank you very much!
    (I'm using Oracle 11 g)

    This can help.
    Re: Dynamic Extraction on dynamic Sql

  • What is the sql SELECT statement to list all service names in the database?

    What is the sql SELECT statement to list all service names in the database?

    I tried
    SELECT name FROM dba_services
    But a long with valid service, he list also some other documents that are not the names of services.

    Hello

    You can try this query:

    select name, value from v$parameter where name = 'service_names';
    

    Hope this helps.
    Best regards
    Jean Valentine

  • Updates using the single SQL Update statement.

    Hi guys,.

    I got an interview... and was not able to answer a question.

    In view of the table emp... need to update the salary with the following requirement by using an SQL statement.

    1 update salary + 1000 for employees who receive pay between 500 and 1000
    2 update salary + 500 for employees who receive wages between 1001 and 1500

    The two above the requirement should be made using only a SQL update statement... can someone tell me how to do?
    update emp
      set salary   = case when salary between 500 and 1000
                                then salary + 1000
                                when salary between 1001 and 1500
                                then salary + 500
                          end;
    

    Concerning
    Arun

  • NULL in PL/SQL SELECT statement..

    Hi all

    I need to use as a result of a SELECT statement in my function to get PCODE from the table. Cur_rec here. CODE comes from cursor that runs before the declaration.

    SELECT PCODE in v_pcode TABLE_XYZ where CODE = cur_rec. CODE and PCODE = 'VIEW '.


    Now the problem is the part of the CODE has all the information in the table TABLE_XYZ. In this case, it triggers an error NO_DATA_FOUND. To solve it, I can put a part of the EXCEPTION and handle it. But I think in another way...

    If there is no data for a CODE, the default value of v_pcode would be 'No Code'. I tried to use the NVL function, but it does not work here as a SQL SELECT statement.

    Can someone give an idea how to achieve this?

    Hello

    declare
      ...
      v_cnt number;
    begin
      SELECT count(*)
           into v_cnt
          from TABLE_XYZ
        where CODE = cur_rec.CODE
           and PCODE='SEE';
      if v_cnt=0 then
        v_pcode = 'No code';
      else
        v_pcode = 'SEE';
      end if;
    end;
    

    Bartek

  • How to convert the next update of FORALL to run the SQL UPDATE statement

    I have a FORALL loop for updating a table. It takes too much time. I want to rewrite the code to a direct sql UPDATE. Also of other tips or tricks that can help to run the fastest proc?
    CURSOR cur_bst_tm IS
    SELECT listagg(tm, ' ') WITHIN GROUP(ORDER BY con_addr_id) best_time,
           con_addr_id
       FROM   (select Trim(Upper(con_addr_id)) con_addr_id,
                      '&'
                      ||decode(Initcap(start_day), 
                                      'Monday', 'm',
                                    'Tuesday', 'tu',
                                    'Wednesday', 'w',
                                    'Thursday', 'th',
                                    'Friday', 'f',
                                     Initcap(start_day))
                      ||'='
                      ||trunc(( ( TO_DATE(start_tm,'HH12:MI:SS PM') - trunc(TO_DATE(start_tm,'HH12:MI:SS PM')) ) * 24 * 60 ))
                      ||','
                      ||trunc(( ( TO_DATE(end_tm,'HH12:MI:SS PM') - trunc(TO_DATE(end_tm,'HH12:MI:SS PM')) ) * 24 * 60 )) tm
               FROM   (SELECT DISTINCT * FROM ODS_IDL_EDGE_OFFC_BST_TM)
                 WHERE con_addr_id is not null)
      GROUP  BY con_addr_id
      ORDER BY con_addr_id;
    
    TYPE ARRAY IS TABLE OF cur_bst_tm%ROWTYPE;
    l_data ARRAY;
    
    
    BEGIN
    
     OPEN cur_bst_tm;
        
         LOOP
        FETCH cur_bst_tm BULK COLLECT INTO l_data LIMIT 1000;
    
        FORALL i IN 1..l_data.COUNT
      
          UPDATE ODS_CONTACTS_ADDR tgt
          SET best_times = l_data(i).best_time,
          ODW_UPD_BY = 'IDL - MASS MARKET',
           ODW_UPD_DT = SYSDATE,
          ODW_UPD_BATCH_ID = '0'
          WHERE Upper(edge_id) = l_data(i).con_addr_id
           AND EXISTS (SELECT 1 FROM ods_idl_edge_cont_xref src
                       WHERE tgt.contacts_odw_id = src.contacts_odw_id
                          AND src.pc_flg='Y')   
           ;       
    
        EXIT WHEN cur_bst_tm%NOTFOUND;
        END LOOP;
         
      CLOSE cur_bst_tm;
    Record count: -.

    Select count (*) from
    ODS_IDL_EDGE_OFFC_BST_TM;
    140 000

    SELECT count (*)
    Ods_idl_edge_cont_xref SRC
    WHERE src.pc_flg = 'Y';
    118 000

    SELECT count (*)
    OF ODS_CONTACTS_ADDR;
    671 925

    Version of database 11g.

    Execution plan for update:
    Operation object name lines cost/output PStart PStop object node bytes

    Mode of UPDATE STATEMENT Optimizer = ALL_ROWS 6 K 8120
    UPDATE ODW_OWN2. ODS_CONTACTS_ADDR
    SEMI 6 K 256 K 8120 HASH JOIN
    TABLE ACCESS FULL ODW_OWN2. ODS_CONTACTS_ADDR 6 K 203 K 7181
    TABLE ACCESS FULL ODW_OWN2. ODS_IDL_EDGE_CONT_XREF K 118 922 K 938

    Edited by: user10566312 May 14, 2012 01:07
  • 42000 SQL error state

    I have a sql 2005 with Service Pack 3 installed on a machine and on the second machine CA ARCserve backup software R16.5 installed and configured to use the SQL 2005 as its database, the backup and the restaurant's fines and thers one is work of migration that is created and when we try to change the work of migration to change the data and the time it says its completed successfully , but the modified date is not kept and we see the following error in our newspaper [SQL] _ASDBCliUpdateStagingGroup (rc = SQL state error: 42000, native error Code: 66, ODBC error: [Microsoft] [ODBC SQL Server driver] [SQL Server] incorrect syntax near '&'.), any suggestion to solve this problem

    It is not a community forum for SQL. Ask the experts on TechNet.

    Go to http://social.technet.microsoft.com/Forums/en-us/categories/ select "find a forum.

    and then look for SQL the list of forums. You must then select the most appropriate forum

    in this list.

    Don

  • SQL select statements

    Hey everybody,

    First of all, Yes, I searched through the 8.5 database schema guide.  As I went through the scheme, I've developed some ideas on how to collect the data you want.  However, if someone has already developed or found the SQL statements (which I'm sure that someone already has) it would help by reducing to the minimum of the buggs in my data collection program.

    All these statistics must be grouped by CSQ and selected for a certain time interval ( and ).  That is, levels of 1 hour.  I have no problem to get a list of results and then perform v.f. to achieve the desired final result.  Also, if I need to run several select statements for tables of essentially two join, please include two statements.  Finally, I saw the RtCSQsSummary table, but I need to collect data for the past, not at this time.

    1 total calls presented by the CSQ

    2. total number of calls answered by the CSQ

    3 total number of calls abandoned by the CSQ

    4. percentage of calls abandoned by CSQ (if it is not stored in the database, I think: /)

    5. average abandon time in seconds (if it is not stored in the DB, I think: sum () /)

    6. service level - % calls answered in 90 seonds by a set of skills (I have seen metServiceLevel in the ContactQueueDetail table; however, I need to find how to configure this threshold for application)

    7. average speed of response by CSQ

    8 average conversation by CSQ calls

    9. the aggregates connected full-time resources or agents CSQ

    10. resources/agents of CSQ ready time

    I realize that some of them should be easy to find (as I always am search in the guide of db schema), but I was reading how a new record is created for each step of the call so I could easily see how I could get inaccurate information without properly developed select statements.

    Any help will be greatly appreciated.

    Brendan

    Brendan,

    I read your message very well.

    You have the schema of database with tables and description. each table has its associated tables (connected with primary and foreign keys). I think you should start the tables to determine what you need.

    Cisco uses the stored procedure to prepare the reports. the stored procedure is 'sp_csq_interval' to create the report.

    Activity report of Queue Service contact"

    HTH

    Anas

    Please note all useful posts

  • Function of PL/SQL return statement IMG

    APEX 4.0.2

    I have a SQL command that it generate statements of IMG. It looks a bit like this-

    SELECT blah blah blah

    (CASE

    "WHEN p.person_id IS NULL THEN ' < img alt ="nophoto"src =" #WORKSPACE_IMAGES #nophoto.png "/ >"

    "ELSE ' < img alt ="photo"src =" #WORKSPACE_IMAGES #photo.png "/ >"

    END) "PHOTO."

    abwapps.er.GetReviewImage (e.thirty_day_due, e.thirty_day_done, e.sixty_day_due, e.sixty_day_done, e.ninety_day_due, e.ninety_day_done) "REVIEW_OVERDUE_IMAGE."

    blah blah blah

    'PHOTO' and 'REVIEW_OVERDUE_IMAGE' are defined as Standard report columns.

    'PHOTO' is displayed correctly. "REVIEW_OVERDUE_IMAGE" displays the REPLACEMENT text.

    I confirmed that getreviewimage to create the IMG statement correctly by making the field to display as text. The IMG statement seems good.

    Then I took among the mentions IMG generated and hard-coded in the SQL statement. In other words changed the SQL statement as follows

    SELECT blah blah blah

    (CASE

    "WHEN p.person_id IS NULL THEN ' < img alt ="nophoto"src =" #WORKSPACE_IMAGES #nophoto.png "/ >"

    "ELSE ' < img alt ="photo"src =" #WORKSPACE_IMAGES #photo.png "/ >"

    END) "PHOTO."

    ' < img alt = "blah" src = "#WORKSPACE_IMAGES #blah.png" / > "" REVIEW_OVERDUE_IMAGE",

    blah blah blah

    bla displayed instead of blah.png. Firebug shows that #WORKSPACE_IMAGES # is not converted to REVIEW_OVERDUE_IMAGE.

    I don't know what is happening here.

    Walt K wrote:

    APEX 4.0.2

    I have a SQL command that it generate statements of IMG. It looks a bit like this-

    SELECT blah blah blah

    (CASE

    WHEN p.person_id IS NULL THEN 'nophoto'

    ELSE                                'photo'

    END) "PHOTO."

    abwapps.er.GetReviewImage (e.thirty_day_due, e.thirty_day_done, e.sixty_day_due, e.sixty_day_done, e.ninety_day_due, e.ninety_day_done) "REVIEW_OVERDUE_IMAGE."

    blah blah blah

    'PHOTO' and 'REVIEW_OVERDUE_IMAGE' are defined as Standard report columns.

    'PHOTO' is displayed correctly. "REVIEW_OVERDUE_IMAGE" displays the REPLACEMENT text.

    I confirmed that getreviewimage to create the IMG statement correctly by making the field to display as text. The IMG statement seems good.

    Then I took among the mentions IMG generated and hard-coded in the SQL statement. In other words changed the SQL statement as follows

    SELECT blah blah blah

    (CASE

    WHEN p.person_id IS NULL THEN 'nophoto'

    ELSE                                'photo'

    END) "PHOTO."

    "blah" "REVIEW_OVERDUE_IMAGE"

    blah blah blah

    bla displayed instead of blah.png. Firebug shows that #WORKSPACE_IMAGES # is not converted to REVIEW_OVERDUE_IMAGE.

    I don't know what is happening here.

    Probably you create image src reference in the GetReviewImage works by using the substitution string "#WORKSPACE_IMAGES #"? This will not be overridden when used outside of a block in the APEX. To refer to integrated units of DB program APEX session state and the substitution string values, you must use the syntax of PL/SQL function:

    'blah'

    However, I highly recommend the use of HTML phrases in order to remove the literal HTML from report queries and PL/SQL program units whenever it is possible to do.

  • Try to run a SQL statement through the window of OEM 12 c run SQL.  Statement fails

    All,

    I have a 11g database.  When it is initially installed, I installed it in $ORACLE_BASE = / orabin/app/oracle/product and $ORACLE_HOME = $ORACLE_BASE/11gDB_R2.  This is the version 11.2.0.1 to give birth to 11.2.0.3.

    Recently, I installed 11.2.0.4 in $ORACLE_BASE/11.2.0.4.  Then, I upgraded my database at 11.2.0.4.  Everything works fine.

    All my scripts on the linux host logon changed to point my environment at $ORACLE_BASE/11.2.0.4 House and my $PATH when I connect to the linux host is: /orabin/app/oracle/product/11.2.0.4/bin:/orabin/app/oracle/product/11.2.0.4/OPatch:/sbin:/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/home/oracle/bin

    On my OEM Console, the database appears as 11.2.0.4 and me can manage very well.

    However, when I try to use the window of the OEM Console to execute SQL to execute any type of SQL statement, it fails.

    The failure error is:

    Could not launch/orabin/app/oracle/product/11gDB_R2/bin/sqlplus-s/nolog: no such file or directory

    It would be a mistake since the 11gDB_R2 directory tree (the 11.2.0.3 software) has been removed from the host, now that the database is set to level and working as 11.2.0.4.

    I wonder if somewhere in the OEM software, there is always a pointer to the old ORACLE_HOME?  I can't find anything in the .bashrc or other shell scripts that are executed when a Shell session on the host computer which were still the reference to the old directory of 11gDB_R2 so I'm a bit puzzled.

    I have 8 guests, and all have been improved in the same way at 11.2.0.4.  For some databases, the OEM window run SQL is executing the SQL code.

    Someone has some ideas on this?

    Go to the Configuration of the analysis of the database (when you set the password) and update of the Oracle home.   Also do this for all targets listener on this host as well.

  • PL/SQL: Update statement

    SQL dear Experts,

    I'm writing a procedure to execute a simple DML statement. For example below stmt update: I provide COL1 and COL2 as inputs based on the update should run. Can you suggest how this can be implemented?
    UPDATE TABLE1 SET COL1=123 WHERE COL2=456;
    create or replace
    procedure test1 (col1 varchar2,col2 varchar2) as
    
    v_str varchar2(90);
    begin
    v_str := 'update emp set '||col1 ||'= 55 where '||col2 ||'= 7369';
    execute immediate v_str;
    end;
    
    DECLARE
      COL1 VARCHAR2(30);
      COL2 VARCHAR2(30);
    BEGIN
      COL1 := 'SAL';
      COL2 := 'EMPNO';
    
      TEST1(
        COL1 => COL1,
        COL2 => COL2
      );
    END;
    

    Is that what you want?

  • SQL Update statement

    Hi all

    I have a table with 5 columns Col1, Col2, Col3, Col4, Col5. The requirement for the company is that all four columns Col1 by Col4 must be filled or any of the four columns must be filled.

    Any line that does not conform the above rule must be marked as error.

    I would like to know how I update the Col5 with 'Error' when 2 rules above does not comply with a statement direct update (sql).

    For Ex:

    Col1 Col2 Col3 Col4 Col5
    Row1 has b c and d
    Row2
    Row3 a c error
    Row4 a b c error

    Thank you

    More efficient UPDATE would be:

    UPDATE your_table
      SET col5 = 'Error'
      WHERE NOT (
                    (col1 IS NOT NULL AND col2 IS NOT NULL AND col3 IS NOT NULL AND col4 IS NOT NULL)
                 OR
                    (col1 IS NULL AND col2 IS NULL AND col3 IS NULL AND col4 IS NULL)
                )
    /
    

    Or you can create the check constraint:

    ALTER TABLE your_table
      ADD CONSTRAINT your_table_CHK1
        CHECK(
                 (col1 IS NOT NULL AND col2 IS NOT NULL AND col3 IS NOT NULL AND col4 IS NOT NULL)
              OR
                 (col1 IS NULL AND col2 IS NULL AND col3 IS NULL AND col4 IS NULL)
             )
    /
    

    to avoid bad lines in the first place.

    SY.

  • CASE in SQL Server statement

    I'm working on a project for ambulance response times. In the following query, which is in my coldfusion code, I use a CASE statement on a subquery to count of ambulance response times in stores. An ambulance should arrive at an incident of emergency in less than 08:59 (539 seconds), otherwise it is considered to be late. In my coldfusion Transact-SQL code, I am:
    1.) is a subquery.
    2.) counting "number of events"time-based, it took the ambulance to arrive. "
    3.) only count the ambulances of Lee County and excluding A6 type (non-emergency) calls.
    (4.) grouping of date parts.

    SELECT DATENAME ("M", I.I_tTimeDispatch) in the month, (DATEPART ("yyyy", I.I_tTimeDispatch)) AS year,.
    COUNT (CASE WHEN (DATEDIFF ("S", I.I_tTimeDispatch, I.I_tTimeArrival)) BETWEEN 0 AND 539 SO evnt END) AS OnTime.
    COUNT (CASE WHEN (DATEDIFF ("S", I.I_tTimeDispatch, I.I_tTimeArrival)) BETWEEN 540 AND 1028 THEN evnt END) AS of late.
    COUNT (CASE WHEN (DATEDIFF ("S", I.I_tTimeDispatch, I.I_tTimeArrival)) > 1028 THEN evnt END) AS aberrant
    (SELECT I_EventNumber AS evnt, I_tTimeDispatch, I_tTimeArrival, I_kTypeInfo, I_Agency FROM dbo. IIncident) as I
    INNER JOIN dbo. ITypeInfo AS T ON I.I_kTypeInfo = T.ITI_TypeInfo_PK
    WHERE I.I_Agency = 'LC'
    AND T.ITI_TypeID NOT LIKE ' A6. "
    GROUP BY (DATEPART ("M", I.I_tTimeDispatch)), (DATENAME ("M", I.I_tTimeDispatch)), (DATEPART ("yyyy", I.I_tTimeDispatch))
    ORDER BY (DATEPART ("yyyy", I.I_tTimeDispatch)) ASC, ASC (DATEPART ("M", I.I_tTimeDispatch))

    Here's my problem!
    I go in Microsoft Access to check my stats and I get different counts. For example, in April 2008, my coldfusion query returns 3 944 response ambulance in time. My query Access for the same period of time, using only ambulances in Lee County and excluding non A6-emergency returns only 3 805 answers. There is an undercounting of 139 responses. Even for my other tanks of the time, I get a undercount.

    Here is my SQL Access to the tray of response time (< seconds 539 or 08:59):

    SELECT Count (dbo_IIncident.I_EventNumber) AS CountOfI_EventNumber
    FROM dbo_IIncident INNER JOIN dbo_ITypeInfo ON dbo_IIncident.I_kTypeInfo = dbo_ITypeInfo.ITI_TypeInfo_PK
    WHERE (((dbo_IIncident.I_Agency) = "lc") AND ((dbo_ITypeInfo.ITI_TypeID) not as ' a6 * ') AND ((dbo_IIncident.I_tTimeDispatch) between # #4/1/2008 and may 1, 2008 #) AND ((DateDiff ("s", [dbo_IIncident].) [I_tTimeDispatch], [dbo_IIncident]. [I_tTimeArrival])) Between 0 and 539));

    How two queries that are supposed to do the same could return different results?


    In order to dispel any confusion, I write the page temporarily. Please look at because it can help you visualize the problem.
    http://lcfcfn01/secure/GTandLT_8_59.cfm

    Instead of counting, why don't you change your SQL to list the incidents in the two queries instead, then you can see who is included in the T - SQL that are not captured in Access code.

    Phil

  • In PL/SQL CASE statement

    Hi experts, PL/SQL,.

    I'm going a little crazy here, so could someone please point out what I am doing wrong with this case statement:

    Test procedure is:

    CREATE or REPLACE procedure SCOTT.postcode_validate_2 (input_post_code VARCHAR2) as


    alphabet_string VARCHAR2 (52): = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvxwyz";
    number_string VARCHAR2 (10): = '012345789';
    last_part_postcode VARCHAR2 (3): = NULL;

    BEGIN


    IF INSTR (input_post_code,' ') = 0
    THEN
    DBMS_OUTPUT. Put_line ("' it takes a space in the zip code please");
    GOTO end;
    ELSIF LENGTH (SUBSTR (input_post_code, instr (input_post_code,' ') + 1)) > 3
    THEN
    DBMS_OUTPUT. Put_line ("the last part of the postcode can be 3 characters");
    GOTO end;
    ON THE OTHER

    last_part_postcode: = SUBSTR (input_post_code, instr (input_post_code,' ') + 1);
    END IF;


    CASE input_post_code

    WHEN (length (substr (input_post_code, 1, instr(input_post_code,' ')-1)) = 2)
    AND instr (alphabet_string, substr(input_post_code,1,1)). = 0
    AND instr (number_string, substr(input_post_code,2,1)). = 0)
    THEN
    DBMS_OUTPUT. Put_line ('we have a valid postal code in the format A9')
    -OTHER
    -DBMS_OUTPUT. Put_line ("sorry, but this is an incorrect postal code!") Format A9');
    -GOTO end;
    -END IF;

    WHEN (length (substr (input_post_code, 1, instr(input_post_code,' ')-1)) = 3)
    AND instr (alphabet_string, substr(input_post_code,1,1)). = 0
    AND instr (alphabet_string, substr(input_post_code,2,1)). = 0
    AND instr (number_string, substr(input_post_code,3,1)). = 0)
    THEN
    DBMS_OUTPUT. Put_line ('we have a valid postal code in the format AA9')
    -OTHER
    -DBMS_OUTPUT. Put_line ("sorry, but this is an incorrect postal code!") AA9 format');
    -GOTO end;
    -END IF;

    WHEN (length (substr (input_post_code, 1, instr(input_post_code,' ')-1)) = 3)
    AND instr (alphabet_string, substr(input_post_code,1,1)). = 0
    AND instr (number_string, substr(input_post_code,2,1)). = 0
    AND instr (number_string, substr(input_post_code,3,1)). = 0)
    THEN
    DBMS_OUTPUT. Put_line ('we have a valid postal code in the A99 format')
    -OTHER
    -DBMS_OUTPUT. Put_line ("sorry, but this is an incorrect postal code!") A99 format');
    -GOTO end;
    -END IF;

    WHEN (length (substr (input_post_code, 1, instr(input_post_code,' ')-1)) = 3)
    AND instr (alphabet_string, substr(input_post_code,1,1)). = 0
    AND instr (number_string, substr(input_post_code,2,1)). = 0
    AND instr (alphabet_string, substr(input_post_code,3,1)). = 0)
    THEN
    DBMS_OUTPUT. Put_line ('we have a valid postal code in the format A9A')
    -OTHER
    -DBMS_OUTPUT. Put_line ("sorry, but this is an incorrect postal code!") A9A format');
    -GOTO end;
    -END IF;

    WHEN (length (substr (input_post_code, 1, instr(input_post_code,' ')-1)) = 4)
    AND instr (alphabet_string, substr(input_post_code,1,1)). = 0
    AND instr (alphabet_string, substr(input_post_code,2,1)). = 0
    AND instr (number_string, substr(input_post_code,3,1)). = 0
    AND instr (number_string, substr(input_post_code,4,1)). = 0)
    THEN
    DBMS_OUTPUT. Put_line ('we have a valid postal code in the format AA99')
    -OTHER
    -DBMS_OUTPUT. Put_line ("sorry, but this is an incorrect postal code!") AA99 format');
    -GOTO end;
    -END IF;

    WHEN (length (substr (input_post_code, 1, instr(input_post_code,' ')-1)) = 4)
    AND instr (alphabet_string, substr(input_post_code,1,1)). = 0
    AND instr (alphabet_string, substr(input_post_code,2,1)). = 0
    AND instr (number_string, substr(input_post_code,3,1)). = 0
    AND instr (alphabet_string, substr(input_post_code,4,1)). = 0)
    THEN
    DBMS_OUTPUT. Put_line ('we have a valid postal code in the format AA9A')
    -OTHER
    -DBMS_OUTPUT. Put_line ("sorry, but this is an incorrect postal code!") AA9A format');
    -GOTO end;
    -END IF;
    END;


    -Check the last part of the format, should be AA9
    IF (instr (number_string, substr(input_post_code,1,1))! = 0)
    AND instr (alphabet_string, substr(input_post_code,2,1)). = 0
    AND instr (alphabet_string, substr(input_post_code,3,1)). = 0)
    THEN
    DBMS_OUTPUT. Put_line ('end part of the code postal is the appropriate format, 9AA');
    ON THE OTHER
    DBMS_OUTPUT. Put_line ("' end part of the postcode is in a wrong format!");
    END IF;

    < < output > >
    DBMS_OUTPUT. Put_line ("Please try again");
    END;
    /

    However, I get the following error:

    LINE/COL ERROR
    -------- -----------------------------------------------------------------
    37/6 PLS-00103: encountered the symbol "WHEN" what awaits an of
    What follows:
    := . ( % ;

    On a second note, can't be incorporated into the (currently commented) case ELSE structure?

    Thank you very much in advance.

    Dev

    The initial error was just a problem with your procedure. The other has to do with how you use the CASE statement.
    The code seems a bit long for what you're trying to do. Could you describe what your needs are?

  • SQL * more State 2091 internal error error

    version: 9i

    When executing SQL queries, I get this error:


    SQL * more internal error state 2091, context 0:0:0
    Dangerous to proceed

    Try to upgrade your SQL client * more...

    Using specific syntactic 9i? Sometimes more old SQL * more can't handle the syntax 'most recent '.

Maybe you are looking for