开发平台pb6.5
现在编写oracle procedure,需要对字符串和日期型数据进行操作
故欲在oracle procedure中实现pb中的两个函数的功能
1、Pos ( string1, string2 {, start } )字符定位
Description 
Finds one string within another string.
Syntax 
Pos ( string1, string2 {, start } )
Argument Description
string1 The string in which you want to find string2
string2 The string you want to find in string1
start (optional) A long indicating where the search will begin in string1. The default is 1
Return value 
Long. Returns a long whose value is the starting position of the first occurrence of string2 in string1 after the position specified in start. If string2 is not found in string1 or if start is not within string1, Pos returns 0. If any argument's value is NULL, Pos returns NULL.2、RelativeDate ( date, n )自动变更时间
Description 
Obtains the date that occurs a specified number of days after or before another date.
Argument Description
date A value of type date
n An integer indicating a number of days
Return value 
Date. Returns the date that occurs n days after date if n is greater than 0. Returns the date that occurs n days before 
date if n is less than 0. If any argument's value is NULL, RelativeDate returns NULL.不知道oracle中是否有现成的function
或者oracle packages 中是否有提供相应功能的函数
请各位大虾帮忙帮忙,谢谢!

解决方案 »

  1.   

    17:15:32 jlanzpa817>select instr('women','o',1,1) from dual;INSTR('WOMEN','O',1,1)
    ----------------------
                         2已用时间:  00: 00: 00.10
    17:15:39 jlanzpa817>select instr('womo','o',1,2) from dual;INSTR('WOMO','O',1,2)
    ---------------------
                        4已用时间:  00: 00: 00.10
    17:15:51 jlanzpa817>select sysdate + 1 from dual;SYSDATE+1
    ----------
    14-8月 -02已用时间:  00: 00: 00.70
      

  2.   

    1、instr
    例子:
    SQL> select instr('asdf','s') from dual;INSTR('ASDF','S')
    -----------------
                    2
      

  3.   

    2、+
    例子:
    SQL> select to_date('2002-08-07','yyyy-mm-dd')+2 from dual;TO_DATE('2
    ----------
    09-8Ô -02SQL> select to_date('2002-08-07','yyyy-mm-dd')-2 from dual;TO_DATE('2
    ----------
    05-8Ô -02
      

  4.   

    加月份:
    SQL> select add_months(sysdate,2) from dual;ADD_MONTHS
    ----------
    13-10月-02