简体   繁体   中英

Extract values from IN parameter and store it in local variables in postgreSQL

I have :listDate:String IN parameter that I'm passing to my proc which contains the dynamic values separated by ,
This :listDate:String is passed to proc from Java front end and it contains the value selected by the user

There can be many combinations

Case 1 listDate can have
1. 30 Dec 2013 to 05 Jan 2014
so v_start_date is 30 Dec 2013 and
v_end_date is 05 Jan 2014

Case 2 listdate can have
30 Dec 2013 to 05 Jan 2014,
06 Jan 2014 to 12 Jan 2014
so v_start_date is 30 Dec 2013 and
v_end_date is 12 Jan 2014

Case 3 listDate can have
06 Jan 2014 to 12 Jan 2014,
13 Jan 2014 to 19 Jan 2014,
20 Jan 2014 to 26 Jan 2014

so v_start_date is 06 Jan 2014 and v_end_date is 26 Jan 2014

How can I extract the values as shown above into v_start_date and v_end_date ?

I was able to resolve it by using

select substring(listDate from '............$') as v_end_date,
substring(listDate from '^...............') as v_start_date

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM