<html><body><div style="color:#000; background-color:#fff; font-family:times new roman, new york, times, serif;font-size:12pt">I firstly try with rid to see if it's working. It gives me an error: <br><br>ERROR:  syntax error at or near "("<br>LINE 19: ...  FROM ' || quote_ident(public) || '.' quote_ident(cc_all ) ...<br>                                                                                               ^<br><br>See anything wrong
 here??<br><br><br>-----------------------------------------------------------------------<br>-- SplitTable<br>-- Split a table into a series of tables which names are composed of the <br>-- concatenation of a prefix and the value of a column.<br>--<br>-- sourcetablename   - Name of the table to split into multiple table<br>-- targettableschema - Name of the schema in which to create the new set<br>--                     of table<br>-- targettableprefix - Prefix of the set of table names to create.<br>-- suffixcolumnname  - Name of the column providing the suffix to each name.<br>-----------------------------------------------------------------------<br>CREATE OR REPLACE FUNCTION SplitTable(cc_all text, public text, cc_ text, rid text)<br>RETURNS int AS<br>$BODY$<br>DECLARE<br>    newtablename text;<br>   
 uniqueid RECORD;<br>BEGIN<br>    FOR uniqueid IN EXECUTE 'SELECT DISTINCT ' || quote_ident(rid) || '::text AS xyz123  FROM ' || quote_ident(public) || '.' quote_ident(cc_all) LOOP<br>        newtablename := cc_ || uniqueid.xyz123;<br>    EXECUTE 'CREATE TABLE ' || quote_ident(public) || '.' || quote_ident(newtablename) || ' AS SELECT * FROM ' || cc_all || ' WHERE ' || rid || '::text = ' || quote_literal(uniqueid.xyz123);<br>    END LOOP;<br>    RETURN 1;<br>END;<br>$BODY$<br>LANGUAGE plpgsql VOLATILE STRICT;<br><br><div><span><br></span></div><div><br></div>  <div style="font-family: times new roman, new york, times, serif; font-size: 12pt;"> <div style="font-family: times new roman, new york, times, serif; font-size: 12pt;"> <div dir="ltr"> <font face="Arial" size="2"> <hr size="1">  <b><span style="font-weight:bold;">From:</span></b> Pierre Racine
 <Pierre.Racine@sbf.ulaval.ca><br> <b><span style="font-weight: bold;">To:</span></b> Giannis Giakoumidakis <ggiakoumidakis@yahoo.com>; PostGIS Users Discussion <postgis-users@postgis.refractions.net> <br> <b><span style="font-weight: bold;">Sent:</span></b> Thursday, September 6, 2012 5:34 PM<br> <b><span style="font-weight: bold;">Subject:</span></b> RE: [postgis-users] upload a folder of raster files<br> </font> </div> <br>
