pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Needs Function
5+ messages / 4 participants
[nested] [flat]

* Needs Function
@ 2007-05-03 04:38 Penchalaiah P. <penchalaiahp@infics.com>
  0 siblings, 0 replies; 5+ messages in thread

From: Penchalaiah P. @ 2007-05-03 04:38 UTC (permalink / raw)
  To: pgsql-sql


 

PLEASE GO TO FOLLOWING QUERY AND REVERT TO ME IF ANY QUERIES



SELECT * FROM TEMP;

DEPTNO   EMPNO

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

    10         B3091,B3092,B3093,B3085

    11         3651,6521

    12         H3062







  1  SELECT DEPTNO,SUBSTR(EMPNO,1,5) EMPNO FROM TEMP WHERE DEPTNO=10

  2  UNION

  3  SELECT DEPTNO,SUBSTR(EMPNO,7,5) EMPNO FROM TEMP WHERE DEPTNO=10

  4  UNION

  5   SELECT DEPTNO,SUBSTR(EMPNO,13,5) EMPNO FROM TEMP WHERE DEPTNO=10

  6  UNION

  7  SELECT DEPTNO,SUBSTR(EMPNO,19,5) EMPNO FROM TEMP WHERE DEPTNO=10

  8  UNION

  9  SELECT DEPTNO,SUBSTR(EMPNO,1,4) EMPNO FROM TEMP WHERE DEPTNO=11

 10  UNION

 11  SELECT DEPTNO,SUBSTR(EMPNO,6,4) EMPNO FROM TEMP WHERE DEPTNO=11

 12  UNION

 13* SELECT DEPTNO,EMPNO FROM TEMP WHERE DEPTNO=12

SQL> /



    DEPTNO EMPNO

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

        10 B3085

        10 B3091

        10 B3092

        10 B3093

        11 3651

        11 6521

        12 H3062



7 rows selected.



Information transmitted by this e-mail is proprietary to Infinite
Computer Solutions and / or its Customers and is intended for use only
by the individual or the entity to which it is addressed, and may
contain information that is privileged, confidential or exempt from
disclosure under applicable law. If you are not the intended recipient
or it appears that this mail has been forwarded to you without proper
authority, you are notified that any use or dissemination of this
information in any manner is strictly prohibited. In such cases, please
notify us immediately at info.in@infics.com and delete this email from
your records.

========================================================================
====================================================


Disclaimer:

This message and the information contained herein is proprietary and
confidential and subject to the Tech Mahindra policy statement, you may
review at http://www.techmahindra.com/Disclaimer.html externally and
http://tim.techmahindra.com/Disclaimer.html internally within Tech
Mahindra.

========================================================================
====================================================



Information transmitted by this e-mail is proprietary to Infinite Computer Solutions and / or its Customers and is intended for use only by the individual or the entity to which it is addressed, and may contain information that is privileged, confidential or exempt from disclosure under applicable law. If you are not the intended recipient or it appears that this mail has been forwarded to you without proper authority, you are notified that any use or dissemination of this information in any manner is strictly prohibited. In such cases, please notify us immediately at info.in@infics.com and delete this email from your records.

Attachments:

image001.jpg (image/jpeg, 2.7K) download view image
^ permalink raw reply [nested|flat] 5+ messages in thread

* Needs Function
@ 2007-05-03 04:38 Penchalaiah P. <penchalaiahp@infics.com>
  2007-05-03 07:17 ` Re: Needs Function Rodrigo De León <rdeleonp@gmail.com>
  2007-05-03 14:20 ` Re: Needs Function Bart Degryse <Bart.Degryse@indicator.be>
  0 siblings, 2 replies; 5+ messages in thread

From: Penchalaiah P. @ 2007-05-03 04:38 UTC (permalink / raw)
  To: pgsql-sql


 



I need a user defined function for the following purpose....

If I pass a string with comma ( , ) separated chars/values.... It should
be appear in next line...

Ex: select get_sep_str ('SK, rp, h, j, 6, 9, kl') from dual;

Output :

SK

rp

h

j

6

9

kl



(Or)



I have one table like this.....



Temp Table:



Deptno number(10)

Empno  varchar2(200);



Data in temp table:



Deptno                       Empno

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

10                                      B3091,B3092,B3093,B3085

11                                      3651,6521

12                                      H3062



Now, I want to display the data like this.....



Deptno                       Empno

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

10                   B3091

10                   B3092

10                   B3093

10                   B3094

11                   3651

11                   6521

12                   H3062

Now, how can I achieve this....





Information transmitted by this e-mail is proprietary to Infinite Computer Solutions and / or its Customers and is intended for use only by the individual or the entity to which it is addressed, and may contain information that is privileged, confidential or exempt from disclosure under applicable law. If you are not the intended recipient or it appears that this mail has been forwarded to you without proper authority, you are notified that any use or dissemination of this information in any manner is strictly prohibited. In such cases, please notify us immediately at info.in@infics.com and delete this email from your records.

