Query that returns several generic criteria using as and in

Hi there, try to do something like this:

Select * from tablename
Where columnname as 5% ' or as 8% ' or like 12% '

without the help OR... so in this big:

Select * from tablename
Where columnname like IN (5% ", 8%, 12%" ")

In MS Sql, I can do something like this:

SELECT * from tablename t
Where exists (select val FROM dbo.fn_String_To_Table (25, 05', '', 0))
ATA columname WHERE AS val + '%')

Where dbo.fn_String_To_Table converts the array of strings in a table.

Any suggestions?

Thank you very much.

Samir says:

where the comma-delimited string variable?

Use your imagination :):

select  *
  from  tablename t
  where regexp_like(t.column_name,'^(' || replace(starts_with_scv,',','|') || ')')
/ 

SY.

Tags: Database

Similar Questions

  • Query that returns number 1 - Add additional columns based on percentages

    I have a query that returns a large number.  The return value will always be a single field (a column, a line, a single value).

    I need to have also three other columns in the return of this request: one that returns a number that is 50% of the original number, one that returns a number that is 75% of the original number, and one that is double the original number.  How is that possible?  If anyone can point me to examples, it would be a great help.  I got the results mixed by searching, so I'm not sure good practices.

    Thank you for the input in advance.

    Hello

    Whenever you have a question, please post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and the accurate results you want from this data, so that people who want to help you can recreate the problem and test their ideas.

    Explain, using specific examples, how you get these results from these data.

    If you show what you want to do using commonly available tables, like those of the scott schema, then you don't need to display the sample data; just results and explanations.

    Always say what version of Oracle you are using (for example, 11.2.0.2.0).

    See the FAQ forum: Re: 2. How can I ask a question on the forums?

    I'm not sure that understand the question.

    If x is a number, then

    .50 * x is 50% of this number,

    .75 * x is 75% of that number, and

    2 * x is to double this figure.

    You can get them all in the same query, if you want to.  For example:

    SELECT ename

    sal

    .50 * sal AS p_50

    .75 * sal AS p_75

    2 * sal AS dbl

    FROM scott.emp;

    Output:

    ENAME SAL P_50 P_75 DBL

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

    SMITH, 800, 400, 600, 1600

    1600 800 1200 3200 ALLEN

    1250 625 WARD 937,5 2500

    JONES 2975 1487.5 2231,25 5950

    1250 625 MARTIN 937,5 2500

    2850 1425 BLAKE 2137,5 5700

    2450 1225 CLARK 1837,5 4900

    3000 1500 2250 6000 SCOTT

    KING 5000 2500 3750 10000

    1500 750 1125 3000 TURNER

    1100 550 825 2200 ADAMS

    JAMES 950 475 712,5 1900

    FORD 3000 1500 2250 6000

    1300 650 975 2600 MILLER

    Is that what you ask?

  • Need help to write a MySQL query that returns only the peer matching records

    Because I don't know how to explain it easily, I use the table below as an example.

    I want to create a MySQL query that returns only the records that match counterparts where 'col1' = 'ABC '.

    Notice the ' ABC / GHI' record does not have a Counter-match ' GHI / ABC' record. This record must not be returned because there is no Counter-Party correspondent. With this table, the ' ABC / GHI' record should be the one returned in the query.

    How can I create a query that will do it?


    ID | col1 | col2
    --------------------
    1. ABC | DEF
    2. DEF | ABC
    3. ABC | IGS
    4. DEF | IGS
    5. IGS | DEF


    * Please let me know if you have no idea of what I'm trying to explain.

    I wanted to just the results where col1 = ABC, but I already got the answer I needed on another forum. Thank you anyway.

    SELECT a.col1,
    a.col2
    FROM table_name AS a
    LEFT OUTER
    Table_name JOIN b
    ON b.col1 = a.col2
    AND a.col1 = b.col2
    WHERE b.col1 IS NOT NULL AND a.col1 = 'ABC '.

  • I need a query that returns the average amount of characters from text colum in MS SQL.

    I need a query that returns the average amount of characters from text colum in MS SQL.

    Could someone show me how?

    Sorting, I need of the

    DATALENGTH

    function

  • SQL QUERY THAT RETURNS THE PL/SQL

    Hello

    I'm putting in 4.2 below apex

    DECLARE

    date of frdate: =: P22_FROMDATE;

    date date: =: P22_TODATE;

    l_date1 varchar2 (11): = to_char(frdate,'dd-mon-yyyy');

    l_date2 varchar2 (11): = to_char(todate,'dd-mon-yyyy');

    v_sql varchar2 (32000);

    v_Name varchar2 (4000): = months_name (frdate, todate);

    char (1) of the v1: = q "[']";

    number of lbr1 (6): =: P22_FROMBRANCH;

    number of LBR2 (6): =: P22_TOBRANCH;

    number of M1 (6): = 11;

    Start

    v_sql: ='SELECT * FROM (SELECT LBRCODE, PRDACCTID, MN, AVGX FROM (SELECT LBRCODE, PRDACCTID, MN, SUM (BALL) BALL, COUNT (MN) DAYS, ROUND (SUM (BAL) count (MN), 2) AVGX ';))

    v_sql: = v_sql | "FROM (SELECT LBRCODE, PRDACCTID, TO_CHAR (BALDATE,'|)) CHR (39) | ' MM' | CHR (39) |') ' | ' ||'|| CHR (39) | » _'|| CHR (39) |' | ' || «TO_CHAR (BALDATE,'|)» CHR (39) | ' AAAA '. CHR (39) |') MN, BALL ';

    V_SQL: = V_SQL | "(SELECT Q2. LBRCODE, Q2. PRDACCTID, T1. BALDATE, T_OST_NEW (Q2. LBRCODE, Q2. PRDACCTID, T1. BALDATE) BALL ';

    V_SQL: = V_SQL | "FROM (select TO_DATE('||) Chr (39) | l_date1 | Chr (39) | «, » || CHR (39) | ' DD-MON-YYYY ' | CHR (39) |') baldate FROM DUAL Union all the ';

    V_SQL: = V_SQL |' select (TO_DATE('||) Chr (39) | l_date1 | Chr (39) | «, » || CHR (39) | ' DD-MON-YYYY ' | CHR (39) |') + level) double baldate ';

    V_SQL: = V_SQL |' connect by level < = (TO_DATE('||) Chr (39) | l_date2 | Chr (39) | «, » || CHR (39) | ' DD-MON-YYYY ' | CHR (39) |') -TO_DATE('||) Chr (39) | l_date1 | Chr (39) | «, » || CHR (39) | ' Dd-mon-yyyy ' | CHR (39) |')) ) Q1,';

    V_SQL: = V_SQL | "(SELECT LBRCODE,'|) ' (rpad (prdcd, 8,'|)) V1 ||'' || v1 |') || LTRIM (rpad('|| v1 ||) » x'|| V1 | «, 25, » || v1 | » 0' || v1||'),'|| v1 | » x'|| v1 |')) prdacctid OF D009021 WHERE the LBRCODE between ' | : P22_FROMBRANCH |' and ' | : P22_TOBRANCH | "AND moduleinfo =' | TO_NUMBER(:P22_SELECTLIST);

    V_SQL: = V_SQL |') ((Q2)) GROUP BY LBRCODE, PRDACCTID, MN))';

    V_SQL: = V_SQL | "PIVOT (MAX (AVGX) (MN) IN (';))

    V_SQL: = V_SQL | V_NAME;

    V_SQL: = V_SQL |')) ORDER OF LBRCODE, PRDACCTID ';

    RETURN V_SQL;

    END;

    I created all the elements of the required page

    I get the error message like missing expression

    to test, I created a function to return the query, it works very well know to return a query that gives me desired report

    am I missing something?

    Help, please

    HEMU wrote:

    Hello Sir

    Sorry to bother you again

    I tried to use «function that returns colon-delimited topics»

    and I got following error

    unable to determine query headings: ORA-06550: line 1, column 138: PLS-00103: Encountered the symbol ";" when expecting one of the following:  . ( ) , * % & = - + < / > at in is mod remainder not rem =>  <> or != or ~= >= <= <> and or like like2 like4 likec between || multiset member submultiset The symbol ")" was substituted for ";" to continue.
    
    failed to parse SQL query:
    

    can take you a look at page901 once again please and a function named months_namex

    is it feasible that I'm looking for?

    The immediate cause of this error is simply incorrect report headings function call syntax:

    return months_namex(to_date(:p901_fromdate,'dd-mon-yyyy'),to_date(:p901_todate,'dd-mon-yyyy')

    This should be:

    return months_namex(to_date(:p901_fromdate,'dd-mon-yyyy'),to_date(:p901_todate,'dd-mon-yyyy'));

    However there is no months_namex function defined in the workspace.

  • Help turn the query that returns single return system

    Hello, I have two tables, readings, and values. Values have a foreign key to the readings.
    create table readings 
    (
    id number primary key,
    point number,
    datereading date
    );
    
    create table reading_values
    (
    id number primary key,
    counter_nr number,
    point number,
    reading_id number,
    datereading date,
    CONSTRAINT fk_reading
    FOREIGN KEY (reading_id)
    REFERENCES readings (id)
    );
    The point and datereadings columns have the same value of related rows.
    insert into readings values (1, 1234, to_date('20100622 12:12', 'yyyymmdd HH24:MI'));
    insert into reading_values values (1, 0, 1234, 1, to_date('20100622 12:12', 'yyyymmdd HH24:MI')); --row1
    insert into reading_values values (2, 1, 1234, 1, to_date('20100622 12:12', 'yyyymmdd HH24:MI')); --row2
    
    insert into readings values (2, 1234, to_date('20100623 12:12', 'yyyymmdd HH24:MI'));
    insert into reading_values values (3, 0, 1234, 2, to_date('20100623 12:12', 'yyyymmdd HH24:MI')); --row3
    insert into reading_values values (4, 1, 1234, 2, to_date('20100623 12:12', 'yyyymmdd HH24:MI')); --row4
    
    insert into readings values (3, 1111, to_date('20100621 12:12', 'yyyymmdd HH24:MI'));
    insert into reading_values values (5, 0, 1111, 3, to_date('20100623 12:12', 'yyyymmdd HH24:MI')); --row5
    Now I have the procedure which the entry: p_point and p_date.
    select * from reading_values rv, 
    (select * from (select id, datereading
    from readings where datereading < p_date and point = p_point
     order by datereading desc) where rownum <= 1) t where rv.reading_id = t.id
    so I want the previous reading_values (in time based on p_date) for a certain point p_date. I hope this makes sense?
    Example:
    select * from reading_values rv, 
    (select * from (select id, datereading
    from readings where datereading < to_date('20100624 12:12', 'yyyymmdd HH24:MI') and point = 1234
     order by datereading desc) where rownum <= 1) t where rv.reading_id = t.id
    
    returns row 3 and 4
    Now, what I want to do, is replace p_point and p_date with two collections. For example: p_points = [1234, 1111] p_dates = [20100622 15:12, 20100624 12:12]
    Here, I want to have the previous reading_values by point = 1234 and datereading < 20100622 order 15:12 by datereading (where rownum < = 1).

    and also reading_values by point = 1111 and datereading < 20100624 order 12:12 by datereading (where rownum < = 1).

    This should return line1, line2 and row5...

    So far I came up with this. But I can't be sure that it is correct. And the performance seems to be horrible (cost 88, 13 recursive calls, 155 becomes uniform) for a query with 2 entry points and 2 dates compared to the original to just a single point query and the date of entry (cost 13, 1 recursive call and gets 14 coherent).
    Select rv.* from (SELECT r.id
          FROM    Readings r, 
          (select rownum rn1, t1.id from table1 t1 order by id) t1, -- input parameter1 (point collection)
          (select rownum rn2, t2.date_now from table1 t2 order by id) t2  -- input parameter 2 (date collection)
          WHERE  r.point = t1.id
              AND     r.datereading = (SELECT  max(r2.datereading)
              FROM   Readings r2
                WHERE   r2.point = t1.id
                AND     r2.datereading < t2.date_now AND rn1 = rn2)
        ) r, Reading_Values rv where r.id= rv.reading_id;
    code for creating table 1 that I used instead of collections of entry:
    create table table1
    (
     id number not null primary key,
     date_now date not null
    );
    insert into table1 values (1234, to_date('20100622 15:12', 'yyyymmdd HH24:MI'));
    insert into table1 values (1111, to_date('20100624 12:12', 'yyyymmdd HH24:MI'));
    Hope someone can help me on my way :) Please ask if something is unclear or strange! Thank you!

    Published by: KarlTrumstedt on 23-jun-2010 06:20

    Try this

    SELECT RV.ID, RV.COUNTER_NR, RV.POINT, RV.READING_ID, RV.DATEREADING
    FROM (
        SELECT (    SELECT LAST_VALUE(RE.ID) OVER
                         (PARTITION BY RE.POINT ORDER BY RE.DATEREADING)
                    FROM READINGS RE
                    WHERE RE.DATEREADING < T1.DATE_NOW AND RE.POINT = T1.ID
                ) ID,
                T1.ID POINT,
                T1.DATE_NOW
        FROM TABLE1 T1
    ) X
    JOIN READING_VALUES RV
    ON (X.ID = RV.READING_ID AND X.POINT = RV.POINT)
    ;
    
  • Query that returns only certain fields in Java

    Currently I use a filter that identifies certain keys, then get all the keys and get a unique value of each object. The rest of the object is important enough. I've seen references to the passage on the ability to do it, using CohQL, but I can't run Java.

    Basically, I want to do: "select the"Cache"box where key ="asdf '" I just want back the specific 'field' rather than the entire object. How can I do this?

    Thank you.

    Hi user13279246,

    You can do this by using the ReducerAggregator. Your code would look like:

    Filter filter = QueryHelper.createFilter(...);
    ValueExtractor extractor = new ReflectionExtractor("isReadOnly");
    Map mapResult = cache.aggregate(filter, new ReducerAggregator(extractor));
    

    The mapResult will be indexed by the actual cache keys, but the values will be extracted Boolean property.

    If you need to return a number of "columns", you would use the MultiExtractor instead. In this case, each value in the returned map would be a list of corresponding extracted properties.

    Kind regards
    Gene

    Published by: ggleyzer on February 15, 2011 16:41

  • Doubt with query that returns unnecessary reocrds

    Hello
    I use under query to retrieve security descending titles in a database:

    Select master sre1.security_id,
    sre2. Clone SECURITY_ID, sa1. Addr STREET_ADDR1
    Of
    SAM_REAL_ESTATE sre1, SAM_REAL_ESTATE sre2, sam_address sa1, sa2 sam_address
    where
    sre1. ADDRESS_ID = sa1. ADDRESS_ID and sre2. ADDRESS_ID = sa2. ADDRESS_ID
    and sre1.security_id < sre2. SECURITY_ID
    and trim (nvl (upper (sa1. STREET_ADDR1), 'Null')) = trim (nvl (upper (sa2. STREET_ADDR1), 'Null'))
    and in sre1.security_id (175459876,175460893,175460770,20530359,21943331,20306795)
    and in sre2.security_id (175459876,175460893,175460770,20530359,21943331,20306795)
    order by 1, 2;


    which returns results as below:

    MASTER CLONE ADDR
    20306795 20530359 Waverley
    20306795 21943331 Waverley
    * 20530359 21943331 Waverley *.
    175459876 175460770 temple
    175459876 175460893 temple
    * 175460770 temple 175460893 *.

    Now, I do not want the selected records in bold as the safety of clone is coming security master while only the less registration by different address should enter into main list and the rest of his security should come clone

    Please suggest

    Thank you
    Deepak

    NOT TESTED

    select min(master) master,clone,addr
      from (select sre1.security_id master,
                   sre2.SECURITY_ID clone,
                   sa1.STREET_ADDR1 addr
              from SAM_REAL_ESTATE sre1,
                   SAM_REAL_ESTATE sre2,
                   sam_address sa1,
                   sam_address sa2
             where sre1.ADDRESS_ID = sa1.ADDRESS_ID
               and sre2.ADDRESS_ID = sa2.ADDRESS_ID
               and sre1.security_id < sre2.SECURITY_ID
               and trim(nvl(upper(sa1.STREET_ADDR1),'Null')) = trim(nvl(upper(sa2.STREET_ADDR1),'Null'))
               and sre1.security_id in(175459876,175460893,175460770,20530359,21943331,20306795)
               and sre2.security_id in(175459876,175460893,175460770,20530359,21943331,20306795)
             order by sre2.SECURITY_ID,upper(sa1.STREET_ADDR1),sre1.security_id
           )
     group by clone,addr
     order by 1,2
    

    Concerning

    Etbin

    It is not a Top - N query

    Edited by: Etbin the 13.8.2009 12:00

  • How to perform an addition of column values in an insert query that would insert in the 3rd column, and the values how to insert into another table.

    I have two tables (2) RESULT TAB (1)

    CREATE TABLE TAB

    (

    NUMBER OF SNO

    A NUMBER,

    B THE NUMBER.

    NUMBER OF THE SUM

    );

    CREATE AN ARRAY OF RESULT

    (

    NUMBER OF SNO

    NUMBER OF THE SUM

    )

    my doubt is:

    (1) I want to insert a table TAB, my question is how to insert a column to the SUM using the column A AND B... Here im adding two values of the column and store result in the AMOUNT column.

    SNO   A  SUM           

    1 100 150 250

    2 300 100 400

    I want to like this, it is possible with single insert query?


    (2) at the time of the insertion TAB of values that SNO, and the values of table TAB $ insert in the table of RESULTS... is it possible these two inserts at the same time?

    in fact, im using another this table.fro TAB and easy to understand I write like that, please solve this problem

    First, you post in the wrong forum as this one is only for Oracle's SQL developer tool. So you might ask your question in the general forum of SQL.

    Second, you might solve your problems with bind variable:

    Insert tab

    (sno, a, b, sum)

    values

    (: SNO,: A: B: A + B :))

    You should not use sum as column name because it is a reserved word.

    More you cannot insert into two different tables with a single SQL, but you can use PL/SQL to do this:

    Start

    insert into tab values (: SNO,: A: B: A + B :);)

    insert into result values (: SNO,: A + B :);)

    end;

    If you meet sno from a sequence, you could do something like this:

    Start

    insert into values tab (seq_sno.nextval,:,: B,: A +: B) return sno in: SNO.

    insert into result values (: SNO,: A + B :);)

    end;

    Hope that helps,

    dhalek

  • When I use the private browsing, I get redirected to the Mystart page in Incredimail that I don't want that I would prefer to use Bing, and I was wondering how I could change the Mystart to Bing

    Whenever I use private browsing I use Incredimail mystart and I prefer to use that Bing.i cannot be found anywhere in Incredimail or Firefox where I can change this.

    Is everytime I use the private browsing

    You are welcome. I'm glad that everything is fine now.

  • Problems to return several rows with setting SLIDER and SO, to OTHER DBMS_OUPUT

    Hi people

    I use 11g Express Edition 11.2.0.2.0.

    I'm trying to return the name of a student, all of their exams, grade, grading and if it is a pass or fail.

    In the code I 'fiddled', if the student has failed it works. However, if the student has spent just returns 'result = Pass' and cannot return their name, rank and tests, pass mark.

    Second question (and please let me know if I need this post in a separate thread) is if a student has completed multiple tests, it returns only one.

    Thanks for any advice you can give me.

    SET SERVEROUTPUT ON
    DECLARE 
      CURSOR c_pass_fail_cursor 
        (p_studentid number) IS
        SELECT students.firstname,
          test_history.score,
          test_id.test_name,
          test_id.passing_grade
        FROM students
        INNER JOIN test_history
          ON students.STUDENT_ID = test_history.student_id
        INNER JOIN test_id
          ON test_id.test_id = test_history.test_id
        WHERE students.student_id = p_studentid
        AND test_history.SCORE < test_id.passing_grade;
        
      v_name students.firstname%type;
      v_score test_history.SCORE%type;
      v_test test_id.test_name%type;
      v_passing test_id.passing_grade%type;
      v_result varchar2(4);  
        
    BEGIN
    
    
      OPEN c_pass_fail_cursor (1);
      LOOP
        FETCH c_pass_fail_cursor INTO v_name, v_score, v_test, v_passing;
      EXIT WHEN c_pass_fail_cursor%notfound;
      END LOOP;
      CLOSE c_pass_fail_cursor;
      
      IF v_score < v_passing then
        v_result := 'Fail';
        DBMS_OUTPUT.PUT_LINE (v_name || ' ' || v_score || ' ' || v_test || ' ' || v_passing || ' ' || 'Result = ' || v_result);  
      ELSE
        v_result := 'Pass';
        DBMS_OUTPUT.PUT_LINE (v_name || ' ' || v_score || ' ' || v_test || ' ' || v_passing || ' ' || 'Result = ' || v_result);
    
    
      END IF;
      
    END;
    /
    

    Hello d670...

    I would try this code:

    DECLARE

    p_studentid NUMBER;

    v_result VARCHAR2 (20);

    BEGIN

    p_studentid: = 1;

    FOR rec_result IN (SELECT students.firstname

    test_history.score

    test_id.test_name

    test_id.passing_grade

    Students

    JOIN test_history

    ON students. STUDENT_ID = test_history.student_id

    JOIN test_id

    ON test_id.test_id = test_history.test_id

    WHERE students.student_id = p_studentid

    AND test_history. NOTE < test_id.passing_grade  ="" --=""> this line needs to be removed!

    )

    LOOP

    IF rec_result.score<>

    THEN v_result: = "Fail";

    ANOTHER v_result: = "Pass";

    END IF;

    DBMS_OUTPUT. Put_line (rec_result.firstname |) ' ' || To_char (rec_result.score) | ' ' || rec_result.test_name | ' ' || To_char (rec_result.passing_grade) | ' ' || "Result =" | v_result);

    END LOOP;

    END;

    /

    I hope it helps.

    Best regards, David

  • Network connections sharing ghost that I can't remove using vista and xp

    I just have this problem above. Old shared connections to the file systems on the laptop running xp that will not disappear. They also appear on another computer running xp on the same network but then xp enabled me to remove vista does not work. I've tried everything I can think of, but nothing works.

    Thank you for all that but...

    I was up at 02:00 and discovered that it was my fault all the time. No surprise there then.
    I had references to the readers that no longer exist that I forgot. Vista is not able to mark as not being more necessary, but allow recreation something with the same name and not necessarily the same content. The procedure to stop file sharing and then erases the link with the network of vista system request.
    I tried parts of your suggestions, but the references were external devices, I really expect Vista to hang on them in any case, they might still have been valid. I think there should also be a way to the administrator of killing existing or unwanted links to network locations.
    Thank you for your time.
    Peter
  • Looping on a method that returns a query

    Hello

    I have a method that returns a query, I convey in this method, an identification number, the query uses in where clause. Now I have another query that returns a list of identification numbers that I have to loop through the appellant the first method and passing in the ID number, for example

    methodA

    Browse the methodA results
    Call methodB passing methodA.ID
    results of methodB
    close the loop

    now, the problem I have is that methodB returns a query and I want to be able to return the results of methodB as a unique query structure. I don't know how many times I will do a loop through the results of methodA, maybe twice, he could by ten times. Thus, the results of calling methodB could be very large.
    How can I add methodB results in a single query structure?

    I finally had to create a monster query with joins in about three tables, but it works.

  • Selection of a function that returns a sys refcursor or alternative

    I have a query that returns a result set of three columns, namely the SSN, the PAID_YEAR and the PAID_TOTAL. This query, I can:

    1. Create a view and then question him.
    2. Create a function result set and return

    If I go the first way, that a simple request like this takes more than 20 seconds:

    SELECT PAID_YEAR,PAID_TOTAL FROM VIEW_1 WHERE SSN=12345678912882;

    I know it's because when I query a view engine first brings all the rows in the view and then filters the lines for the criteria provided.

    If I go the second way I can send only a parameter and make the engine look for only the rows that match the condition and the Recordset. But I don't know how then SELECT this result set returned. I took a look at the tables in pipeline, but do not understand how to their advantage. So my final question is if it is somehow possible to select from the result set returned by a function like this:

    SELECT * FROM FUNCTION_1(12132323232).

    If Yes, then how, if not, what would be another way?

    I know it's because when I query a view engine first brings all the rows in the view and then filters the lines for the criteria provided.

    No - you don't "know that" because it is not true. Just check out the plan of the command explain to yourself. Oracle can always use appropriate indexes so that only the needed rows are returned.

    So my final question is if it is somehow possible to select from the result set returned by a function like this:

    SELECT * FROM FUNCTION_1(12132323232).
    

    No - you can't do it like that. You must use the TABLE function to process the result of the function defined in a table:

    'SELECT * FROM TABLE(FUNCTION_1(12132323232)).

    -type to match record emp
    create or replace type emp_scalar_type as an object
    (EMPNO NUMBER 4,
    ENAME VARCHAR2 (10),
    USE VARCHAR2 (9).
    MGR NUMBER 4,
    HIREDATE DATE,
    NUMBER OF SAL (7, 2)
    NUMBER OF COMM (7, 2)
    DEPTNO NUMBER (2)
    )
    /

    -records of the emp table
    create or replace type emp_table_type to table of emp_scalar_type
    /

    -function of pipelined

    create or replace function get_emp (p_deptno number)
    return emp_table_type
    PIPELINED
    as
    TYPE EmpCurTyp IS REF CURSOR RETURN emp % ROWTYPE;
    emp_cv EmpCurTyp;
    l_rec emp % rowtype;
    Start
    Open emp_cv SELECT * from emp where deptno = p_deptno;
    loop
    extract the emp_cv in l_rec;
    When the output (emp_cv % notfound);
    line of conduct (emp_scalar_type (l_rec.empno, LOWER (l_rec.ename),
    l_rec.job, l_rec.mgr, l_rec.hiredate, l_rec.sal, l_rec.comm, l_rec.deptno));
    end loop;
    return;
    end;
    /
     
    Select * from table (get_emp (20))

  • Query to return then 7 dates

    Hello

    is it possible to return the next 7 dates just by using a query, for example, I need a query that returns:

    Select (I don't know who put here) double

    Date
    2012-10-05
    2012-10-06
    2012-10-07
    2012-10-08
    2012-10-09
    2012-10-10
    2012 10-11

    If possible, I would like to know if there is a way to pass a date and according to her, the query returns the next 7 dates based on the date... for example:

    Select (I don't know who put here) of the double if date > '' 2012-10-15

    Date
    2012 10-16
    2012 10-17
    2012 10-18
    2012 10-19
    2012 10-20
    2012 10-21
    2012 10-22

    I really appreciate any help
    Thank you
    SQL> select trunc(sysdate) + level - 1 from dual
      2  connect by level <= 7;
    
    TRUNC(SYS
    ---------
    05-OCT-12
    06-OCT-12
    07-OCT-12
    08-OCT-12
    09-OCT-12
    10-OCT-12
    11-OCT-12
    
    7 rows selected.
    
    SQL> select date '2012-10-15' + level - 1 from dual
      2  connect by level <= 7;
    
    DATE'2012
    ---------
    15-OCT-12
    16-OCT-12
    17-OCT-12
    18-OCT-12
    19-OCT-12
    20-OCT-12
    21-OCT-12
    
    7 rows selected.
    

Maybe you are looking for