oracle 如何在oracle pl sql中添加空格
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/36078677/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to add blank space in oracle pl sql
提问by user2784400
SELECT lpad(nvl(substr(to_char(nvl(edt.leave,'''')),1,10),'''') || nvl(decode(leave_time,null,'''',
decode(edt.leave_time,''P'',''-PM'',''-AM'')),''''),10,'' '') LeaveType,
CASE WHEN substr(to_char(rh.holiday_date,''dd/MM/yyyy''),1,10) IS NOT NULL THEN
substr(to_char(rh.holiday_date,''dd/MM/yyyy''),1,10)
ELSE
'' ''
END HolidayDate, FROM TABLE
I have that part of code in my package, that is accessed by crystal reports... whenever I export the Data it doesnt give me the 10 spaces on my ELSE(enclosed by single quotes) when the record doesn't have a holiday_Date Where did I go wrong?
我的包中有那部分代码,可通过水晶报告访问......每当我导出数据时,当记录没有假期时,它不会在我的 ELSE 上给我 10 个空格(用单引号括起来)我做错了吗?
回答by Thomas G
回答by Siva
Don't manipulate everything in query if you are using crystal reports instead try below:
如果您使用的是水晶报表,请不要操作查询中的所有内容,而是尝试以下操作:
Change query like this... instead of case statement on date take date column in the query and manipulate in crystal reports.
像这样更改查询......而不是日期上的case语句在查询中获取日期列并在水晶报告中进行操作。
SELECT lpad(nvl(substr(to_char(nvl(edt.leave,'''')),1,10),'''') || nvl(decode(leave_time,null,'''',
decode(edt.leave_time,''P'',''-PM'',''-AM'')),''''),10,'' '') LeaveType,
rh.holiday_date FROM TABLE
Now in crystal reports take a formula @Date
and write below code:
现在在水晶报告中采用一个公式@Date
并编写以下代码:
if IsNull(Cdate(rh.holiday_date))
then " " //Adding 10 spaces
else Cdate(rh.holiday_date)
Now run and export the report
现在运行并导出报告