To parse a string value in a Select statement by using features of characters

I need to put a single space between the last number and the first character in a string. These channels will always begin with a number. For example, the string can be:
555B11#1A MAIN ST.
I have to return the following:
555 B11#1A MAIN ST.
Note the space after the 555 and before the B. The rest of the chain must remain the same. Is it possible is a Select SQL statement, using the features of character?

Any help would be greatly appreciated.

Sharpe says:
Indeed, it works. Thank you!

1  SELECT REGEXP_REPLACE ('555B11#1A MAIN ST.', '([[:digit:]])([[:alpha:]])', '\1 \2', 1, 1)     AS
2* FROM    dual
SQL> /

NEW_ADDR
-------------------
555 B11#1A MAIN ST.

SQL>
{code)

Can you help me understand what the pattern parameter '([[:digit:]])([[:alpha:]])' means and what it is doing exactly?  

Sure. I was waiting to see if that expression really worked on your complete data before explaining. An explanation of the code that works is more generally more instructive than an explanation of the code that does not work, and you will only need to maintain code that works.

[[: digit:]] means just that: all the digits ' 0 'to 9'. I could have used \d, as Solomon has done.
[[: alpha:]] means any alphabetical character. You want to just insert a space, when a digit is immmdiately letter, followed by one on the right? In other words, if there is already a space after the first group of numbers, I guess that you do not want to add another space.

And that means parameter replacement '\1 \2' and what he does exactly?

Put the expressions inside parentheses above allows to refer to the exact substring match using Backreferences . The backreference \1 refers to the part of the pattern that starts with 1 ' ('. left \2 backreference refers to the alternative ground that begins with the 2nd '('. gauche Dans l'exemple, vous avez donné, le patron de (digit) (letter) which was first a '5 b', then '\1' means '5' and '\2' is 'B'.))
Thus, the 2nd argument says "seek a model made up molasses maximum figure, followed immediately by a letter".
The 3rd argument says 'replace this template with the same number you found, then a space, then the same letter you have found'.
The 5th argument said only change the 1st occurrence of the pattern. The default is to change each of them, but that would have changed 1 'a' to ' 1' later in the string, and you said that you didn't want that.
The 4th argument is the default value; We do not have ' really need, except that we cannot pass the 5th argument without passing the argument 4th in front of her (at least not in the versions of Oracle that I use).

Tags: Database

