Re: postgres function

From: Ramesh T <rameshparnanditech(at)gmail(dot)com>
To: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: postgres function
Date: 2015-10-15 19:15:35
Message-ID: CAK8Zd=sjgb_GrNa4xFY0AaFt3_O=65AN-4sm8YvHU4DoXZGYmg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

yes David gave correct solution

but , the value I'm using and it's column in the table sometimes value
may be '123-987-123' or '123-987-123-13-87'

if pass like below must return else condiion 0,

select case when select split_part('123-987-123','-',4) >0
then 1 else 0 end
it's return error like integer need...

On Thu, Oct 15, 2015 at 8:50 PM, David G. Johnston <
david(dot)g(dot)johnston(at)gmail(dot)com> wrote:

> On Thu, Oct 15, 2015 at 10:05 AM, Ramesh T <rameshparnanditech(at)gmail(dot)com>
> wrote:
>
>> '123-987-123' it is not fixed some times it may be '1233-9873-123-098'
>> as you said it's fixed,
>>
>> changes the values in middle of the -
>>
>> sometimes times i need 1233 and 098 or 9873,first position i'll find
>> direct for second variable we don't know where it's end with -
>>
>> i.e ,
>> i need to find second postition of the variable between the '-'
>> ​​
>>
>
> ​While I and others are likely inclined to provide you a working solution
> to do so you need to state your data and requirement more clearly.​ Given
> the apparent language dynamic I'd suggest supplying 5-10 example data
> values along with their expected result.
>
> ​Otherwise, regular expressions almost certainly will let you solve your
> problem (though, like Joe Conway indicated, split_​part may be possible)
> once you learn how to construct them. regexp_matches(...) is the access
> point to using them.
>
> David J.
>
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message David G. Johnston 2015-10-15 19:20:14 Re: postgres function
Previous Message anj patnaik 2015-10-15 18:40:55 Re: question