Hello All:

 

I am requesting your kind assistance with a simple text parsing
function.

The source code for the function is below. What is interesting is that
the 

path through the code that actually does something works.  The simple 

path through the code fails.

 

For example 

select getrfs_bbcode('CHF/USD 12/17/2008 CURNCY     ', null, null);
returns  "CHFUSD  CURNCY     "  this is correct.

 

select getrfs_bbcode('BPZ8 CURNCY              ',  NULL, NULL);
returns nothing.  I need to receive 'BPZ8 CURNCY              '  in this
case.

 

 

What am I missing?  

 

Many thanks for your assistance.

 

KD

 

 

CREATE OR REPLACE FUNCTION getrfs_bbcode( bbcode_in bpchar,
sectype_bbsuffix_in bpchar, sectypekey_in integer )

  RETURNS character AS

$BODY$

 

DECLARE

  rtn_bbcode char(25);

  tmp_bbcode  char(25);

  abbcode char(10)[3]; 

BEGIN

 

  tmp_bbcode  := upper( rtrim(bbcode_in ) ); 

  --  

  if tmp_bbcode like '%CURNCY'  then 

     if strpos( tmp_bbcode, '/' )  > 0  then 

        --  Is there / in the BB Code 

        abbcode :=  string_to_array(tmp_bbcode, ' ');

        rtn_bbcode := replace(abbcode[1], '/', '')  ||'  '|| abbcode[3];

     else 

        rtn_bbcode := tmp_bbcode;      -- simple pass though case does
not work?!?!

 

     end if;     

     

  end if;  

 

 return  rtn_bbcode ;

 

END

$BODY$

 

LANGUAGE 'plpgsql' VOLATILE;

 

Kevin Duffy

 

Reply via email to