Is there a function "off aggregate" a string of csv in Oracle?

Hello

I want to turn the channel

"7654, 7698, 7782, 7788".

in a list of values that I can use in the WHERE clause of a SELECT statement.

For example,.
select ename
  from emp
 where empno in (somemagicfunction('7654,7698,7782,7788'));
I know how to do the "hard". I'm trying to find out if there is an "easy" way

Thank you for helping.

John.

For many lists, you can also use (from 11r2 upwards):

SQL> var str varchar2(4000)
SQL> exec :str := '7788,7900'
PL/SQL procedure successfully completed.

SQL> select empno, ename from emp where empno in (select to_number(column_value) from xmltable((:str)))
/
          EMPNO ENAME
--------------- ----------
           7788 SCOTT
           7900 JAMES     

2 rows selected.

For a list of varchar2, only a small change is needed...

Tags: Database

Similar Questions

  • Why the function of integrated separator string is missing in Oracle?

    Hi all

    It's maybe a generic/discussion question. And it's purely for learning about how Oracle prioritizes its development on the functions in construction.

    Well, we have very userful built-in functions (http://docs.oracle.com/cd/B19306_01/server.102/b14200/functions001.htm) is transformed during the versions of Oracle from simple to very complex (syntactic xml and data mining functions)

    But why is this important function to split a string has been neglected (may not be the right word) by Oracle.

    Be a learner curious and admirer of such a wonderful technology database called Oracle, I always thought that it must have a dedicated channel, divide the function.

    My question is: is this something that can be generalized in a built-in function?

    or

    Is he coming releases?

    At least a simple function first (I guessed right his name would be splitstr and the very basic features to do our job of splitting, maybe I'm wrong in thinking this way, please correct me if...) Thank you in advance!)

    splitstr('A,B,c',',','col')-> (separator ',' and the fractionating column mode)

    Output: A B C (three separate columns)

    splitstr('A,B,c',',','row')-> (separator ',' and the mode line split)

    Output:

    A

    B

    C

    ----------

    If oracle has this, there will be a lot of code reduced and we can be saved by connect or recursive with clause or as a matter of fact even xmltable (with or without tokenizer ) for the separation of the channels.

    What you have to say about this? You can ignore this naïve question if is not a value you answer.

    And thanks for everyone who reads this discussion!

    See you soon,.

    Manik.

    Can you please help me understand why Oracle has its participation in develping and DBMS_UTILITY.COMMA_TO_TABLE now then?

    http://docs.Oracle.com/CD/B19306_01/AppDev.102/b14258/d_util.htm

    Oracle can only tell you why they have developed this particular function. But the fact that Oracle included in a package of "utility" tells me that they do not consider that there was a generic number of use cases. These functions often begin as internal functions that Oracle decides to publish.

    But if you read this API spec you'll see that he does that to a VERY PARTICULAR use case and has several restrictions.

    The list must be a list separated by commas of non-vide: another thing that a comma-separated list is rejected. Do not count the commas inside double quotes.

    Entries in the list separated by commas may not include multibyte and dashes (-) character.

    Also, returns a collection which would normally be used only for a very limited number of items.

    It is not yet near a general-purpose function.

    A major complication with such a function in SQL is sql is generally used with more than one, or even millions, of lines.

    How you specify to Oracle where to put the collection on each of these lines?

    New - Oracle is a relational database. With the help of sql to manipulate collections is NOT a relational paradigm.

    Just my opinion. Others can and will disagree. But you may have to wait for the weekend for these answers.

  • My gesture control function does not work correctly there on and off automatically

    My gesture control function does not work correctly there on and off automatically

    which application you are using? try reinstalling the media gallery.

  • Is there a function to adjust the length of a string to 8 multiple bytes?

    Hello

    I have a function to encrypt a password.

    FUNCTION encodeit (p_name IN VARCHAR2, p_password IN VARCHAR2) RETURN VARCHAR2
       IS
          l_password   VARCHAR2 (4000);
          l_salt       VARCHAR2 (4000) := 'hdjikndbbhitasuihfnnkqyhiplwmneuyndnloidj';
       BEGIN
          l_password :=
             UTL_RAW.cast_to_raw (
                DBMS_OBFUSCATION_TOOLKIT.md5 (
                   input_string => p_password ||
                                   SUBSTR (l_salt, 10, 13)||
                                   LOWER (p_name)||
                                   SUBSTR (l_salt, 4, 10)));
          RETURN l_password;
       END;
    

    I want to decrypt the password to send to users when they forget it.  I wrote this function:

    FUNCTION decodeit (p_name IN VARCHAR2, p_password in VARCHAR2) RETURN VARCHAR2 IS
        l_salt       VARCHAR2 (4000) := 'hdjikndbbhitasuihfnnkqyhiplwmneuyndnloidj';
        BEGIN
          RETURN DBMS_OBFUSCATION_TOOLKIT.desdecrypt(input_string =>  p_password ||
                                                                      SUBSTR (l_salt, 10, 13)||
                                                                      LOWER (p_name)||
                                                                      SUBSTR (l_salt, 4, 10),
                                                     key_string   => l_salt) ;
        END;
    

    The problem is that the DBMS_OBFUSCATION_TOOLKIT.desdecrypt function needs a multiple of the input string of 8 bytes. And p_name and p_password are not of fixed length. Is there a function to adjust the length of a string to 8 multiple bytes?

    Best regards.

    They used to work - could be almost ten years (I think version 9 - not tested yet)

    As you can see, you can 'encode' the number of characters, padded in order to set the right length of the decrypted string


    create or replace FUNCTION ' CRYPTIN "(p_str in varchar2) return varchar2 as". "

    l_data VARCHAR2 (255);

    function pad_DES (p_string in varchar2) return varchar2 is

    -platelets p_string with pad_chr containing the number of characters padded (1 to 8)

    -make the string length a multiple of 8 as required by decipher

    pad_length pls_integer;

    pad_char char: = chr (0);

    pad_chars varchar2 (8);

    Start

    pad_length: = 8 - mod (length (p_string), 8);

    pad_chars: = chr (pad_length);

    Return concat (p_string, rpad (pad_chars, pad_length, pad_chars));

    end;

    Start

    l_data: = pad_DES (p_str);

    dbms_obfuscation_toolkit. Decrypt (input_string-online l_data, key_string => 'MagicKey' encrypted_string-online l_data);

    return UTL_RAW. CAST_TO_RAW (l_data);

    end;

    create or replace FUNCTION ' CRYPTOUT "(p_str in varchar2) return varchar2 as". "

    l_data VARCHAR2 (255);

    function unpad_DES (p_string in varchar2) return varchar2 is

    -Removes from p_string upholstered characters (1 to 8)

    pad_length pls_integer;

    Start

    pad_length: = length (p_string);

    pad_length: = pad_length - ascii (substr(p_string,pad_length,1));

    Return substr(p_string,1,pad_length);

    end;

    Start

    l_data: = p_str;

    dbms_obfuscation_toolkit. DESDecrypt (input_string-online l_data, key_string => 'MagicKey', decrypted_string-online l_data);

    Return unpad_DES (l_data);

    end;

    Concerning

    Etbin

  • is there any function in the osb to generate a unique number in proxy

    is there any function in the osb to generate a unique number in proxy

    FN - bea: uuid()

    The function fn - bea: uuid() returns a universal unique identifier. The function has the following signature:

    FN - bea: uuid() as XS: String

    You can use this function in the pipeline of proxy to generate a unique identifier. You can insert the unique identifier that is generated in an XML document in the form of element. You are unable to generate a unique identifier to the system variable. You can use this to edit a message payload.

    For example, suppose you want to generate a unique identifier to add it to a message for follow-up purposes. You can use this function to generate a unique identifier. The function returns a string that you can add it to the SOAP header.

  • SQL function for comparing 2 strings

    Hi all
    Is there a SQL function for comparing 2 strings?

    There is no function of pre defined in Sql for the string comparison. You can create according to your requirement.

    Concerning

  • (1) is there a function for all the object of the same size?

    (1) is there a function for all the object of the same size?

    Sorry, I thought you wanted to align the objects.

    We do not have the function to make items of the same size. You must change one by one. To change the .lks file may be more effective.

  • OBIEE 11 g there is function

    Hi all

    I'm on there is function in says it works fine

    But

    during the observation data, data are incompatible with the particular product category, why because two category s (A, B) have subcategory namesake (base)

    Cat CAT sup

    A  ------        Basic

    A - value added

    A - high

    B -------     Basic

    B Bass

    B way

    My report has five columns like CM-1 CM - 2 CM - 3, -4 CM, 5 CM,

    When I was a selection A cat and subcat is Basic, data as below...

    CM-1 CM-2 CM-3 CM - 4 CM-5

    Has basic has basicB basic B basichas basic       

    If subname of cat is different without offspring

    Please help me.


    Concerning

    RM

    You can create a key made up of Cat + SubCat (in a logical column concatenation is a quick victory) which will return the single SubCats and assign it as the logical level key:

    SubCat:

    A Basic

    A - value added

    A-high

    B Basic

    ...

  • Creating shadows of text - is there a function for this?

    I would like to create a shadow effect for my text in my headers.  Is there a function for this?

    In the current version of Muse you can only apply effects to pixelated fonts (fonts). If you need a shadow to the other fonts effect, you can do the following:

    1. create a paragraph style, name it as you need (for example shadow_paragraph) and assign to the text element you need to be affixed.

    2. go in the Page Properties > metadata > HTML customized to(Or insert HTML to a master page)

    3 insert a

  • Is there a function to get the name of the days?

    Hello
    I use 10.2.0.1.0 oracle
    Is there a function to obtain the day of the week?
    as I need to get Sunday, Monday, Tuesday, Saturday.
    I know that I can use union and select the name from a double.
    But I just want to know if there is another way.
    I need to show 7 days in a poplist in my form, it's the requirement

    Thank you
    SELECT TO_CHAR(TRUNC(SYSDATE ,'DAY')+Level-1,'DAY') DAYS FROM DUAL connect by Level<8
    SQL> /
    
    DAYS
    ---------
    SUNDAY
    MONDAY
    TUESDAY
    WEDNESDAY
    THURSDAY
    FRIDAY
    SATURDAY
    
  • There is function - number

    Hello

    I created there is function and it does not work. Help, please.

    Function AGO created layer MDB by following below steps.

    1 created new logical column
    2. function AGO

    There is (base". "Fact - fins - GL another committed Transaction. "" Transaction amount ", Core. «"' Date - Fiscal Calendar»» (Exercise 1).

    3. change exercise level
    4. drag the column in the presentation layer

    Report created with two parameters - exercise and exercise.

    Now, when I run report - I see the data for the current period (setting) but new column appears not all data.


    Any help is greatly appreciated. First time I am trying to create this feature.

    Thank you
    Poojak

    The important thing to check for the use of time series works in obiee as AGO and this day is to ensure that you have a time Dimension in the business model. Go to the properties of your heart. "' Date - Fiscal Calendar" Dimension and see if the temporal Dimension check box is checked.
    The next thing would be to check the chronological key. See if your lowest grain in the kernel. "' Date - Fiscal Calendar ' Sun is defined as chronological key.

    SAI.

  • is there a function to apply all in capital letters of a Word, sentence or paragraph?

    is there a function to apply all in capital letters of a Word, sentence or paragraph? If I have a written sentence and I want to do all of the capital of the letter, including at - it a setting or click solution for this? Thank you

    Commands > text > case [operation]

    Does that on a text field based, however, not a selection of text characters

  • Is there a way to disable the indicators of query in Oracle 9i / 10g / 11g?

    Hello

    Suppose there is an application of part 3, which will generate Oracle queries with notes. I will not be able to access the code. Is there a way to disable query indicators in the Oracle database?

    Thank you!

    Here is an example:

    SQL> select /*+ FULL(emp) */ * from emp where empno=10;
    
    Execution Plan
    ----------------------------------------------------------
    Plan hash value: 3956160932
    
    --------------------------------------------------------------------------
    | Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    --------------------------------------------------------------------------
    |   0 | SELECT STATEMENT  |      |     1 |    37 |     3   (0)| 00:00:01 |
    |*  1 |  TABLE ACCESS FULL| EMP  |     1 |    37 |     3   (0)| 00:00:01 |
    --------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       1 - filter("EMPNO"=10)
    
    SQL> alter session set "_optimizer_ignore_hints"=true;
    
    Session altered.
    
    SQL> select /*+ FULL(emp) */ * from emp where empno=10;
    
    Execution Plan
    ----------------------------------------------------------
    Plan hash value: 2949544139
    
    --------------------------------------------------------------------------------------
    | Id  | Operation                   | Name   | Rows  | Bytes | Cost (%CPU)| Time     |
    --------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT            |        |     1 |    37 |     1   (0)| 00:00:01 |
    |   1 |  TABLE ACCESS BY INDEX ROWID| EMP    |     1 |    37 |     1   (0)| 00:00:01 |
    |*  2 |   INDEX UNIQUE SCAN         | PK_EMP |     1 |       |     0   (0)| 00:00:01 |
    --------------------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       2 - access("EMPNO"=10)
    

    Be sure to test your application. Hidden settings should not be used in production without validation of Oracle support.

    Nicolas.

    tested on 11.1.0.6
    Edited by: N. Gasparotto, Sep 11, 2008 21:38

  • There is function to this day do not using aggregates

    I use the Group table and a detailed table
    I have the time hierarchy, which is the lowest level to date. I have for sale
    created for a year (CDA) comparison with function AGO. He
    works well.

    BUT, I want to accelerate, so I used aggregates. I created new
    table time grouped by MONTHS and table corresponding agg_SALES. I have
    established connections and the mapped fields. It works OK for
    normal queries, this means that my questions to use month level
    aggregates. BUT when I add YAGO measure or measures of the CDA in the query, it will
    then the table sales whose grain is date.

    How can I force BI Server to use the AGO with aggregates?

    I use OBIEE 10.1.3.4

    Thank you

    Ishaq

    (Question originally shot of ITtoolbox and published by Gorazd)

    Hello

    By defintion TODATE and function there is need the lowest granularaty of the function. Alternativily, you can write you own function on the database using your aggregates. and use the EVALUATE function in OBIEE to push to the interface.

    Concerning

    John
    http://obiee101.blogspot.com/

  • Is there a way to parse a string containing % (percentage symbols) using the function 'analysis of the chain?

    I am communication in series with a mirror device and the syntax of the input string contains this text: "% hr ="

    I was not able to find a way to say to the function that the percentage here is not a format specifier. Is it possible, or should I just try to use a different function?

    Thank you.

    Use %% in your format string for what he knows to use the percent literally.  So % RH = %f

    EDIT: Darin has one here in front of me.  It seems to be-% and % both work.

Maybe you are looking for