Similar Questions

  • How to use the Type of Oracle Table values in the Select statement.

    Hello

    I get the initial set of values in the Table of Type Records of the Oracle and want to use the list of values in the Select statement.

    For example, try something like the following:

    TYPE t_record () IS RENDERING
    ID TABLEA.ID%type,
    NO TABLEA.NO%type

    );
    v_record t_record;
    T_table TYPE IS the v_record TABLE % TYPE;
    v_table t_table;

    -Code to fill the values of v_table here.

    SELECT ID, NO, COLLECT in BULK IN < some other table variabes here > FROM TABLEA
    WHERE ID IN (i) v_table USER.USER;

    I want to know how to use the Type of Oracle Table values in the Select statement.

    Something like this:

    create or replace type t_record as  object (
    id number,
    no number
    )
    /
    
    CREATE or replace type t_table AS TABLE OF t_record;
    /
    
    set serveroutput on
    declare
    
      v_table t_table := t_table();
      v_t1 t_table := t_table();
    
    begin
    
      v_table.extend(1);
      v_table(1).ID := 1;
      v_table(1).No := 10;
    
      v_table.extend(1);
      v_table(2).ID := 2;
      v_table(2).ID := 20;
    
      SELEC t_record (ID,NO) BULK COLLECT INTO v_t1
      from TableA
      FROM TABLEA
      WHERE ID IN (select t.ID from table(v_Table) t);
    
      for i in 1..v_t1.count loop
        dbms_output.put_line(v_t1(i).ID);
        dbms_output.put_line(v_t1(i).No);
      end loop;
    end;
    /
    

    No test!

    P;

    Published by: bluefrog on March 5, 2010 17:08

  • How to add an imaginary line in the result of the value of a SELECT statement.

    Hello all-

    I have requirment to add an imaginary line in the result set of a SELECT statement.

    For example lets say it is a pay table having the following columns:

    Number of Payment_id
    status varchar2 (10)
    number amount
    date of payment_date

    so here's the data: -.

    Payment_id status amount payment_date
    applied 1 100 12/07/2008
    2 Reversed 200 01 / 06/2009
    Applied 3 300 01 / 07/2009


    Here is my SQL

    Select * form payment where payment_date > = 01/01/2009

    The output will be

    2 Reversed 200 01 / 06/2009
    Applied 3 300 01 / 07/2009

    My desired output is less than

    2 Reversed 200 01 / 06/2009
    Applied 3 300 01 / 07/2009
    reversed-200 2, 01 / 06/2009-(Dummy Row)

    Third line here is the imaginary line that I add when the status is "reversed".

    I would be very grateful for any help on this...

    Thank you
    Gerard

    Cartesion join against a shadow table is a useful method to create a fictitious line:

    with my_tab as (select 1 cust_id, 1 Payment_id, 'Applied' Status, 100 Amount, to_date('12/07/2008', 'mm/dd/yyyy') payment_date from dual union all
                    select 1 cust_id, 2 Payment_id, 'Reversed' Status, 200 Amount, to_date('01/06/2009', 'mm/dd/yyyy') payment_date from dual union all
                    select 1 cust_id, 3 Payment_id, 'Applied' Status, 300 Amount, to_date('01/06/2009', 'mm/dd/yyyy') payment_date from dual union all
                    select 2 cust_id, 1 Payment_id, 'Applied' Status, 100 Amount, to_date('12/07/2008', 'mm/dd/yyyy') payment_date from dual union all
                    select 2 cust_id, 2 Payment_id, 'Reversed' Status, 200 Amount, to_date('01/05/2009', 'mm/dd/yyyy') payment_date from dual union all
                    select 2 cust_id, 3 Payment_id, 'Applied' Status, 300 Amount, to_date('01/06/2009', 'mm/dd/yyyy') payment_date from dual union all
                    select 2 cust_id, 4 Payment_id, 'Reversed' Status, -400 Amount, to_date('01/06/2009', 'mm/dd/yyyy') payment_date from dual union all
                    select 2 cust_id, 5 Payment_id, 'Applied' Status, 500 Amount, to_date('01/07/2009', 'mm/dd/yyyy') payment_date from dual),
                    --- end of mimicking your table
          dummy as (select 'Reversed' col1, 1 rn from dual union all
                    select 'Reversed' col1, 2 rn from dual)
    select mt.cust_id,
           mt.payment_id,
           mt.status,
           decode(dummy.rn, 2, -1*mt.amount, mt.amount) amount,
           mt.payment_date
    from   my_tab mt,
           dummy
    where  mt.status = dummy.col1 (+)
    order by mt.cust_id, mt.payment_id, dummy.rn nulls first;
    
    CUST_ID     PAYMENT_ID     STATUS     AMOUNT     PAYMENT_DATE
    1     1     Applied     100     07/12/2008
    1     2     Reversed     200     06/01/2009
    1     2     Reversed     -200     06/01/2009
    1     3     Applied     300     06/01/2009
    2     1     Applied     100     07/12/2008
    2     2     Reversed     200     05/01/2009
    2     2     Reversed     -200     05/01/2009
    2     3     Applied     300     06/01/2009
    2     4     Reversed     -400     06/01/2009
    2     4     Reversed     400     06/01/2009
    2     5     Applied     500     07/01/2009
    

    Published by: Boneist on January 7, 2009 23:10
    NB. You may need to mess around with the order if that is not in the order you want. You did not mention what the rules were for all orders expected, so I composed my own * {;-)

    Also, I added a (cust_id) identifier to differentiate different types of payments, as is usually the case. Remove unless it is not applicable to your case.

  • Get multiple values in a select statement in a variable to a procedure

    Hello

    I'm trying to craete a procedure where the entry of the procedure will be a similar string "a, b, c, d" and output the values of a table that matches the value separated by commas of in sting.

    For this.

    create table test (varchar2 (10)) nm;

    Insert test values ('a');

    Insert test values ('b');

    Insert test values ('c');

    Insert test values (');

    Select * from test;

    NM

    ------

    one

    b

    c

    d

    Now I'm doing a procedure where the parameter will be the column values NM of TEST table in a string separated by commas like "a, b, c, d, x, l" there could be false values also.

    The procedure will return only the values that are adapted with column NM from the TEST table for this I created this procedure.

    create or replace procedure p_test (p_nm IN varchar2 / *, THE sys_refcursor p_out * /)

    is

    number of l_len;

    l_val varchar2 (10);

    l_val1 varchar2 (10);

    Start

    l_len: = length (p_nm);

    -dbms_output.put_line (l_len);

    Start

    because me in 1.l_len

    loop

    Select REGEXP_SUBSTR (p_nm, ' ([^,] *)(,|$)', 1, I, NULL, 1) in double l_val;

    -dbms_output.put_line (l_val);

    -Open p_out for

    Select * into l_val1 of test where nm = l_val;

    dbms_output.put_line (l_val1);

    output when l_len is null;

    end loop;

    exception

    When no_data_found then

    null;

    end;

    exception

    while others then

    dbms_output.put_line (' error reason :'||) SQLERRM |' :'|| error code SQLCODE);

    end;

    EXECUTE p_test ('a, b, c, d, q, w');

    OUTPUT-

    one

    b

    c

    d

    This procedure gives me out as I need, but I need to get this in a variable which should be OUT the parameter of this procedure will be called by the JAVA for our application.

    As I already tried to use the refcursor (see the commented part), but it gives me no output during a call there.

    Its a call to this procedure when I use the refcursor (removing comments).

    declare

    l_out sys_refcursor;

    l_val varchar2 (20);

    l_str varchar2 (20): = 'a, b, c, d;

    Start

    p_test (l_str, l_out);

    loop

    extract the l_out in l_val;

    dbms_output.put_line (l_val);

    dbms_output.put_line ('a');

    When the output l_out % notfound;

    end loop;

    end;

    So here I am stuck with that, how to get the result of multiple or I'm missing something here and if there is a better approach to this requirement as I come with that so I'm sharing it here.

    OR if someone can tell me what is the problem with this package-

    create or replace package p_test_api

    is

    type t_rec is rendered (name varchar2 (200));

    type t_tab is table of index by pls_integer t_rec;

    procedure p_pest_proc (p_nm in varchar2, p_out to t_tab);

    end p_test_api;

    /

    create or replace package body p_test_api

    is

    procedure p_pest_proc (p_nm in varchar2, p_out to t_tab)

    is

    number of l_len;

    l_val varchar2 (10);

    l_val1 varchar2 (10);

    Start

    l_len: = length (p_nm);

    Start

    because me in 1.l_len

    loop

    Select REGEXP_SUBSTR (p_nm, ' ([^,] *)(,|$)', 1, I, NULL, 1) in double l_val;

    dbms_output.put_line (l_val);

    Select * bulk collect into p_out test where nm = l_val;

    output when l_len is null;

    end loop;

    exception

    When no_data_found then

    null;

    end;

    exception

    while others then

    dbms_output.put_line (' error reason :'||) SQLERRM |' :'|| error code SQLCODE);

    end p_pest_proc;

    end p_test_api;

    CALL THIS PACKAGE-

    declare

    l_out p_test_api.t_tab;

    l_str varchar2 (20): = 'a, b, c, d;

    Start

    P_TEST_API. P_PEST_PROC (l_str, l_out);

    dbms_output.put_line ('b');

    because me in 1.l_out.count

    loop

    dbms_output.put_line ('a');

    dbms_output.put_line (l_out (i). (Name)

    dbms_output.put_line ('a');

    When the output l_out.count = 0;

    end loop;

    dbms_output.put_line ('a');

    end;

    It won't loop

    I am using-

    Oracle Database 11 g Enterprise Edition Release 11.2.0.1.0 - 64 bit Production

    Thank you

    First of all, get rid of it WHEN OTHERS like William already noted. If you do not want to use the collections:

    SQL > create or replace
    function f_test () 2
    3 p_nm varchar2
    4                  )
    5 return varchar2
    6 is
    v_result 7 varchar2 (4000);
    Start 8
    9. Select listagg (nm, ',') within the Group (nm control)
    10 in v_result
    11 test
    where the 12 «,» | p_nm | ',' like '%', | NM | ',%';
    13 return v_result;
    14 end;
    15.

    The function is created.

    SQL > start
    2 dbms_output.put_line (f_test ('a, b, c, d, x, w'));
    3 end;
    4.
    a, b, c and d

    PL/SQL procedure successfully completed.

    SQL >

    SY.

  • How to select several values with a select statement with other columns

    Hi all

    I have a small request related to the selection of values in a table.

    create table employees (eid, ename varchar2 (20));

    insert into employee values (1, 'Nik');

    insert into employee values (2, "Prashant");

    commit;


    Now, I have a small list of say A, b, C, I want to choose this list with all the lines as

    with test1 as)

    Check the eid, ename for employee

    )

    Select eid, ename, 'A' col1 in test1

    UNION ALL

    Select eid, ename, 'B' col1 in test1

    UNION ALL

    Select eid, ename, 'C' col1 in test1

    but the problem with that is that in production my employee table has millions of records and it scans the employee three times table (or the number of constant values)

    Is there another way to do this.

    Thank you

    Nik

    Here is an approach with the scanning of a single table test1

    Select t.eid, t.ename, c.col1

    t test1

    Cross join (select 'A' col1 of union double all the)

    Select 'B' of all the double union

    Select the double ' C') c

  • Set the first value after the select statement

    Hello

    I have a problem here.

    After you run the statement select, it'll come to me:

    COM
    DLY
    EXC
    NRD
    RDY



    My question: How can I set the first value instead of 'COM' in "EXC"?

    Thank you.

    Hello
    Where you use this instead:

    select *
    from
    (
    select col_name
    ,case when col_name='EXC' then 1 else 0 end as "id"
    from table_name
    )
    order by "id" desc
    
  • can 'build' a select statement by using a control of IF-ELSE?

    I need to create a stored procedure that accepts as pararmeter account number and status. If the status is 'A' for approved, so I want to return all price records in my table of prices for this account number, otherwise if the status is 'R' for the dismissal, I want to read data from a price change of queue, which has also the error code and description. If the status is null, then I want to send prices of the assets of the PRICE table AND rejected him to the Chronogram of the queue of price:

    Can I do something like this in PL/SQL?
    If param_status = 'A' or param_status is null THEN
       SELECT ACCT_NO, PRICE, EFFECTIVE_DATE, null, null
       FROM ACCOUNT
       where ACCT_NO = param_acct_no
    
    Elsif param_status = 'R' or param_status is null THEN
    
    UNION
       SELECT ACCT_NO, PRICE, ENTRY_DATE, ERR_CD, ERR_DESCRIPTION
       from PRICE_CHANGE_QUE
       where ACCT_NO = param_acct_no
           and  STATUS = 'R';
    END IF;
    I ', m using Oracle 11.2, and I plan to return the results as a cursor must be used in a .NET application.

    I need display all prices of ASSETS, or any REJECTED price, according to it if the status is sent on or not.

    Hello

    If you want an application that does it all:

    select  ACCT_NO, PRICE, EFFECTIVE_DATE, null,   null
    from      ACCOUNT
    where     ACCT_NO     = PARAM_ACCT_NO
    and     'A'     = nvl (:PARAM_STATUS, 'A')
         --
        union
         --
    select     ACCT_NO, PRICE, ENTRY_DATE,     ERR_CD, ERR_DESCRIPTION
    from     PRICE_CHANGE_QUE
    where     ACCT_NO = param_acct_no
    and       STATUS      = 'R'
    and     'R'     = nvl (:PARAM_STATUS, 'R')
    ;
    

    SQL is sufficient for this purpose; you needn't PL/SQL.

    It will probably be more effective to your .NET application so check param_status is 'A', 'R' or NULL first, then branch to one of the 3 most effective query.

    I hope that answers your question.
    If not, post a small example data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and also publish outcomes from these data.
    Explain, using specific examples, how you get these results from these data.
    If the problem involves (for example param_status) parameters that are not in any table, and then after a few differetn sets of parameters and the results you want from the same sample for each game data.
    Always tell what version of Oracle you are using.
    See the FAQ forum {message identifier: = 9360002}

  • Return multiple values from a function in a SELECT statement

    I hope I've provided enough information here. If not, let me know what I'm missing.

    I create a view that will combine the information from several tables. Most are pretty simple, but there are a couple of columns in the view that I need to get by running a function within a package. Even if this is quite simple (I have a function named action_date in a package called rp, for example, that I can use to return the date that I need through SOME rp.action_date (sequence_number).

    Here is the question: I really need to return several bits of information of the same record (not only action_date, but also action_office, action_value, etc.)-a join of the tables will work not here, as I will explain below. I can, of course, perform a function separate for each statement, but this is obviously inefficient. Within the select statement of the view, however, I don't know how each of the values that I need to get back.

    For example, right now, I have:

    Table 1:
    sequence_number NUMBER (10),
    name varchar (30),
    ...

    Table2:
    Table1_seq NUMBER (10),
    action_seq NUMBER (10),
    action_date DATE,
    action_office VARCHAR (3),
    action_value VARCHAR (60),
    ...

    I can't just simply join Table1 and Table2 because I have to perform processing in order to determine the rows returned matching, I really need to select. If the package opens a cursor and treats each line until it finds the one I need.

    The following works but is ineffective since all calls to the package returns the columns of the same record. I don't know how to put all the values that I need in the SELECT statement.
    CREATE VIEW all_this_stuff AS
    SELECT sequence_number, name,
    RP.action_date (sequence_number) action_date,
    RP.action_office (sequence_number) action_office,
    RP.action_value (sequence_number) action_value
    FROM table1

    Is there a way to return multiple values in my SELECT statement or I'm going about this all wrong?

    Any suggestions?

    Thank you very much!

    Hello

    What you want is a Query of Top - N , what you can do using the ROW_NUMBER analytic function in a subquery, like this:

    WITH     got_rnum     AS
    (
         SELECT     action_seq, action_dt, action_office, action_type, action_value
         ,     ROW_NUMBER () OVER ( ORDER BY  action_date
                                   ,            action_seq
                             ,            action_serial
                           ) AS rnum
         FROM     table2
         WHERE     action_code     = 'AB'
         AND     action_office     LIKE 'E'     -- Is this right?
    )
    SELECT     action_seq, action_dt, action_office, action_type, action_value
    FROM     got_rnum
    WHERE     rnum     = 1
    ;
    

    As written, this returns a single line (at most).
    I suspect you'll actually get a rank for each group , where a group is defined by a value in a table in which you join.
    In this case, add a PARTITION BY clause to the ROW_NUMBER function.
    If post you a small example of data (CREATE TABLE and INSERT statements), I could show you exactly how.
    As I don't have your tables, I'll show you the use of the tables in the scott schema.
    This is a view containing data in the scott.dept table and also to scott.emp, but only for the highest employee in each Department (in other words, the employee whose oldest hire date). If there be a tie for the first hire date, while the candidate with the lowest empno is selected.

    CREATE OR REPLACE VIEW     senior_emp
    AS
    WITH     got_rnum     AS
    (
         SELECT     d.deptno
         ,     d.dname
         ,     e.empno
         ,     e.ename
         ,     e.hiredate
         ,     ROW_NUMBER () OVER ( PARTITION BY  d.deptno
                                   ORDER BY          e.hiredate
                             ,                e.empno
                           ) AS rnum
         FROM     scott.dept     d
         JOIN     scott.emp     e     ON     d.deptno     = e.deptno
    )
    SELECT     deptno
    ,     dname
    ,     empno
    ,     ename
    ,     hiredate
    FROM     got_rnum
    WHERE     rnum     = 1
    ;
    
    SELECT     *
    FROM     senior_emp
    ;
    

    Output:

    .    DEPTNO DNAME               EMPNO ENAME      HIREDATE
    ---------- -------------- ---------- ---------- ---------
            10 ACCOUNTING           7782 CLARK      09-JUN-81
            20 RESEARCH             7369 SMITH      17-DEC-80
            30 SALES                7499 ALLEN      20-FEB-81
    

    Moreover, one of the conditions to the query you posted has been

    action_office     LIKE 'E'
    

    which equals

    action_office     = 'E'
    

    (AS is always equivalent to = if the string that follows AS does not contain the winning cards.)
    Did you mean say that or did you mean something like this:

    action_office     LIKE 'E%'
    

    Instead?

  • Handeling string in a select statement

    Hi friends,

    I would like to know how I can handle strings in a SQL select statement?

    SQL > SELECT 'string' from dual

    Her send me errors when the string is "or &." For example, as if string = Mike & Karen project

    You can also tell me wht other characters, such as ', & can make a question?

    Thank you.

    citing alternative:
    http://download.Oracle.com/docs/CD/B19306_01/AppDev.102/b14251/adfns_sqltypes.htm#sthref377

  • Calculation using multiple select statements - APEX 4.0

    Hello

    I'm new to APEX, PL/SQL and some SQL knowledge, but I pick up things quickly. I want to make a page element equal to the value of a Select statement minus another Select statement. Statements make the same tables and differ only slightly in the where clause. I don't know the best way to create this calculation. Can someone please help.

    Select the #1 declaration

    Select sum (JE_TRANSACTIONS. DEBIT_AMOUNT) as a "Liberation."
    of "REVREC_FORMS" "REVREC_FORMS"
    "JOURNAL_ENTRIES" "JOURNAL_ENTRIES."
    "JE_TRANSACTIONS" "JE_TRANSACTIONS".
    where "JOURNAL_ENTRIES. "" RELATED_REVREC "=" REVREC_FORMS. " "" REVREC_ID ".
    and "JOURNAL_ENTRIES. "" RECORD_ID_ "=" JE_TRANSACTIONS. " "" RELATED_JOURNAL_ENTRY ".
    and "JOURNAL_ENTRIES. "' RELEASE_TYPE ' = 'Liberation '.
    and "JOURNAL_ENTRIES. "" REVENUE_TYPE "="Software ".
    and "REVREC_FORMS". "" REVREC_ID "=: P12_REVREC_ID

    Select the #2 declaration

    Select sum (JE_TRANSACTIONS. DEBIT_AMOUNT) as "Report".
    of "REVREC_FORMS" "REVREC_FORMS"
    "JOURNAL_ENTRIES" "JOURNAL_ENTRIES."
    "JE_TRANSACTIONS" "JE_TRANSACTIONS".
    where "JOURNAL_ENTRIES. "" RELATED_REVREC "=" REVREC_FORMS. " "" REVREC_ID ".
    and "JOURNAL_ENTRIES. "" RECORD_ID_ "=" JE_TRANSACTIONS. " "" RELATED_JOURNAL_ENTRY ".
    and "JOURNAL_ENTRIES. "" RELEASE_TYPE "="Report ".
    and "JOURNAL_ENTRIES. "" REVENUE_TYPE "="Software ".
    and "REVREC_FORMS". "" REVREC_ID "=: P12_REVREC_ID

    What is

    select   sum(decode(release_type,'Deferral',je_transactions.debit_amount)) - sum(decode(release_type,'Release',je_transactions.debit_amount)) as result
    from   "REVREC_FORMS" "REVREC_FORMS",
    "JOURNAL_ENTRIES" "JOURNAL_ENTRIES",
    "JE_TRANSACTIONS" "JE_TRANSACTIONS"
    where "JOURNAL_ENTRIES"."RELATED_REVREC"="REVREC_FORMS"."REVREC_ID"
    and  "JOURNAL_ENTRIES"."RECORD_ID_"="JE_TRANSACTIONS"."RELATED_JOURNAL_ENTRY"
    and  "JOURNAL_ENTRIES"."REVENUE_TYPE" ='Software'
    and  "REVREC_FORMS"."REVREC_ID" =:P12_REVREC_ID
    

    Scott

  • Create a temporary table and insert using a select statement

    Hello

    I tried to create a temporary table and insert it by using the value in a select statement. Please see below the code

    ---
    CREATE a TEMPORARY TABLE GLOBAL Temp_Test
    (
    DATE OF DAY_FUTURE
    )
    AS
    SELECT TO_DATE (SYSDATE + ROWNUM, 'DD-MON-YY')
    DUAL CONNECT BY ROWNUM FROM < = 14)
    ---

    As soon as I run the script, the error message indicates the following:
    --

    Error from the 1 in the command line:
    CREATE a TEMPORARY TABLE GLOBAL Temp_Test
    (
    DATE OF DAY_FUTURE
    )
    ONLY select TO_DATE (sysdate + rownum, 'DD-MON-YY')
    Double connect rownum < = 14)

    Error in the command line: 2 column: 1
    Error report:
    SQL error: ORA-01773: cannot specify the types of data in this TABLE to CREATE column
    01773 00000 - 'cannot specify the types of column data in this TABLE to CREATE"
    * Cause:
    * Action:
    --


    What seems the problem? I already have the data type such as TO_DATE on my select statement.

    Any help would be appreciated

    Thank you
    SQL> CREATE GLOBAL TEMPORARY TABLE Temp_Test
      2  (
      3  DAY_FUTURE
      4  ) on commit preserve rows
      5  AS
      6  SELECT TO_DATE(SYSDATE+ROWNUM, 'DD-MON-YY')
      7  FROM DUAL CONNECT BY ROWNUM <= 14
      8  /
    
    Table created.
    
    SQL> select count(*)
      2    from temp_test
      3  /
    
      COUNT(*)
    ----------
            14
    
  • How does a facility TestStand to parse a string to a TcpIp Read?

    L & G,

    I am interested by linking TestStand for a product of mine and I downloaded the eval and spin a typically TcpIp sequence as shown in the examples.  I'm trying to understand how to configure TestStand to parse the string coming back from my server too the success/failure and test results information present in the returned string.

    I look forward to your responses and thank you for your help.

    Craig Byrd

    L & G,

    I figured out how to create and use a local variable (string) as the chain of TCPWrite by simply changing the TCPWrite to the stage and set the the Results.Data value to use theLocals.TCP.

    Concerning

    Craig Byrde

  • Could not save the different string value to each element of the array

    I have a configuration of VI to read several channels Veristand project.  The entrance is a table 1 d of channels, (an element for each channel, I want to read).  The channels have different names, each of the elements in the chain must be different.  I am able to edit each item and run the VI, and it works fine.  However, if I save, close and reopen the VI, all elements show the same value (what happens to the value of the last element for which I defined a default value).  Is this behavior planned, or have I missed a configuration setting which would allow different string values?  Please notify.  Thank you.

    GSinMN

    Make sure that you select the table and not only one item when you right click-> set by default on the front panel.

  • comparing string values in the same table

    I have a table with ID (14 digit string values) starting with "A". Ex: A21849B1020792. There may be a different ID with the same substring 'B1020792' in the same table, example: A12349B1020792. If this happens, the ID of the last creation date of must be returned in the result. In other words, comparison is done on the same table. "In the example provided, say A12349B1020792 has the date of 1 January 2015 'and A21849B1020792 has date February 1, 2015", since A21849B1020792 has the most recent date, the result must contain only A21849B1020792.

    ID create_date

    ---                              ------------------

    A21849B1020792 02/01/2015

    A12349 B1020792 01/01/2015

    A12345B1234567 01/03/2015      

    A43567B1234567 01/04/2015      


    Here's the query I used:

    substr (a.id, 7) select sc, max (a.create_date) cd1

    of table a, table b

    where a.id! = b.id

    and substr (a.id, 7) = substr (b.id, 7)

    and a.id like 'A %' and b.id like 'A %' / * (I used a % because I am interested only IDs that begin with A) * /.

    and a.id ('A12349B1020792', 'A21849B1020792','A12345B1234567 ','A43567B1234567')

    Group of substr (a.id, 7);

    Result:

    ---------

    sc                    cd1

    ---                    ------

    B1020792 02/01/2015

    B1234567 04/01/2015

    There is one thing that I'm not able to do with my request, that is, be able to get real IDs list and not list of substrings. If I added a.id column in the select clause and the group by clause, the query includes both by substr (a.id, 7) and a.id and as a result, the query returns four lines as below:

    substr (a.id, 7) select sc, max (a.create_date) cd1, a.id ID

    of table a, table b

    where a.id! = b.id

    and substr (a.id, 7) = substr (b.id, 7)

    and a.id like 'A %' and b.id like 'A %' / * (I used a % because I am interested only IDs that begin with A) * /.

    and a.id ('A12349B1020792', 'A21849B1020792','A12345B1234567 ','A43567B1234567')

    Group by substr (a.id, 7), a.id.

    Result:

    ---------

    sc                    cd1                      ID

    ---                    ------                   ---------

    01/01/2015 A12349B1020792 B1020792

    B1020792 01/02/2015 A21849B1020792

    B1234567 01/03/2015 A12345B1234567

    B1234567 01/04/2015 A43567B1234567


    My goal is to retrieve a list of all the unique identifiers that have the later dates.


    ID:

    ---

    A21849B1020792

    A43567B1234567


    Thanks for your time in advance!

    Hello

    user11951344 wrote:

    I have a table with ID (14 digit string values) starting with "A". Ex: A21849B1020792. There may be a different ID with the same substring "B1020792" in the same table, example: A12349B1020792. If this is the case, the ID of the last creation date must be returned in the result. In other words, comparison is done on the same table. "In the example provided, say A12349B1020792 updated 1 January 2015 ' and A21849B1020792 a date February 1, 2015", as A21849B1020792 has the most recent date, the result should contain only the A21849B1020792.

    ID create_date

    ---                              ------------------

    A21849B1020792 02/01/2015

    A12349B1020792 01/01/2015

    A12345B1234567 03/01/2015

    A43567B1234567 01/04/2015

    Here's the query I used:

    substr (a.id, 7) select sc, max (a.create_date) cd1

    of table a, table b

    where a.id! = b.id

    and substr (a.id, 7) = substr (b.id, 7)

    and a.id like 'A %' and b.id like 'A %' / * (I used a % because I am interested only IDs that begin with A) * /.

    and a.id ('A21849B1020792', 'A12345B1234567', 'A12349B1020792', 'A43567B1234567')

    Group of substr (a.id, 7);

    Result:

    ---------

    sc                    cd1

    ---                    ------

    B1020792 02/01/2015

    B1234567 01/04/2015

    There is one thing that I am not able to do with my request, that is, the ability to retrieve the list of IDs real and not a list of substrings. If I added a.id column in the select clause and the group by clause, the query groups according to the two substr (a.id, 7) and a.id and as a result, the query returns four lines as below:

    substr (a.id, 7) select sc, max (a.create_date) cd1, a.id ID

    of table a, table b

    where a.id! = b.id

    and substr (a.id, 7) = substr (b.id, 7)

    and a.id like 'A %' and b.id like 'A %' / * (I used a % because I am interested only IDs that begin with A) * /.

    and a.id ('A21849B1020792', 'A12345B1234567', 'A12349B1020792', 'A43567B1234567')

    Group by substr (a.id, 7), a.id.

    Result:

    ---------

    sc                    cd1                      ID

    ---                    ------                   ---------

    B1020792 01/01/2015 A12349B1020792

    B1020792 02/01/2015 A21849B1020792

    B1234567 03/01/2015 A12345B1234567

    B1234567 01/04/2015 A43567B1234567

    My goal is to retrieve a list of all the unique identifiers that have the later dates.

    ID:

    ---

    A21849B1020792

    A43567B1234567

    Thanks for your time in advance!

    If it makes sense to treat the first 6 characters of the ID separately from the rest of the id in this problem, maybe it makes sense to store those two parts of the id in two different columns.  Relational databases work best when each column of each row contains 1 single piece of data (at most).  It is so fundamental to the design of table that he called the first normal form.

    Given that the two parts are stored in column 1, so you can something like this Request Top - N:

    WITH got_r_num AS

    (

    SELECT r.id

    r.create_date AS cd1

    , RANK () OVER (PARTITION OF SUBSTR (r.id, 7))

    ORDER BY r.create_date DESC

    ) AS r_num

    FROM table_x g - g for data values

    JOIN table_x r - r for related values

    ON SUBSTR (r.id, 7) = SUBSTR (g.id, 7)

    WHERE g.id IN ('A12349B1020792'

    , "A21849B1020792".

    , "A12345B1234567".

    , "A43567B1234567".

    )

    - AND g.id LIKE 'A %' - if necessary.   The above condition ensures already g.id start with "A".

    AND r.id LIKE 'a % '.

    )

    SELECT id, create_date

    OF got_r_num

    WHERE r_num = 1

    ;

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

  • using the function - how to use the values of the input variables on the table select statement names

    Hello community, I have a problem when creating a function. The purpose of this function is to check the table of weather gave yesterday or not. We must check this on different tables on different sachems. We are creating a function with input variables.

    CREATE OR REPLACE FUNCTION IN_SCHEMA.IS_YDAYDATA_TO_TABLE

    (

    in_schema IN VARCHAR2,

    in_tablename IN VARCHAR2,

    in_datefield IN VARCHAR2,

    )

    RETURNS INTEGER

    AS

    -Declaring variables

    v_is_true INTEGER.

    BEGIN

    SELECT

    CASE

    WHEN MAX (in_datefield) = TRUNC(SYSDATE-1)

    THEN 1

    ON THE OTHER

    0

    END

    IN

    v_is_true

    Of

    in_schema.in_tablename

    ;

    RETURN v_is_true;

    END;

    /

    When creating, I got error: [error] ORA-00942 (44:19): PL/SQL: ORA-00942: table or view does not exist

    How to use the values of the input variables on the table select statement names?

    Hello

    Here's a way you can use dynamic SQL statements for this task:

    CREATE OR REPLACE FUNCTION IS_YDAYDATA_TO_TABLE

    (

    in_schema IN VARCHAR2,

    in_tablename IN VARCHAR2,

    in_datefield IN VARCHAR2,

    in_first_date DATE DEFAULT SYSDATE - 1,.

    in_last_date DATE by DEFAULT NULL

    )

    RETURNS INTEGER

    AS

    -IS_YDAYDATA_TO_TABLE returns 1 if in_schema.in_tablename.in_datefield

    -contains all the dates in the in_first_date of the range through included in_last_date

    - and it returns 0 if there is no such lines.

    -If in_last_date is omitted, the search only the data on in_first_date.

    -If in_first_date is omitted, it defaults to yesterday.

    -Time parts of the in_first_date and in_last_date are ignored.

    -Declaring variables

    sql_txt VARCHAR2 (1000);

    v_is_true INTEGER.

    BEGIN

    sql_txt: = 'SELECT COUNT (*).

    || 'FROM ' | in_schema | '.' || in_tablename

    || 'WHERE ' | in_datefield | ' > =: d1'

    || «AND» | in_datefield | '< >

    || 'AND ROWNUM = 1';

    dbms_output.put_line (sql_txt |) '= sql_txt in IS_YDAYDATA_TO_TABLE");  -For debugging

    Sql_txt EXECUTE IMMEDIATE

    IN v_is_true

    With the HELP of TRUNC (in_first_date) - d1

    TRUNC (NVL (in_last_date

    in_first_date

    )

    ) + 1                -- d2

    ;

    RETURN v_is_true;

    END is_ydaydata_to_table;

    /

    DISPLAY ERRORS

    If you must use dynamic SQL statements, put all the SQL statement in a single string variable, such as sql_txt in the example above.  In this way, you can easily see exactly what will be executed.  Comment out the call to dbms_output under test is completed.

    Try to write functions that will address not only the question that you have now, but similar questions that you may have in the future.  For example, now that interest you only to the verification of the data of yesterday, but later, you might want to check another day or range of days.  The above function combines the convenience of a function simple (looks like yesterday data if you don't tell him otherwise) with the power of a more complex function (you can use the same function to check any day or range of days).

Maybe you are looking for

  • Eve and battery usage

    Hello I have 6 s 128 gig iPhone a week before, I replaced my phone with a new one and this is the second time I replace my phone, the first has a problem with on / off button and the second has a problem in the supply system and the battery did not w

  • T61p: Should I Nvidia Bug with date of manufacture 0825 has 2 25th week 2008?

    Hello. I have a T61p with the following NVIDIA chip production date: 0825a 2 This means the 25th week of 2008. Have I not the Nvidia bug?

  • is it safe to use the PdaNet 3.02 android app?

    has anyone ever used their phone's wi - fi signal to go on the internet with their computer?

  • Date of the manufacturer's warranty

    Hello I bought my cell E5 - 571G online last November 2014 in an online store, I also registered on the Acer site. Then this year on October 2015 I returned my laptop to the store. However, they said that according to guarantee my laptop Acer already

  • voicemail &amp; auto-numbering

    is it possible to implement the '1' keyboard for dialvoicemail AND automatically dialin my code of security rather than having to tap her on the keyboard. On my old phone, the '1' key has been updated dial * 86PP * #, which I've been unable to launch