Attachments:

image001.jpg (image/jpeg, 2.7K) download view image
^ permalink raw reply [nested|flat] 5+ messages in thread

* Re: Needs Function
  2007-05-03 04:38 Needs Function Penchalaiah P. <penchalaiahp@infics.com>
@ 2007-05-03 07:17 ` Rodrigo De León <rdeleonp@gmail.com>
  2007-05-03 14:14   ` Re: Needs Function Aaron Bono <postgresql@aranya.com>
  1 sibling, 1 reply; 5+ messages in thread

From: Rodrigo De León @ 2007-05-03 07:17 UTC (permalink / raw)
  To: pgsql-sql

On 5/2/07, Penchalaiah P. <penchalaiahp@infics.com> wrote:
> I need a user defined function for the following purpose….
>
> If I pass a string with comma ( , ) separated chars/values…. It should be appear in next line…
>
> Ex: select get_sep_str ('SK, rp, h, j, 6, 9, kl') from dual;
>
> Output :
>
> SK
>
> rp
>
> h
>
> j
>
> 6
>
> 9
>
> kl
>
>
>
> (Or)
>
>
>
> I have one table like this…..
>
>
>
> Temp Table:
>
>
>
> Deptno number(10)
>
> Empno  varchar2(200);
>
>
>
> Data in temp table:
>
>
>
> Deptno                       Empno
>
> -----------                      ------------
>
> 10                                      B3091,B3092,B3093,B3085
>
> 11                                      3651,6521
>
> 12                                      H3062
>
>
>
> Now, I want to display the data like this…..
>
>
>
> Deptno                       Empno
>
> ---------                        ---------
>
> 10                   B3091
>
> 10                   B3092
>
> 10                   B3093
>
> 10                   B3094
>
> 11                   3651
>
> 11                   6521
>
> 12                   H3062
>
> Now, how can I achieve this….

See:

http://archives.postgresql.org/pgsql-general/2005-12/msg00080.php



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: Needs Function
  2007-05-03 04:38 Needs Function Penchalaiah P. <penchalaiahp@infics.com>
  2007-05-03 07:17 ` Re: Needs Function Rodrigo De León <rdeleonp@gmail.com>
@ 2007-05-03 14:14   ` Aaron Bono <postgresql@aranya.com>
  0 siblings, 0 replies; 5+ messages in thread

From: Aaron Bono @ 2007-05-03 14:14 UTC (permalink / raw)
  To: Rodrigo De León <rdeleonp@gmail.com>; +Cc: pgsql-sql

On 5/3/07, Rodrigo De León <rdeleonp@gmail.com> wrote:
>
>
>
> See:
>
> http://archives.postgresql.org/pgsql-general/2005-12/msg00080.php
>
>
>
Man, where was this last week when I needed it.  I will have to keep this
for future reference.

Thanks!

-- 
==================================================================
   Aaron Bono
   Aranya Software Technologies, Inc.
   http://www.aranya.com
   http://codeelixir.com
==================================================================

^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: Needs Function
  2007-05-03 04:38 Needs Function Penchalaiah P. <penchalaiahp@infics.com>
@ 2007-05-03 14:20 ` Bart Degryse <Bart.Degryse@indicator.be>
  1 sibling, 0 replies; 5+ messages in thread

From: Bart Degryse @ 2007-05-03 14:20 UTC (permalink / raw)
  To: pgsql-sql

Well, actually it was there last week too :)

>>> "Aaron Bono" <postgresql@aranya.com> 2007-05-03 16:14 >>>
On 5/3/07, Rodrigo De León <rdeleonp@gmail.com> wrote:




See:

http://archives.postgresql.org/pgsql-general/2005-12/msg00080.php 




Man, where was this last week when I needed it.  I will have to keep this for future reference. 

Thanks!

-- 
==================================================================
   Aaron Bono
   Aranya Software Technologies, Inc.
   http://www.aranya.com  ( http://www.aranya.com/ )
   http://codeelixir.com ( http://codeelixir.com/ )
================================================================== 

^ permalink  raw  reply  [nested|flat] 5+ messages in thread


end of thread, other threads:[~2007-05-03 14:20 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2007-05-03 04:38 Needs Function Penchalaiah P. <penchalaiahp@infics.com>
2007-05-03 04:38 Needs Function Penchalaiah P. <penchalaiahp@infics.com>
2007-05-03 07:17 ` Rodrigo De León <rdeleonp@gmail.com>
2007-05-03 14:14   ` Aaron Bono <postgresql@aranya.com>
2007-05-03 14:20 ` Bart Degryse <Bart.Degryse@indicator.be>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox