help in the creation of function.

Hi guys I am a newbie in pl/sql...
I want to create a function that bed alll the lines of a table containing hundreds of lines...
Break all the lines separated by space in several blocks or columns and check certain conditions on each block/columns...
For example:
I have a table that is to have a GBA and hundreds these lines...

12345 1234 12345 12345 12345 12345 12345 12345
.
.
.
.
Now, I want to create a function or a procedure that reads all the lines and check certain conditions on every word of each line...

for example: 1st condition:
1st, 2nd, 3rd, 4th and 5th Word is 12345 or not...
2nd, 3rd, 4th, 5th, 6th Word is 1234 or not
3rd word has a length = 5 or not, and various other conditions... but one thing is sure, I must check all the words in the line with respect to each condition...


thnx in advance...

Or...

SQL> ed
Wrote file afiedt.buf

  1  with testdata as (select '12345 12345 12345 12345 12345 12346 12347 12348' as txt from dual union all
  2                    select '54321 1234 1234 1234 1234 1234 32785' from dual union all
  3                    select '10101 10101 10101 10101 10101 10101 10101' from dual union all
  4                    select '123 123 123 123 123 123 123' from dual)
  5  --
  6  -- end of test data, use query below
  7  --
  8  select txt
  9        ,case when wrd1 = '12345' and wrd2 = '12345' and wrd3 = '12345' and wrd4 = '12345' and wrd5 = '12345' then
 10                'True'
 11         else 'False' end as cond1
 12        ,case when wrd2 = '1234' and wrd3 = '1234' and wrd4 = '1234' and wrd5 = '1234' and wrd6 = '1234' then
 13                'True'
 14         else 'False' end as cond2
 15        ,case when length(wrd3) = 5 then
 16                'True'
 17         else 'False' end as cond3
 18  from (
 19        select txt
 20              ,regexp_substr(txt,'[^ ]+',1,1) as wrd1
 21              ,regexp_substr(txt,'[^ ]+',1,2) as wrd2
 22              ,regexp_substr(txt,'[^ ]+',1,3) as wrd3
 23              ,regexp_substr(txt,'[^ ]+',1,4) as wrd4
 24              ,regexp_substr(txt,'[^ ]+',1,5) as wrd5
 25              ,regexp_substr(txt,'[^ ]+',1,6) as wrd6
 26        from testdata
 27*      )
SQL> /

TXT                                             COND1 COND2 COND3
----------------------------------------------- ----- ----- -----
12345 12345 12345 12345 12345 12346 12347 12348 True  False True
54321 1234 1234 1234 1234 1234 32785            False True  False
10101 10101 10101 10101 10101 10101 10101       False False True
123 123 123 123 123 123 123                     False False False

Tags: Database

