Hello,

 

  Ok, I give up! Tried a lot of things in my code! But still get error on
index row size. So, I'm part of my code, if someone could help me! A valid
value for this type is: '(03-jan-2007 , 15-may-2010)'

 

typedef struct t_periodo

{

      DateADT           tvi;

      DateADT           tvf;

}     Periodo;

 

Datum

periodo_in(PG_FUNCTION_ARGS)

{

    char    *str = PG_GETARG_CSTRING(0);

    char    tvi_char[MAXDATEFIELDS];

    char    tvf_char[MAXDATEFIELDS];

    

    tvi_char = (char *) palloc(strlen(MAXDATEFIELDS));

    tvf_char = (char *) palloc(strlen(MAXDATEFIELDS));

    

    Periodo     *result;

    

    if (sscanf(str, " ( %s , %s )", tvi_char, tvf_char) != 2)

        ereport(ERROR,

            (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),

            errmsg("invalid input syntax for periodo: \"%s\"", str)));

            

    result->tvi = StringToDateADT(tvi_char);            

    result->tvi = StringToDateADT(tvf_char);

    

    result = (Periodo *) palloc(sizeof(Periodo));

      

    if (result->tvi > result->tvf)

        ereport(ERROR,

                (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),

                errmsg("Initial date (TVi) must be smaller than final date
(TVf)")));      

    

    PG_RETURN_POINTER(result);

}

 

 

  Please help me!

  Thanks in advance!

 

 

Reply via email to