Pl Sql Tips

August 24th, 2010 | Posted in Blog, PL SQL pipeline function | No Comments



1- How to split one string using a separator character ?
=> Solution : tested on my Oracle 10G R2 Database

TEST> create or replace type tabchar as table of varchar2(4000);
2 /

Type created.

TEST> create or replace function splittotabchar
2 (pInput IN VARCHAR2,pSeparator IN char := ‘_’) return tabchar
3 pipelined
4 is
5 vPosSep NUMBER;
6 vTemp VARCHAR2(4000);
7 begin
8
9 vTemp := pInput;
10 vPosSep := instr(vTemp,pSeparator);
11
12 while (vPosSep != 0)
13 loop
14 pipe row (substr(vTemp,1,vPosSep-1));
15 vTemp := SUBSTR(vTemp,vPosSep+1);
16 vPosSep := instr(vTemp,pSeparator);
17 end loop;
18
19 pipe row(vTemp);
20 end;
21 /

Function created.

TEST> select * from table(splittotabchar(‘abc_def_ghI’));

COLUMN_VALUE
————————————————————————————————————————————————————————————
abc
def
ghI

TEST>

Scridb filter


No Comments to “Pl Sql Tips”

There are no comments yet, add one below.


Leave a Comment





Subscribe


Polls

which oracle topic interests you most?

View Results

Loading ... Loading ...


Oracle Class Tweets


Recent Posts


Recent Comments

  • Jaspreet: Brilliant explanation.
  • Yousuf: Very Nice… Just wanted to check you have done all patching at Node 1 only.. is there any thing need to...
  • Yousuf: Very Nice.. Thanks for sharing.. Once question.. You have executed all commands on Node 1 only.. Is there any...
  • Emir: Thanks… Great article
  • borse firmate: Thank you for another informative blog. The place else may just I am getting that kind of information...
  • leandro: why this parameter is systemwide? could you read from a asm instance from one failure group and from the...
  • Mohammad: paul, we create pfile from target database to source database and later we change database name, and...
  • Muhammad Ikram: Thanks Brother for sharing pearls of knowledge. May ALLAH reward you for this both here and...
  • rgrover: Thanks for the POST. I recently encounter similar issue. Your POST helped.
  • gopalredy: really its very use full to dbas
  • Vivian: This is awesome! Thank you so much!
  • henry zhong: CDB=DB, and PDB=SCHEMA but in a sub dictionary?
  • Dehbashee: Salam Brother, Thanx for sharing, however, i would be interested in chaging the password for the grid user...
  • wissem: No we don’t need that :) Just the scripts I posted above
  • Md. Tanweer: Thanks for posting the material. I really appreciate if you can send me, if you have tutorial for 11g...
  • christiaan: Thanks!! This has been bugging the hell out of me for so long.
  • Rajasekhar: Thank you
  • Samarjit Panigrahy: Very Nice and Simple Demo… Cool :)
  • cq: Any reason not to use auto patch for both CRS and RAC homes with one command? Or use opatch auto for RAC home as...
  • Hitesh: Hi, Can we use this RACcheck tool on oracle SE version ? Thanks