简体   繁体   English

从IN参数中提取值并将其存储在PostgreSQL中的局部变量中

[英]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 , 我将:listDate:String IN参数传递给了proc,其中包含由,
This :listDate:String is passed to proc from Java front end and it contains the value selected by the user :listDate:String从Java前端传递到proc,它包含用户选择的值

There can be many combinations 可以有很多组合

Case 1 listDate can have 情况1 listDate可以有
1. 30 Dec 2013 to 05 Jan 2014 1. 2013年12月30日至2014年1月5日
so v_start_date is 30 Dec 2013 and 因此v_start_date是2013年12月30日
v_end_date is 05 Jan 2014 v_end_date是2014年1月5日

Case 2 listdate can have 案例2 listdate可以有
30 Dec 2013 to 05 Jan 2014, 2013年12月30日至2014年1月5日,
06 Jan 2014 to 12 Jan 2014 2014年1月6日至2014年1月12日
so v_start_date is 30 Dec 2013 and 因此v_start_date是2013年12月30日
v_end_date is 12 Jan 2014 v_end_date是2014年1月12日

Case 3 listDate can have 情况3 listDate可以有
06 Jan 2014 to 12 Jan 2014, 2014年1月6日至2014年1月12日,
13 Jan 2014 to 19 Jan 2014, 2014年1月13日至2014年1月19日,
20 Jan 2014 to 26 Jan 2014 2014年1月20日至2014年1月26日

so v_start_date is 06 Jan 2014 and v_end_date is 26 Jan 2014 因此v_start_date为2014 年1月 6日v_end_date为2014年1月26日

How can I extract the values as shown above into v_start_date and v_end_date ? 如何将上面显示的值提取到v_start_datev_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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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