Create a simple query (SQL)

Hi experts,

I have a table with data as follows:

Database version: 10.2.0.4
Table name: TRANSACTION_HIST_TAB
TRANS_ID      LOT_NO    PART_NO    QTY    TRANSACTION         LOCATION_NO    ROWVERSION
---------     -------   --------   ----   -----------------   ------------   ----------------------
T00000X1      L001     ABC         10     CHANGE LOCATION     WRH_1          01/01/13 08:00:00 AM
T00000X2      L001     ABC        10     CHANGE LOCATION     WRH_2          01/02/13 10:00:00 AM
T00000X3      L002     XYZ        20     CHANGE LOCATION     WRH_3          01/03/13 11:00:00 AM
and I want to create a single query (SQL) which can get data grouped by LOT_NO and only the first transaction by LOT_NO

Expected results:
TRANS_ID      LOT_NO    PART_NO    QTY    TRANSACTION         LOCATION_NO    ROWVERSION
---------     -------   --------   ----   -----------------   ------------   ----------------------
T00000X1      L001     ABC         10     CHANGE LOCATION     WRH_1          01/01/13 08:00:00 AM
T00000X3      L002     XYZ        20     CHANGE LOCATION     WRH_3          01/03/13 11:00:00 AM
Someone has an idea?

Kind regards

Rob

Hi, Rob.

Here's one way:

WITH     got_r_num     AS
(
     SELECT     t.*     -- or list columns you want
     ,     ROW_NUMBER () OVER ( PARTITION BY  lot_no
                               ORDER BY          rowversion
                       )  AS r_num
     FROM    transaction_hist_tab  t
)
SELECT       *     -- or list all columns except r_num
FROM       got_r_num
WHERE       r_num     = 1
;

Depending on your data and your needs, match Sub like Manik suggested, might work. I think that you want to GROUP BY lot_no only, no transid.

I hope that answers your question.
If not, post a small example data (CREATE TABLE and only relevant columns, INSERT statements), and the results you want from this data.
Explain, using specific examples, how you get these results from these data.
Always say what version of Oracle you are using (for example, 11.2.0.2.0).
See the FAQ forum {message identifier: = 9360002}

Tags: Database

Similar Questions

  • Auto-relation (Simple query) SQL statement

    Hello

    I just want to know is the following: auto-relation SQL statement
    SELECT ROWID,ACCOUNT_ID,ACCOUNT_NAME,IS_CLOSED,TYPE_ID,ACCOUNT_ID_PARENT 
    FROM GL_ACCOUNTS
    WHERE GL_ACCOUNTS.TYPE_ID = GL_ACCOUNTS_PARENT.TYPE_ID AND
    GL_ACCOUNTS.ACCOUNT_ID_PARENT = GL_ACCOUNTS_PARENT.ACCOUNT_ID
    If not pls I want to create a

    Thanks in advance,

    Kind regards

    Abdetu...

    Abdetu wrote:
    Hello

    I just want to know is the following: auto-relation SQL statement

    SELECT ROWID,ACCOUNT_ID,ACCOUNT_NAME,IS_CLOSED,TYPE_ID,ACCOUNT_ID_PARENT
    FROM GL_ACCOUNTS
    WHERE GL_ACCOUNTS.TYPE_ID = GL_ACCOUNTS_PARENT.TYPE_ID AND
    GL_ACCOUNTS.ACCOUNT_ID_PARENT = GL_ACCOUNTS_PARENT.ACCOUNT_ID
    

    If not pls I want to create a

    Thanks in advance,

    Kind regards

    Abdetu...

    Do you want a self-join or query CONNECT BY (a particular type of self-join that runs recursively).

    Both are described in the documentation

  • How can I create an updateable query sql report

    The impression that after the upgrade of our APEX version I have more option to create an updated report. Some of my former updateable reports seem to work very well, but some will not update when I click on my "submit" button. AT first, they just refreshed the page and ignored my changes of data in the text field. After tinkering with the non-functional region, now I get an ORA-20001 current version of the data in the database has changed etc.

    Help!

    Hello

    OK - first of all, you can always create an update report. When you create a new report, select the report wizard and follow the instructions. When the report has been created you can then move on to be updated. I don't know why it was done this way, but that works.

    Second, on reports that return this error, you have all the columns put a column of Standard report? I found that you must include all columns in the data submitted, even if this means that you must create a second instance of a column in your SQL statement, and then do one of the hidden columns. For example, if you created a tabular presentation the wizard on the EMP table, you get EMPNO and EMPNO_DISPLAY, with hidden EMPNO. You will need to do the same for any column are not changed by the user. Something similar can also occur if you performed any of the items INPUT readonly or disabled because they have not passed by the browser.

    Andy

  • trying to get used to sql * more running and creating a simple procedure

    Hello all;

    I'm getting used to sql * more after using for a while using pl/sql developer.

    I am trying to create a simple procedure and run it. See my procedure below
    create or replace procedure test(t in varchar2(200), limit in number(30))
    begin
    select tbl_report.id from tbl_report where tbl_report.id like '|| t ||%' and rownum <= limit;
    end test;
    and then I type in run hr.test ("J", 10); to run this and then press ENTER, and it does nothing. How can I run and create a simple procedure in sql * more

    Hello

    In addition to all the good points, others have done:

    When you issue a SELECT statement in SQL * Plus (or any other front end) two things happen:
    (1) a result set, containing the results of your query, is produced, and
    (2) this result set is displayed.
    Given that these two things are always done together, it is easy to forget that they are two different things.
    In PL/SQL, you must explicitly do something to catch the result set, and you must explicitly do something else to view it (if you want to display it).

    A simple way to get the result set is to use a cursor FOR loop, to extract a line at a time and run code with this line in a record variable (called the country in the example below).
    View the results is to call dbms_output.put_line.

    Here is an example:

    CREATE OR REPLACE PROCEDURE     test
    (       t       IN      VARCHAR2
    ,     lmt      IN     NUMBER          -- LIMIT is an Oracle keyword; best not to use it as a variable name
    )
    IS
    BEGIN
        FOR  country  IN ( SELECT  country_name
                          FROM    hr.countries
                     WHERE   country_name     LIKE t || '%'
                     AND     ROWNUM          <= lmt
                   )
        LOOP
            dbms_output.put_line (  country.country_name
                        || ' = country_name'
                        );
        END LOOP;
    END test;
    /
    SHOW ERRORS
    

    You can use variables, such as t and lmt, in the query without using dynamic SQL, as long as the variables do not have the same names as the columns in the table. In this case, t and lmt are good names; country_name or region_id wouldn't. (In fact, t is a reputable insofar as it cannot be confused with a column in the table of the country. T is not a good reputation in the sense that it does not give much information about what contains the variable, or how it is used. Why not call the variable target_name or name_a_trouver?

    You can run the SQL procedure * more like this:

    SET     SERVEROUTPUT     ON
    
    EXEC  test ('I', 2);
    

    If you issue the SET SERVEROUTPUT ON command, then you will not see the output of dbms_output. You must only issue the command SET SERVEROUTPUT ON once per session, but nothing bad happens if you do it more than once.

    When I ran the procedure as stated above, I got this output:

    Israel = country_name
    India = country_name
    

    Notice that "The Italy" does not appear, because lmt has 2.

    Do not create your own procedures, tables or other objects in the HR schema, or among all the other patterns created by Oracle. Create your own schema and create procedures and other objects in it.

  • query sql delicate... date of the created object.

    friends...
    I am trying to solve this query sql delicate for some time, but unable to progress when it comes to this day...

    Q.
    Query dba_objects and list all tables created yesterday ' sysdate - 1' and in another column of the list all the tables created ' sysdate - 7'.

    -query below gives me to yesterday, but don't know how to have 'Last_week' column filled... maybe I join?
    select owner, object_name, to_char(created, 'MM-DD-YYYY HH24:MI:SS') "Yesterday", to_char(created, 'MM-DD-YYYY HH24:MI:SS') "Last_Week"
    from dba_objects
    where object_type = 'TABLE'
    and created >=trunc(sysdate - 1)
    and created < trunc(sysdate)
    appreciate your time and effort in looking at this...

    Thank you

    Published by: khallas301 on March 19, 2013 09:27
    typo edited... Thanks to frank

    khallas301 wrote:
    Query dba_objects and list all tables created yesterday ' sysdate - 1' and in another column of the list all the tables created ' sysdate - 7'.

    Well, sysdate - 7 ways months ago, not last week. If this is what you want, then:

    select  owner,
            object_name,
            case
              when trunc(created) = trunc(sysdate - 1) then to_char(created,'MM-DD-YYYY HH24:MI:SS')
            end "Yesterday",
            case
              when trunc(created) = trunc(sysdate - 7) then to_char(created, 'MM-DD-YYYY HH24:MI:SS')
            end "Week Ago"
      from  dba_objects
      where object_type = 'TABLE'
        and (
                trunc(created) = trunc(sysdate - 1)
             or
                trunc(created) = trunc(sysdate - 7)
            )
    /
    

    SY.

  • A simple query with as wrong return result

    Hello

    I run a simple query with like.
    If I use the parameter I get incorrect results.
    If I use the request without parameter results are ok.

    My script:

    ALTER SESSION SET NLS_SORT = BINARY_CI;
    ALTER SESSION SET NLS_COMP = LINGUISTIC;

    -drop table abcd;
    create table abcd (col1 varchar2 (10));

    INSERT INTO VALUES ABCD ('122222');
    insert into abcd values ('111222');


    SELECT * FROM ABCD WHERE COL1 LIKE: 1. -bad result with 12%
    /*
    COL1
    ----------
    122222
    * 111222 *.
    */

    "Select * ABCD where col1 like 12%; -result ok
    /*
    COL1
    ----------
    122222
    */

    I use Oracle Database 11 g Enterprise Edition Release 11.2.0.1.0 - 64 bit Production
    and query, run in Oracle SQL Developer 3.1.07.

    I think it's just a bug, and it is set to 11.2.0.3:

    11.2.0.1:

    DB11.2.0.1>> select * from v$version where rownum=1;
    
    BANNER
    --------------------------------------------------------------------------------
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
    
    1 row selected.
    
    DB11.2.0.1>> ALTER SESSION SET NLS_SORT=BINARY_CI;
    
    Session altered.
    
    DB11.2.0.1>> ALTER SESSION SET NLS_COMP=LINGUISTIC;
    
    Session altered.
    
    DB11.2.0.1>> create table abcd (col1 varchar2(10));
    
    Table created.
    
    DB11.2.0.1>> INSERT INTO ABCD VALUES ('122222');
    
    1 row created.
    
    DB11.2.0.1>> insert into abcd values ('111222');
    
    1 row created.
    
    DB11.2.0.1>> VARIABLE A1 VARCHAR2(10);
    DB11.2.0.1>> EXEC :A1 := '12%';
    
    PL/SQL procedure successfully completed.
    
    DB11.2.0.1>> SELECT * FROM ABCD WHERE COL1 LIKE :A1;
    
    COL1
    ----------
    122222
    111222
    
    2 rows selected.
    

    11.2.0.3:

    DB11.2.0.3>> select * from v$version where rownum=1;
    
    BANNER
    --------------------------------------------------------------------------------
    Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
    
    1 row selected.
    
    DB11.2.0.3>> ALTER SESSION SET NLS_SORT=BINARY_CI;
    
    Session altered.
    
    DB11.2.0.3>> ALTER SESSION SET NLS_COMP=LINGUISTIC;
    
    Session altered.
    
    DB11.2.0.3>> create table abcd (col1 varchar2(10));
    
    Table created.
    
    DB11.2.0.3>> INSERT INTO ABCD VALUES ('122222');
    
    1 row created.
    
    DB11.2.0.3>> insert into abcd values ('111222');
    
    1 row created.
    
    DB11.2.0.3>> VARIABLE A1 VARCHAR2(10);
    DB11.2.0.3>> EXEC :A1 := '12%';
    
    PL/SQL procedure successfully completed.
    
    DB11.2.0.3>> SELECT * FROM ABCD WHERE COL1 LIKE :A1;
    
    COL1
    ----------
    122222
    
    1 row selected.
    

    Kind regards
    Sayan Malakshinov
    http://orasql.org

  • Not sure if I can do this with a simple query.

    CREATE TABLE primary_table (SSN VARCHAR2 (15) VARCHAR2 (30) FIRST_NAME, LAST_NAME VARCHAR2 (30), VARCHAR2 (20)) of the STATE;

    insert into primary_table VALUES ('111-11-1111, 'Elvis', 'Presley', 'ACTIVE');
    insert into primary_table VALUES (222-22-2222', 'Gift', 'King', 'ACTIVE');
    insert into primary_table VALUES ('33-333-3333, 'Lex', 'Harrison', 'ACTIVE');

    CREATE TABLE secondary_table (SSN VARCHAR2 (15) NOT NULL, ARRIVAL DATE, NUMBER of LENGTH_OF_STAY);

    insert into secondary_table VALUES ('11-111-1111 ", 1 January 2011", 10);
    insert into secondary_table VALUES (' ' 222-22-2222 ", March 1, 2011", 10);
    insert into secondary_table VALUES (' ' 222-22-2222 ", June 1, 2011", 20);
    insert into secondary_table VALUES ('' 33-333-3333, January 1, 2011 ", 10);

    ========================================================================================

    Hello

    I created two very simple tables for this exercise. I don't know if I can do this with a simple query, or must use pl/sql.

    I want to join primary_table secondary_table of SSNand list the fields of primary_table, but only if the join returns only a line.

    In other words, I would like to create a list of data primary_table for primary_table lines that have only one line on the secondary table.


    Concerning

    RF25 wrote:
    CREATE TABLE primary_table (SSN VARCHAR2 (15) VARCHAR2 (30) FIRST_NAME, LAST_NAME VARCHAR2 (30), VARCHAR2 (20)) of the STATE;

    insert into primary_table VALUES ('111-11-1111, 'Elvis', 'Presley', 'ACTIVE');
    insert into primary_table VALUES (222-22-2222', 'Gift', 'King', 'ACTIVE');
    insert into primary_table VALUES ('33-333-3333, 'Lex', 'Harrison', 'ACTIVE');

    CREATE TABLE secondary_table (SSN VARCHAR2 (15) NOT NULL, ARRIVAL DATE, NUMBER of LENGTH_OF_STAY);

    insert into secondary_table VALUES ('11-111-1111 ", 1 January 2011", 10);
    insert into secondary_table VALUES (' ' 222-22-2222 ", March 1, 2011", 10);
    insert into secondary_table VALUES (' ' 222-22-2222 ", June 1, 2011", 20);
    insert into secondary_table VALUES ('' 33-333-3333, January 1, 2011 ", 10);

    ========================================================================================

    Hello

    I created two very simple tables for this exercise. I don't know if I can do this with a simple query, or must use pl/sql.

    I want to join primary_table to secondary_table of NSSand the list of fields in the primary_table, but only if the join returns only a line.

    In other words, I would like to create a list of data primary_table for primary_table lines that have only one line on the secondary table.

    Concerning

    Something like...

    select p.
    from primary_table p
    where p.ssn in (select s.ssn from secondary_table s group by s.ssn having count(*) = 1)
    
  • Simple PL/SQL code error

    Hi all

    Below a simple PL/SQL code that is generate details on all PMCs on a particular and entry Department as dept_id.
    create or replace procedure total_info_dept
       (id IN number)
      
        IS
        emp_name varchar2(30);
        dep varchar2(30);
        sal number;
      
        Begin
     for id in (select b.name,c.dept_name,a.salary into emp_name,dep,sal
       from salary a,emp b,dept c where b.emp_id=a.emp_id and b.dept_id=c.dept_id)
       LOOP
     DBMS_OUTPUT.PUT_LINE('The Dept id is '||id||' Salary ' || sal);
       END LOOP;
      END total_info_dept;
    Compiler error is given below: -.

    LINE/COL ERROR
    -------- -----------------------------------------------------------------
    24/6 PL/SQL: statement ignored
    24/27 PLS-00306: wrong number or types of arguments in the call to ' |'

    Help, please

    Concerning
    Adam

    Hi Piku,

    first for formatting your code you need not put the backslash on last {noformat}

    {noformat} tag.
    
    This is the correct way of formatting your code
    i.e.:
    {noformat}
    

    {noformat}
    SELECT...
    {noformat}

    {noformat}
    
    You error is due to the fact that you are not using correctly the cursor.
    
    Your code should be changed in this way:
    

    CREATE OR REPLACE PROCEDURE total_info_dept (id number)
    IS
    -emp_name VARCHAR2 (30); -no need for a local variable
    -dep VARCHAR2 (30);
    -sal NUMBER;
    BEGIN
    FOR id IN (SELECT b.name, c.dept_name, a.salary
    -IN emp_name, dep, sal - for cursor without having to copy it to the local variable
    OF hsalary a, b of the emp, dept c
    WHERE b.emp_id = a.emp_id AND b.dept_id = c.dept_id)
    LOOP
    Dbms_output.put_line ('The Dept id is' | id.dept_name |) "Salary". ID.salary);
    END LOOP;
    END total_info_dept;

    Regards.
    Al                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
    
  • Create the view using SQL DEVELOPER

    I'm new to this forum :)

    11 GR 2, WIN2008 R2

    SQL Developer Version 3.2.09

    I am creating the data below view (view existing)

    Table: Dovmarker
    MARKERBOREHOLE                             UWI             MARKERSURFACE              Z
    WELLXXX               65372643AAAA     Cw     -982,985619574516
    WELLXXX               65372643AAAA     Cn     -1891,47401803955
    WELLXXX               65372643AAAA     J     -674,989528816517
    WELLXXX               65372643AAAA     K3     20,00165000429
    WELLXXX               65372643AAAA     Tr     125,000317308153
    WELLXXX               65372643AAAA     K1     -658,989731894024
    WELLXXX               65372643AAAA     Q     149,999999999549
    
    WELLYYY                          56618334AAAA     Jkm     -715,071442105268
    WELLYYY                          56618334AAAA     K3     36,9013966413975
    WELLYYY                          56618334AAAA     J2     -976,056079257549
    WELLYYY                          56618334AAAA     Tr     106,900507694299
    I try to describe the table and my goal :),

    each line describes wells, uwi(uniqe identifier), z (deppth), high (surface marker)

    I try to merge all lines with the same MARKERBOREHOLE/UWI and MARKERSURFACE contact coresponding Z (ascending) as MARKERSURFACE = Z.
    If it is posibble to reduce the number of decimals to 2.

    My idea to solve the problem:
    example: ' | ' is the delimiter
    WELLXXX    Q=149,999999999549 | Tr=125,000317308153 | K3=20,00165000429 |  K1=-658,989731894024 | J =-674,989528816517 | Cw=-982,985619574516 | Cn=-1891,47401803955
    WELLYYY   Tr=106,900507694299 | K3=36,9013966413975 |  Jkm=-715,071442105268 | J2=-976,056079257549
    or better (not enough knowledge ;))
    WELLXXX    Q=149,999999999549 
                     Tr=125,000317308153
                     K3=20,00165000429 
                     K1=-658,989731894024 
                     J =-674,989528816517 
                     Cw=-982,985619574516 
                     Cn=-1891,47401803955
    
    WELLYYY   Tr=106,900507694299 
                     K3=36,9013966413975 
                     Jkm=-715,071442105268 
                     J2=-976,056079257549
    Number of markersurface is different for each well


    I try to do it by the listagg function, but I have failled
    select markerborehole, listagg(z, ' | ') within group (order by z) as new1 
      from dovmarker
      group by markerborehole;
     
    result:
    WELLZZZ  -2575,95869465411 | -1891,47401803955 | -982,985619574516 | -674,989528816517 | -658,989731894024 | 
    WELLRRR -2376,96975480605 | -2376,96975480605 | -2308,97180590009 | -2308,97180590009 | -2206,47428534641 | -2206,47428534641 | -2163,97522524171
    When I tried to create new view in sql developer I occurred error;
    Error(s) parsing SQL:
    unexpected token near *!* in the following:
    select markerborehole, listagg(z, ' | ') within *!*group (order by z) as new1
    unexpected token near *!* in the following:
    select markerborehole, listagg(z, ' | ') within group *!*(order by z) as new1
    missing expression near *!* in the following:
    select markerborehole, listagg(z, ' | ') within group (*!*order by z) as new1
    Can you help me with this?

    Concerning
    Jaroslaw

    961148 wrote:
    I missed x

    Well Yes, my apologies, I has not changed all that.

    It's a simple way to format the Z value to 2 decimal places?

    Yes. It depends on if you want to use rounded, floor, ceiling, truncate or if you like a string always have 2 decimal places etc.
    Make your choice and customize according to your needs...

    SQL> ed
    Wrote file afiedt.buf
    
      1  with t as (select 'WELLXXX' as MARKERBOREHOLE, '65372643AAAA' as UWI, 'Cw' as MARKERSURFACE, -982.985619574516 as Z from dual union all
      2             select 'WELLXXX', '65372643AAAA', 'Cn', -1891.47401803955 from dual union all
      3             select 'WELLXXX', '65372643AAAA', 'J', -674.989528816517 from dual union all
      4             select 'WELLXXX', '65372643AAAA', 'K3', 20.00165000429 from dual union all
      5             select 'WELLXXX', '65372643AAAA', 'Tr', 125.000317308153 from dual union all
      6             select 'WELLXXX', '65372643AAAA', 'K1', -658.989731894024 from dual union all
      7             select 'WELLXXX', '65372643AAAA', 'Q', 149.999999999549 from dual union all
      8             select 'WELLYYY', '56618334AAAA', 'Jkm', -715.071442105268 from dual union all
      9             select 'WELLYYY', '56618334AAAA', 'K3', 36.9013966413975 from dual union all
     10             select 'WELLYYY', '56618334AAAA', 'J2', -976.056079257549 from dual union all
     11             select 'WELLYYY', '56618334AAAA', 'Tr', 106.900507694299 from dual)
     12  --
     13  -- END OF TEST DATA - IGNORE ABOVE WITH CLAUSE
     14  --
     15  select z
     16        ,round(z,2) as round_z_2
     17        ,floor(z*100)/100 as floor_z_2
     18        ,ceil(z*100)/100 as ceil_z_2
     19        ,trunc(z,2) as trunc_z_2
     20        ,to_char(round(z,2),'fm9990.00') as string_z_2
     21* from t
    SQL> /
    
                      Z  ROUND_Z_2  FLOOR_Z_2   CEIL_Z_2  TRUNC_Z_2 STRING_Z
    ------------------- ---------- ---------- ---------- ---------- --------
     -982.9856195745160    -982.99    -982.99    -982.98    -982.98 -982.99
    -1891.4740180395500   -1891.47   -1891.48   -1891.47   -1891.47 -1891.47
     -674.9895288165170    -674.99    -674.99    -674.98    -674.98 -674.99
       20.0016500042900         20         20      20.01         20 20.00
      125.0003173081530        125        125     125.01        125 125.00
     -658.9897318940240    -658.99    -658.99    -658.98    -658.98 -658.99
      149.9999999995490        150     149.99        150     149.99 150.00
     -715.0714421052680    -715.07    -715.08    -715.07    -715.07 -715.07
       36.9013966413975       36.9       36.9      36.91       36.9 36.90
     -976.0560792575490    -976.06    -976.06    -976.05    -976.05 -976.06
      106.9005076942990      106.9      106.9     106.91      106.9 106.90
    
    11 rows selected.
    

    with above code I try to create a new view in SQL Developer, but I have error:

    Error(s) parsing SQL:
    Unexpected token near *!* in the following:
    select markerborehole, listagg(z,chr(10)) within *!*group(order by rn) as z
    Unexpected token near *!* in the following:
    select markerborehole, listagg(z,chr(10)) within group*!*(order by rn) as z
    Missing expression near  *!* in the following:
    select markerborehole, listagg(z,chr(10)) within group(*!*order by rn) as z
    

    What are all the {noformat}! * * {noformat} in the code? Delete them.

    Edit: or maybe your version of SQL Developer is not up-to-date and does not know the new LISTAGG function in 11g?

    Published by: BluShadow on 26-Sep-2012 09:41

  • Query SQL Report with condition (multiple settings) at the point of the apex?

    Hi all

    I have a small problem and cannot find a solution.

    I need to create reports based on a query, SQL or I.R. Nothing hard here.
    I need to add the WHERE clause dynamically with javascript to an element of the Apex.
    Even once is not very difficult. I set the agenda of the Summit, put my query like this "SELECT * FROM MYTAB WHERE COL1 =: P1_SEARCH" then I call the page by setting the P1_SEARCH value. For example, COL1 is rowid. It works very well.

    But here's my problem. Consider that P1_SEARCH contains several ROWID, and I don't know the number of these values,
    (no I don't create a large number of items and create a query with so much GOLD!), I would sotheming like "SELECT * FROM MYTAB WHERE ROWID IN (: P1_SEARCH) with something like: ROWID1, ROWID2 in P1_SEARCH."

    I also tried: 'ROWID1, ROWID2' and 'ROWID1', 'ROWID2 '.
    but I can't get anything else than the mistake of filter. It works with a value, but as soon as there are two values or more, it seems that the Apex is unable to read the string.


    How can I do it please?

    Thanks for your help.

    Max

    mnoscars wrote:

    But here's my problem. Consider that P1_SEARCH contains several ROWID, and I don't know the number of these values,
    (no I don't create a large number of items and create a query with so much GOLD!), I would sotheming like "SELECT * FROM MYTAB WHERE ROWID IN (: P1_SEARCH) with something like: ROWID1, ROWID2 in P1_SEARCH."

    I also tried: 'ROWID1, ROWID2' and 'ROWID1', 'ROWID2 '.
    but I can't get anything else than the mistake of filter. It works with a value, but as soon as there are two values or more, it seems that the Apex is unable to read the string.

    For a standard report, see + {message identifier: = 9609120} +.

    For an IR - and improve safety by avoiding the risk of SQL Injection, use a collection containing the values in a column instead of a CSV list:
    {code}
    SELECT * FROM MYTAB WHERE ROWID IN (SELECT c001 FROM apex_collections WHERE collection_name = "P1_SEARCH")
    {code}
    (Please close duplicate threads spawned by your original question.)

  • Help with simple PL/SQL package

    Hi, I'm creating a package simple PL/SQL to loop over a list of names and do some special fuzzy criteria in an attempt to clean up the data. Unfortunately... I don't know anything about PL/SQL and hitting problems is to work. Could anyone give a hand?

    p. s.
    table TMP_UTL_MATCH_INPUT has a list of names to corresponding in the column called CLEAN_MERCHANT
    TMP_UTL_MATCH_OUTPUT table should contain the original entry of line # and value, a corresponding output line # and value and calculated edit_distance jaro_winkler similaritise
    table TMP_UTL_MATCH_STATUS is simply updated after each value so I can track where in the process it is obtained (I suspect that this algorithm will take a lot of time...)

    Thanks in advance for any help!
    Scott

    create or replace
    PROCEDURE ' PROCESS_UTL_MATCH_DATA "("START_ROW"EN ENTIER PAR DÉFAUT 1) IS" ".
    -initialize variable here

    whole Num_Rows;
    number of edit_distance_similarity;
    number of jaro_distance_similarity;

    -main body
    BEGIN
    Select count (*) in tmp_utl_match_input num_rows;

    declare name_array as varray (num_rows) of varchar2 (40);

    Select clean_merchant in the TMP_UTL_MATCH_INPUT name_array;

    truncate table tmp_utl_match_status;
    insert into tmp_utl_match_status values (0);

    I'm in 1.num_rows - 1 LOOP
    FOR i j + 1.num_rows LOOP
    edit_distance_similarity = utl_match.edit_distance_similarity (name_array (i), (j) name_array);
    jaro_winkler_similarity = utl_match.jaro_winkler_similarity (name_array (i), (j) name_array;)

    If (edit_distance_similarity > 50 or jaro_winkler_similarity > 50)
    then
    insert into values of tmp_utl_match_output (i, name_array (i), j, (j) name_array, edit_distance_similarity, jaro_winkler_similarity);
    END IF;
    END LOOP;

    Update tmp_utl_match_status set current_row_num = i;
    commit;
    END LOOP;



    EXCEPTION
    WHILE OTHERS THEN
    NULL; -Enter any code exception here
    END;

    I'm sorry. Just discovered that my syntax is incorrect. Cannot bulk collect a select statement. You must use a cursor, so here is the revised code

    create or replace
    PROCEDURE "PROCESS_UTL_MATCH_DATA"("START_ROW" IN INTEGER DEFAULT 1) IS
    --initialize variables here
    
      num_rows integer;
      edit_distance_similarity number;
      jaro_distance_similarity number;
      type Vartab is table of varchar2(40);
      name_array  vartab;
      CURSOR tmp_utl_cur IS
        SELECT clean_merchant FROM tmp_utl_match_input
         ORDER BY row_num;
    
    -- main body
    BEGIN
      OPEN tmp_utl_cur;
      FETCH tmp_utl_cur
        bulk collect into name_array;
      num_rows := name_array.COUNT;
    
      execute_immediate 'truncate table tmp_utl_match_status';
      insert into tmp_utl_match_status values (0);
    
      FOR i in 1..num_rows-1 LOOP
        FOR j IN i+1..num_rows LOOP
          edit_distance_similarity = utl_match.edit_distance_similarity(name_array(i), name_array(j));
          jaro_winkler_similarity = utl_match.jaro_winkler_similarity(name_array(i), name_array(j);
    
          if (edit_distance_similarity > 50 or jaro_winkler_similarity > 50)
          then
            insert into tmp_utl_match_output values (i, name_array(i), j, name_array(j)
                                                    ,edit_distance_similarity, jaro_winkler_similarity);
          END IF;
        END LOOP;
    
        update tmp_utl_match_status set current_row_num = i;
        commit;
      END LOOP;
    
    EXCEPTION
      WHEN OTHERS THEN
        NULL; -- enter any exception code here
    END;
    
  • Problem with a simple query

    Hello, I'll start by saying that I am a noob. in any case, I'm trying to do what I thought was a simple query for records that are greater or equal to the date of the day: it's my request...

    < cfquery name = "getUpcoming" datasource = 'events' >
    SELECT title, eventDate FROM event WHERE eventDate > = #Now () # ORDER BY ASC eventDate
    < / cfquery >

    It works, so, I get the records that are greater than the current date, but all records that match to are not.

    I guess that it is looking at the time as well, or should I completely wrong. I do not know? Any help would be greatly appreciated.

    Good reading up on top of (http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-7f 6f.html), which you must use when you pass dynamic values to the DB, instead of hard-coding the in your SQL string.  And when using , use a param of CF_SQL_DATE type, and must ignore the time portion of the date/time value, you pass (I'm not 100% certain of this... only about 99% certain... but give it a go).  Or spend only the date part of the date/time value in the query.  Using createOdbcDate() fact, without all the extra horsing around adding things together and using the dateFormat() attribute as the previous poster suggested.

    --

    Adam

  • Validation of a region defined as a QUERY SQL type (updated report)

    Hello

    I am trying to perform validation on a region defined as type of QUERY SQL (editable report). The report has two columns.
    One of the columns is a Select list and I want to make sure that the user can select the same value twice
    in the report. For example, if the selection list has 5 values A, B, C, D, E, I don't want a user to be able to select
    B twice in the report. Will it use javascript to perform validation? If Yes, could someone provide some guidance on
    where to embed the javascript? Are there other alternatives than javascript? I create an element that came from a sql query
    counts the number of lines where the value of the column is the same. I then used the item in my validation logic. The problem with this logic
    is that a user can enter the same value and it is not until the 3rd attempt to select the same value that the validation works using the number of lines which is why I think that I need to somehow capture the value of the selection list when a user selects and then compare it to what is already in the database column Select.

    I hope that my question and explanations are clear.

    Thanks in advance for your help,

    Michael

    Hello

    This can be managed using javascript or a validation of the page. Here is an example of use of javascript: [http://htmldb.oracle.com/pls/otn/f?p=267:7]

    To do this, I have:

    1 - a model of button which does not send the page but just runs javascript. The model will depend on your theme, but should include:

    <a href="#BUTTON_ATTRIBUTES#">#LABEL#</a>
    

    If #BUTTON_ATTRIBUTES # appears on the template, delete it as we need it only once. You must create a new button model based on a copy of your existing across models, shared components. Normally, he would show href = "" #LINK # "-we do not want that this would become doSubmit('buttonname')." If your model does not use tags for buttons, you might need to create one from scratch.

    2 - I have updated the button on my page to use this template and then assign the setting button attributes:

    javascript:check();
    

    3. in the header of the HTML page, I added:

    <script type="text/javascript">
    function check()
    {
     var e = 0;
     var f = document.getElementsByName("f02");
     var k1;
     var k2;
     var v1;
     var v2;
     if (f)
     {
      for (k1 = 0; k1 < (f.length - 1); k1++)
      {
       v1 = f[k1].value;
       for (k2 = (k1 + 1); k2 < f.length; k2++)
       {
        v2 = f[k2].value;
        if (v1 == v2)
        {
         e = 1;
        }
       }
      }
     }
     if (e > 0)
     {
      alert("Duplicates found!");
     }
     else
     {
      doSubmit("SUBMIT");
     }
    }
    </script>
    

    In this example, SUBMIT is the name of the button and "f02" is the name attribute of the select list items that we want to check - change these needs by your page.

    Now, when the Submit button is clicked, instead of directly submit the page, the javascript function is called. This function loops through each selection list and gets its value. Then, he compared it to the remaining items. If there is a match, the e flag is set to 1. After all the items have been verified, if e is not 0, then a message appears. Otherwise, the page is sent.

    Andy

  • How to create a database in SQL Server Express 2014 to be used with LV Database Toolkit

    I use LV Database Toolkit, which, by default, uses the Jet database. Now, I want to use the SQL with LV Database Toolkit database. I downloaded and installed "SQL Server Express with Tools 2014" in my laptop of Labview. Now I want to create a database in SQL Server, because I think that it is a requirement for the creation of a "udl connection file" (file *.udl). Please help me!


  • Create Volume Simple

    I went to check out Help & Support center and I followed the steps, and I converted the disk to a dynamic disk to create a simple volume.

    When I went to right click on the dynamic disk, I should click on "New Volume" so I can complete the wizard.

    But the problem is, when I try to click on "New Volume" it doesn't let me, it not show in a dark gray text, how to do now?

    I even tried to use the command promote, but when I enter 'Diskpart', 'create volume simple [size = 400] [disk = 0] '.

    It gives me a new list as:

    Add - Add Mirror

    Create - create the partition or volume

    Exit - exit diskpart

    .. .etc

    What should I do now?

    What is your operating system? The dynamic disk could not work on Windows Home edtiton, BTW, is it one unallocated space on your disk to sylvie, to create the volume, that you must have a space of unalloaceted first of all, you could make reference to 'how volume Dynamics cerate .

Maybe you are looking for