Then I would suggest you use the SQL method: <br><br>-Create a new table creating a unique numeric id per filename (use generate_series()),<br><br>-Join this table to the raster table so you get one numeric id per filename and <br><br>-Use this field when you call SplitTable().<br><br>Pierre<br><br>> -----Original Message-----<br>> From: Giannis Giakoumidakis [mailto:<a ymailto="mailto:ggiakoumidakis@yahoo.com" href="mailto:ggiakoumidakis@yahoo.com">ggiakoumidakis@yahoo.com</a>]<br>> Sent: Thursday, September 06, 2012 10:28 AM<br>> To: Pierre Racine; PostGIS Users Discussion<br>> Subject: Re: [postgis-users] upload a folder of raster files<br>> <br>> Anyhow, it's not so important this for me.<br>> <br>> <br>> <br>> The best would be something that reminds the names of the files but it's ok if it<br>> is as simple as  cc001, cc002, cc003, ... etc  or  whatever it starts from cc that is<br>> common to
 all the filenames and then a row of numbers.<br>> <br>> <br>> <br>> <br>> <br>> ________________________________<br>> <br>> From: Pierre Racine <<a ymailto="mailto:Pierre.Racine@sbf.ulaval.ca" href="mailto:Pierre.Racine@sbf.ulaval.ca">Pierre.Racine@sbf.ulaval.ca</a>><br>> To: Giannis Giakoumidakis <<a ymailto="mailto:ggiakoumidakis@yahoo.com" href="mailto:ggiakoumidakis@yahoo.com">ggiakoumidakis@yahoo.com</a>>; PostGIS Users<br>> Discussion <<a ymailto="mailto:postgis-users@postgis.refractions.net" href="mailto:postgis-users@postgis.refractions.net">postgis-users@postgis.refractions.net</a>><br>> Sent: Thursday, September 6, 2012 5:03 PM<br>> Subject: RE: [postgis-users] upload a folder of raster files<br>> <br>> <br>> How do you want your tables names to be created from those filenames?<br>> <br>> > -----Original Message-----<br>> > From: Giannis Giakoumidakis [mailto:<a
 ymailto="mailto:ggiakoumidakis@yahoo.com" href="mailto:ggiakoumidakis@yahoo.com">ggiakoumidakis@yahoo.com</a>]<br>> > Sent: Thursday, September 06, 2012 5:19 AM<br>> > To: Pierre Racine; PostGIS Users Discussion<br>> > Subject: Re: [postgis-users] upload a folder of raster files<br>> ><br>> > Thank you very much!<br>> ><br>> > I need some extra help with the table name generator<br>> > (public.dem_x_!_rid:~4,2!), I can't understand how it works.<br>> ><br>> > Note that my filenames have that form: cc00h00m15s, cc00h00m30s,<br>> > cc00h00m45s, cc00h01m00s, ... , cc02h00m00s (hours, minutes, seconds that<br>> > rising every 15 seconds)<br>> ><br>> ><br>> ><br>> ><br>> ><br>> ><br>> > ________________________________<br>> ><br>> > From: Pierre Racine <<a ymailto="mailto:Pierre.Racine@sbf.ulaval.ca"
 href="mailto:Pierre.Racine@sbf.ulaval.ca">Pierre.Racine@sbf.ulaval.ca</a>><br>> > To: Giannis Giakoumidakis <<a ymailto="mailto:ggiakoumidakis@yahoo.com" href="mailto:ggiakoumidakis@yahoo.com">ggiakoumidakis@yahoo.com</a>>; PostGIS Users<br>> > Discussion <<a ymailto="mailto:postgis-users@postgis.refractions.net" href="mailto:postgis-users@postgis.refractions.net">postgis-users@postgis.refractions.net</a>><br>> > Sent: Wednesday, September 5, 2012 9:07 PM<br>> > Subject: RE: [postgis-users] upload a folder of raster files<br>> ><br>> ><br>> > Here is my answer to that:<br>> ><br>> > http://geospatialelucubrations.blogspot.ca/2012/09/loading-many-rasters-<br>> into-<br>> > separate.html<br>> ><br>> > Pierre<br>> ><br>> > > -----Original Message-----<br>> > > From: <a ymailto="mailto:postgis-users-bounces@postgis.refractions.net"
 href="mailto:postgis-users-bounces@postgis.refractions.net">postgis-users-bounces@postgis.refractions.net</a> [mailto:postgis-users-<br>> > > <a ymailto="mailto:bounces@postgis.refractions.net" href="mailto:bounces@postgis.refractions.net">bounces@postgis.refractions.net</a>] On Behalf Of Giannis Giakoumidakis<br>> > > Sent: Monday, September 03, 2012 6:12 AM<br>> > > To: PostGIS Users Discussion<br>> > > Subject: [postgis-users] upload a folder of raster files<br>> > ><br>> > > I want to upload to a db a big number of raster files, pe 500, inside a folder,<br>> > > named in a row (file_1 to file_500), each one to a different table. Any ideas?<br>> A<br>> > > loop or something of the basic: raster2pgsql -s 4236 -I -C -M file_1.tif -F -t<br>> > > public.demelevation | psql -d gisdb<br>> > ><br>> > > Note that using wildcard (*.tif) doesn't help, I tried
 but it uploads all files in<br>> one<br>> > > table as different rows.<br>> > ><br>> > > My sql knowledge is bad, so any help would be precious. Thanks.<br>> ><br>> ><br>> ><br>> <br>> <br>> <br><br><br><br> </div> </div>  </div></body></html>