Thread: Create type
If I can't use nested tables, how can I create a type that will be a kind of "dynamic list of structure". regards, Renaud THONNART
Richard Huxton wrote: > From: "Renaud Tthonnart" <thonnart@amwdb.u-strasbg.fr> > > > If I can't use nested tables, how can I create a > > type that will be a kind of "dynamic list of structure". > > Sorry Renaud, I'm not sure it's clear what you're trying to do. Could you > post an example of what you're trying to achieve to the list? That'd > probably help > > Ta > > - Richard Huxton Ok. First I wanted to use nested tables. But I think it is not possible. Then I decided to create a type that will made the same function, a type that will be like a C structure. This type would contain an integer and a string like (1,'aaa'). Then I would have made a list or an array with this type. Am I clear? Sorry if not, my English is poor. Thank you for your help. Renaud THONNART
On Tue, Feb 27, 2001 at 09:11:43AM +0100, Renaud Tthonnart wrote: > Richard Huxton wrote: > > > > Sorry Renaud, I'm not sure it's clear what you're trying to do. > > Could you post an example of what you're trying to achieve to the > > list? That'd probably help > > Ok. First I wanted to use nested tables. But I think it is not > possible. > > Then I decided to create a type that will made the same function, a > type that will be like a C structure. This type would contain an > integer and a string like (1,'aaa'). Then I would have made a list or > > an array with this type. Am I clear? Sorry if not, my English is > poor. I think the original question still stands. What are you trying do? Can't you map your "structure" to a regular table? A list of struct's containing one integer and one string sounds like a table containing one integer and one string (with the possible addition of an extra key field if the integer is not already an identifier). CREATE TABLE list_struct ( i integer NOT NULL, c varchar(255) NOT NULL CHECK (char_length(c) > 0), PRIMARY KEY (i, c) ); -- Eric G. Miller <egm2@jps.net>
From: "Renaud Tthonnart" <thonnart@amwdb.u-strasbg.fr> > If I can't use nested tables, how can I create a > type that will be a kind of "dynamic list of structure". > > regards, > Renaud THONNART > > Ok. First I wanted to use nested tables. But I think it is not possible. > Then I decided to create > a type that will made the same function, a type that will be like a C > structure. This type would contain > an integer and a string like (1,'aaa'). Then I would have made a list or an > array with this type. > Am I clear? Sorry if not, my English is poor. > > Thank you for your help. > Renaud THONNART Ah - you can define your own types using C and then should be able to have an array of them. Never done this myself, but the relevant information is in the Programmer's Guide - 13. Extending SQL: Types You will probably end up building supporting functions and operators for the type too. - Richard Huxton
"Eric G. Miller" wrote: > > Ok. First I wanted to use nested tables. But I think it is not > > possible. > > > > Then I decided to create a type that will made the same function, a > > type that will be like a C structure. This type would contain an > > integer and a string like (1,'aaa'). Then I would have made a list or > > > > an array with this type. Am I clear? Sorry if not, my English is > > poor. > > I think the original question still stands. What are you trying do? > Can't you map your "structure" to a regular table? A list of struct's > containing one integer and one string sounds like a table containing > one integer and one string (with the possible addition of an extra > key field if the integer is not already an identifier). > > CREATE TABLE list_struct ( > i integer NOT NULL, > c varchar(255) NOT NULL > CHECK (char_length(c) > 0), > PRIMARY KEY (i, c) > ); > > -- > Eric G. Miller <egm2@jps.net> Of course I can do that but I need one table of that kind for each row of 1000 tables that contain 10000 rows each. That's the reason why I would have like using nested table. Olk. I see that I want to do is not possible. I just want to say that it is a bit disapointing that PostgreSQL that is qualified OR/DBMS don't offer a way to create nested tables. I think that will be interresting to add it in future versions. Renaud THONNART
Richard Huxton wrote: > > Ok. First I wanted to use nested tables. But I think it is not possible. > > Then I decided to create > > a type that will made the same function, a type that will be like a C > > structure. This type would contain > > an integer and a string like (1,'aaa'). Then I would have made a list or > an > > array with this type. > > Am I clear? Sorry if not, my English is poor. > > > > Thank you for your help. > > Renaud THONNART > > Ah - you can define your own types using C and then should be able to have > an array of them. Never done this myself, but the relevant information is in > the Programmer's Guide - 13. Extending SQL: Types > > You will probably end up building supporting functions and operators for the > type too. > > - Richard Huxton Ok, thank you for your help Richard ! Renaud THONNART