Similar Questions

  • Requried helps the creation of function

    Hi all

    I need assistance to create feature my input parameters for this function will be 1 or 1,2 1,2,3

    my output should be

    If I pass 1 as an input parameter, it should return 1
    If I spend 1, 2 as input parameter it should return 1.2 in different lines
    Even if I switch 1,2,3 as an input parameter it should return 1,2,3 in different lines.

    Can someone help me please in the creation of this function.

    Thanks in advance.

    Published by: p78 on January 16, 2012 03:31

    Published by: p78 on January 16, 2012 03:31

    Hello

    It will be something like that. You must first type to return lines (use another number, for example data type if you must):

    CREATE OR REPLACE TYPE t_list AS TABLE OF VARCHAR2 (4000);
    /
    

    Then, the function will be a pipeline function:

    CREATE OR REPLACE FUNCTION in_list (p_list  IN  VARCHAR2)
      RETURN t_list PIPELINED
    AS
      l_text  VARCHAR2(32767) := p_list || ',';
      l_idx   NUMBER;
    BEGIN
      LOOP
        l_idx := INSTR(l_text, ',');
        EXIT WHEN NVL(l_idx, 0) = 0;
        PIPE ROW (TRIM(SUBSTR(l_text, 1, l_idx - 1)));
        l_text := SUBSTR(l_text, l_idx + 1);
      END LOOP;
    
      RETURN;
    END;
    /
    

    now, you can query (or whatever the needs):

    select * from table(in_list('aa','bb'));
    

    Herald tiomela
    http://htendam.WordPress.com

  • Help with the creation of the Datagrid column

    I am trying to get a better understanding of the way the Spark DataGrid works so that I can create and version extended for one of my projects. One of the things that really left me speechless is how the datagrid sets up the columns based on the dataprovider when no explicit column is defined. I was able to debug through the initialization of the datagrid to the point where the setter for dataprovider is called. At this point, my debug trace goes "down the rabbit hole" so to speak and when she returns, the columns are initialized but I can't figure out how. Could someone tell me please to the class or function that is actually responsible for creating the columns of the dataprovider if they are not defined explicitly?

    So, as you have discovered, the Grid method / generateColumns (private) is called if the list of columns is always set to null when the commitPropertes().   Subsequently becomes the columns property, as a consequence of the liaison, should update the list of columns as expected.

    Could create an example that illustrates the problem you meet?   I'd be happy to look at it.

    -Hans

  • Help in the creation of the schema Script in order to short-circuit

    Dear Sir
    As I have two similar patterns (with the same objects) and I need to create scripts for the two schemas for objects like (procedures, packages, functions, views, triggers) of these two diagrams (what I'm doing with the help of Toad (DBA > > generate the schema Script), now my problem is that the sequence of object in the scripts are different in the two scripts) , so is there a way I can get fixed a short sequence (probably in alphabetical order) .then my complementary process can be simplified



    Thanks and greetings
    Ashish Mishra

    If you don't want a specific product solutions, do not post in a specific forum of the product.

    I suggest that ask you in the forum SQL and PL/SQL.

  • Need help with the creation of a research or time slider bar

    Hello!

    I have three scenes in my fla and I want to create a time slider that shows the current framework of playing time and the total time of the image. Can someone help me on this.

    Thank you

    I made a few changes...

    Creates:
    txtFrameStatus
    TextField: html and multiline.

    mcBar
    A mc with a horizontal bar.

    VARs
    var movieFPS:Number = 12; Here set the FPS
    var porcent:Number;
    var currentFrame:Number;
    var totalFrames:Number;
    var totalSeconds:Number;
    var currentSeconds:Number;
    var textTime:String;

    function that presents information
    this.onEnterFrame = function (): Void {}
    currentFrame = _currentframe;
    totalFrames = _totalframes;
    us = Math.floor ((currentFrame / totalFrames) * 100);
    totalSeconds = Math.floor(totalFrames / 12);
    currentSeconds = Math.floor(currentFrame / 12);

    var cSeconds:Number = currentSeconds % 60; cSeconds = (cSeconds< 10)="">
    '0' + cSeconds: cSeconds;
    var cMinutes:Number = Math.floor(currentSeconds / 60); cMinutes =
    (cMinutes< 10)="" "0"="" +="" cminutes="" :="">

    var tSeconds:Number = totalSeconds % 60; (tSeconds = tSeconds< 10)="">
    '0' + tSeconds: tSeconds;
    var tMinutes:Number = Math.floor(totalSeconds / 60); tMinutes =
    (tMinutes< 10)="" "0"="" +="" tminutes="" :="">

    textTime = "Total images:" + totalFrames + "."
    ";
    textTime += "current Frame:" + currentFrame + "."
    ";
    textTime += "us:" + us + '%' + "."
    ";
    textTime += ' time Total: "+ tMinutes +": "+ tSeconds +". "
    ";
    textTime += ' current time: "+ cMinutes +": "+ cSeconds;"

    txtFrameStatus.htmlText = textTime;

    mcBar._xscale = us;

    if(porcent == 100) delete this.onEnterFrame;
    };

    --
    Kind regards
    Erick Souza
    www.ericksouza.com

  • Need help with the creation of SQL table

    Hi all

    I created a table, a month back. Now, I need to create another table in the same structure.
    Is there a way for dat I can get the script from the table I created earlier and use the same to create another.
    Or y at - it another way, so that we can create a table with the same structure of the existing table.

    Help, please.

    Kind regards
    Mohan

    Discover the function [DBMS_METADATA. GET_DDL | http://download.Oracle.com/docs/CD/B19306_01/AppDev.102/b14258/d_metada.htm#i1019414].

    Example:

    SQL> SET LONG 5000
    SQL> SELECT DBMS_METADATA.GET_DDL('TABLE','EMP','SCOTT') FROM DUAL;
    
    DBMS_METADATA.GET_DDL('TABLE','EMP','SCOTT')
    --------------------------------------------------------------------------------
    
      CREATE TABLE "SCOTT"."EMP"
       (    "EMPNO" NUMBER(4,0),
            "ENAME" VARCHAR2(10),
            "JOB" VARCHAR2(9),
            "MGR" NUMBER(4,0),
            "HIREDATE" DATE,
            "SAL" NUMBER(7,2),
            "COMM" NUMBER(7,2),
            "DEPTNO" NUMBER(2,0),
             CONSTRAINT "PK_EMP" PRIMARY KEY ("EMPNO")
      USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
      STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
      TABLESPACE "USERS"  ENABLE,
             CONSTRAINT "FK_DEPTNO" FOREIGN KEY ("DEPTNO")
              REFERENCES "SCOTT"."DEPT" ("DEPTNO") ENABLE
       ) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
      STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
      TABLESPACE "USERS"
    

    Published by: Centinul on January 11, 2010 08:01

  • New user needs help with the creation of an animation :)

    Hello

    IM fairly new to all Adobe Premiere Pro Im using CS6 and need help with it.

    I want to make a video and add a scene that looks like the beginning of this video Sarah the movie - YouTube , to be exact - the animation at the location where you type your user name and password, I can do that in Adobe Premiere Pro? I want to do exactly the same animation and no idea of how do

    Would appreciate any help!

    There are several ways to do so.

    One way would be to create a title with the name and title with the password.  Add the crop effect to each and the keyframe as necessary. Adjust the size and position as desired.

  • Help with the creation of responsive navigation in 2015 DW (was: Newbie Question 2015)

    OK, I was on it for about 3 days and at my wits end... I am creating a website using DW 2015 I'm new to bootstrap3 I need to create a sensitive nav, exactly like this one http://mediatemple.net also note how she acts when you shrink the browser instead of pushing down from the site it opens on it... I am an expert in maybe a 3d and graphics, we can help or even if you can direct me in the right direction.

    Continuing from there where we left in your other thread:

    Change your container of nav to as below:

  • Help with the creation of color sets in the Illustrator file

    I'm repeating a specific background image on every page of a calendar and want to change its colors on each page. There are 2 shades in the image using a total of four different colors. I am not at all skilled in the theory of color and I was wondering if someone can please tell me if there is an easy way to come with harmonious color combinations that I can apply to the original Illustrator file? My solution shortcut would be to convert color to grayscale and apply a color overlay, but the image will seem just flat when I do this. I prefer to set the gradients individually but do not know how to find the compatible colours.

    Here's a preview of the image, followed by a DropBox link to the Illustrator file.

    background.jpg

    https://DL.dropboxusercontent.com/u/52882455/background1.AI

    Thank you!

    Couple for you ideas:

    First of all, try to use the color wheel on color.adobe.com.  Select the middle color and add your hex code of the color.  The app will automatically show you similar colors.  See an example of here. You can also experiment with other rules of color in the color rule menu (just click on one of them).

    Second, take a look at themes created by others.  If you are generally looking for colors that work well with the yellow, you can browse the most popular themes and identify some that use yellow.

    I hope this helps.

  • Need help in the creation of triggers

    Hi friends

    I need to set a trigger of DB, I have not used concept of triggers previously this is the 1st time that I will use the concept of trigger please advise me

    the requirement is

    I need to set a trigger of DB for a 'xxx' table if all orders is deleted from the table 'xxx' means the triggers must fire and fill the data offline at the other "yyy" custom table... I created the custum "yyy" with a few 6-column table (eg: del_by, ord_no, created_date etc.) Please suggest me how I can get my task your help he's be highly appreciable

    Thanks in advance
    AT

    Sorry, I meant actually after HAVING DELETE (and I forgot FOR EACH ROW) - I edited the post above.

    : Old MAN's recording of your xxx table is deleted.
    : NEW is the registration of your table xxx which is inserted if it was an INSERT trigger.
    If you create a trigger for UPDATE, you will have both a: OLD and one: NEW record.

    The optional clause of SEO simply allows you to rename the OLD and NEW to some other names if you wish.

  • Problem with the help of the $s javascript function to fill a page element

    Hello Oracle APEX community,

    I work on a page dashboard of exploration down and have been a problem when I try to fill a Page of text (hidden or not) element using javascript built in function $s.
    The feature works very well when the data is a number such as dept_id (even if the field type is varchar type). However, trying to pass what is a text the process fails, unless a value is hardcoded as parameter to the function. So, for example, I have a table with constituents by State counties. I would like to fill out (filter) a table based on when you click a bar for a State without having to submit the page. I use dynamic actions and built in javascript function in the SQL code for the graph to achieve; But even once, it works fine when I use a field varchar as the FIPS code (FIPS for Texas is "48"), but when I try to fill the page element by using the abbreviation of the State "TX" (new varchar), it fails.

    Here is an example of code that works:
    SELECT 'javascript:$s("P1_DEPTNO",'||d.deptno||')' LINK,
    d.dname LABEL,
    sum(e.SAL) sal
    FROM emp e, dept d
    where e.deptno = d.deptno
    group by 'javascript:$s("P1_DEPTNO",'||d.deptno||')', d.dname 
    And here is an example of code that does not work:
    SELECT 'javascript:$s("P1_DEPTNO",'||d.loc||')' LINK,
    d.dname LABEL,
    sum(e.SAL) sal
    FROM emp e, dept d
    where e.deptno = d.deptno
    group by 'javascript:$s("P1_DEPTNO",'||d.loc||')', d.dname 
    However, when I hard code a value the script text works:
    SELECT 'javascript:$s("P1_DEPTNO","BOSTON")' LINK,
    d.dname LABEL,
    sum(e.SAL) sal
    FROM emp e, dept d
    where e.deptno = d.deptno
    group by 'javascript:$s("P1_DEPTNO","BOSTON")', d.dname
    ORDER BY d.dname 
    I encounter this problem on several versions of the APEX: (4.0.2.00.07 - local installation) and (4.1.0.00.28 - apex.oracle.com)

    Does anyone know of this problem and how to solve? I have looked for the parameters of the element of the page itself and can not understand.
    I rewrote my sql to use the fields of value of my tables instead, but I have a few objects on the page that will really depend on the data of base characters instead.

    Thank you
    Wayne

    In your javascript that you generate, surround your value with quotes and it will then should always work with the numbers and strings (your channels are probably interpreted as variable names and that they do not exist when running, so slip out).

    Example:

    SELECT 'javascript:$s("P1_DEPTNO","'||d.loc||'")' LINK,
    

    Published by: gti_matt on August 16, 2011 09:50

  • Dreamweaver can help in the creation of a referral of human age verification Page?

    My client, a Destributer of beer and all other Web sites that sell alcohol, even the little guys, have seen an increase in audits by the Federal Trade Commission (FTC) and need a gateway for users to put their age, if more than 18, to view the site. Visit the Sam Adams for example: http://www.samueladams.com.

    It seems that people choose one of the two methoods for this. Just a yes / no question about a referral page or a page where they actually put in their age. Whatever it is, it is created so that you can not access the site without verifying your age.

    Is there something in Dreamweaver that can help me meet these technical requirements?

    This is the site to date: http://www.atomic.cyndeeadkins.com/

    It's still a work in progress of course...

    As we are all aware, two methods are not completely foolproof.

    If you want to just Yes / No, you can simply make a landing page with 2 buttons - Yes and no. The Yes button linking to the main site and no button for Google.com or some other page custom indicating their access is not that they are minors.

    If you want a DOB field to validate the age, here's the script:

    MM010203040506070809101112 DD01020304050607080910111213141516171819202122232425262728293031 YYYY20122011201020092008200720062005200420032002200120001999199819971996199519941993199219911990198919881987198619851984198319821981198019791978197719761975197419731972197119701969196819671966196519641963196219611960195919581957195619551954195319521951195019491948194719461945194419431942194119401939193819371936193519341933193219311930192919281927192619251924192319221921192019191918191719161915191419131912191119101909190819071906190519041903190219011900
  • Need help with the creation of a brush

    Hi guys,.

    I wanted to ask for help in creating a brush (even a link to a tutorial will be goon enough ).

    I got this example:

    Sample.png

    I've created a brush him, and I'm trying to get this kind of result:

    Result.png

    but it is only done to duplicate it and gives me this result:

    Test.png

    Can someone help me please understand what I need to set so that the brush behaves like a continuous brush rather than reproduce them?

    Thank you very much

    Shlomit

    what you need to do, is make a brush that resembles the tip of a brush. Photoshop already has several, but you can make your own that is going to be the best.

    get a brush and a place a bit like what made you, but do not paint a paint stroke. make it kindof grungy look. make your brush, making sure to desaturate and all.

    EDIT:

    Oh, and if you make the filling similar to 10-20% of your race will be better

  • Need help in the creation of procedure

    Hi all

    Some body can you please help me in creating a procedure.
    I have a 'NAME' table and column LNAME, FNAME, EMPID
    now I have an EMPID_SEQ sequence.
    I have data like
    LNAME      FNAME      EMPID
    JOHN        SMITH
    JOHN        SMITH
    PETER      PARKER
    MIKE        JONES
    MIKE        JONES
    MIKE        JONES
    Now, I want to write a procedure in order to give a number (EMPID_SEQ. NEXTVAL) for the same name and surname as

    LNAME      FNAME      EMPID
    JOHN        SMITH       1
    JOHN        SMITH       1
    PETER      PARKER       2
    MIKE        JONES        3
    MIKE        JONES        3
    MIKE        JONES        3
    can someone help me please by writing this procedure.
    Thanks in advance.

    Hello:

    DECLARE
       CURSOR c
       IS
          SELECT DISTINCT lname,
                          fname
                     FROM names;
    BEGIN
       FOR i IN c
       LOOP
          UPDATE names
             SET empid = empid_seq.NEXTVAL
           WHERE lname = i.lname AND fname = i.fname;
       END LOOP;
    END;
    

    Saad,
    http://saadnayef.blogspot.com

  • I need help for the creation of rules - the very high values!

    Hello

    I have some troubleshooting by creating rules to HFM 11.1.1.3. I declarate a table where an account data are stored. There should be a stored digital data in another account of HFM (e.g. "EB_MITTEL"). The stored data are much higher than the value in the logfile ('write2File") showed. If I divide this value by 100000000000000 so good value.

    Example: The value in the log file: 16492,8691588785 (',' = the decimal delimiter)
    Value in the data grid: 164.928.691.588.785 ("'. ' separator = of thousands")

    Part of the rule file:

    Void

    Dim lMittelWert, lMaxWert, lMinWert

    lMittelWert = 0
    lMaxWert = 0
    lMinWert = 0
    a = 0
    For x = 1 to 13

    If arListe (x) <>0 then
    lMittelWert = lMittelWert + arListe (x)
    a = a + 1
    End if

    If lMaxWert < arListe (x) then
    lMaxWert = arListe (x)
    End If

    If x = 1 then
    lMinWert = arListe (x)
    End if

    Next

    lMinWert = lMaxWert

    For x = 1 to 13

    If lMinWert > arListe (x) and arListe (x) <>0 then
    lMinWert = arListe (x)
    End If
    write2file arListe (x)
    Next
    If <>0 then
    lMittelWert = lMittelWert / a
    End if
    KSM Exp ' a #EB_MITTEL.» ' C1 # "& C1Item &"="& lMittelWert
    KSM Exp ' a #EB_MIN. C1 # "& C1Item &"="& lMinWert
    KSM Exp ' a #EB_MAX. C1 # "& C1Item &"="& lMaxWert
    End Sub



    I hope someone can help me, thanks in advance. (and I'm so sorry for my bad English)

    Jürgen

    VB script using string to convert numbers in some languages require special attention during the handling of numbers. (French, German and other who use commas as the decimal separator).

    Internally, HFM VB Scripts use periods (.) as the decimal separator. One solution is to force the use of decimals and force the script engine to use decimal numbers by declaring the local to be English in the United States with:

    b = setLocale("en-us")

Maybe you are looking for