Thread: Create Type Problem

Create Type Problem

From
vinay_15082000@hotmail.com (Vinay Jain)
Date:
Hi
   I am newbie so this problem may be too simple to be asked.please help me if
any new thing to be added in following:

I want to use user defined data type in User_Type(n) way....

I created data type IndChar The c functions are:
/* Definaton of Data Type) */

typedef struct IndChar
{
    int32 len;
    char c_in_str[1];
}IndChar;

then i defined input & output functions.

Input: Datum indcharin(PG_FUNCTION_ARGS);
Output: Datum indcharout(PG_FUNCTION_ARGS);

then i created a function of the same name(i.e. IndChar) as
Datum indchar(PG_FUNCTION_ARGS);//for applying indchar(n) form i.e.fixed length
and i created it using:

create function indchar(IndChar, integer) returns IndChar
language C as 'Path for indchar.so file'
immutable strict;

after these i created data type using:
create type indchar
(input = indcharin,
output = indcharout,
internallength = variable,
storage = extended);

the type is created...

when i use it in Creating Table:

create table temp
(name IndChar(20));

it gives error at character '( '.....
please tell me why it is giving such error...
if some steps needed to alter or add tell me...
thanx in advance
Vinay jain

Re: Create Type Problem

From
Stephan Szabo
Date:
On Thu, 1 Apr 2004, Vinay Jain wrote:

>    I am newbie so this problem may be too simple to be asked.please help me if
> any new thing to be added in following:
>
> I want to use user defined data type in User_Type(n) way....

AFAIK, you cannot currently make user defined types that
take (n) fashion arguments like varchar or numeric.

Re: Create Type Problem

From
"Vinay Jain"
Date:
hi stephan
thank you for giving this information..
actually i  have found problem in order by clause
when i insert data in local language of india (i.e. Hindi) it sorts in order
of length which is incorrect
so i ve written routine & trying it for some new data type
now problem is this if i can not specify length then how much length it can
support...
the second thing though it is working on my sample data but order by
clause's output is varying
some time's it comes in right order and sometimes it's order is cahnged on
same data
i have defined < operator and according to code which i have tested as stand
alone is working fine
is there any need to change locale setting for user defined data type
thanks in advance
regards
vinay


>From: Stephan Szabo <sszabo@megazone.bigpanda.com>
>To: Vinay Jain <vinay_15082000@hotmail.com>
>CC: pgsql-general@postgresql.org
>Subject: Re: [GENERAL] Create Type Problem
>Date: Tue, 6 Apr 2004 10:32:34 -0700 (PDT)
>
>
>On Thu, 1 Apr 2004, Vinay Jain wrote:
>
> >    I am newbie so this problem may be too simple to be asked.please help
>me if
> > any new thing to be added in following:
> >
> > I want to use user defined data type in User_Type(n) way....
>
>AFAIK, you cannot currently make user defined types that
>take (n) fashion arguments like varchar or numeric.

_________________________________________________________________
Old pals, ex-flames, great times. Catch up with the past! Sign up now!
http://www.batchmates.com/msn.asp