<html><body><div style="color:#000; background-color:#fff; font-family:times new roman, new york, times, serif;font-size:12pt">Now worked, thanks! <br><br>I can't understand how this "substring(filename from 4 for 2)" works. <br><br><div>My filenames are like that: cc00h00m15s, cc00h32m45s etc, how I create a unique for these?</div><div><br><span></span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: times new roman,new york,times,serif; background-color: transparent; font-style: normal;"><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> Friday, September 7, 2012 5:37 PM<br> <b><span style="font-weight: bold;">Subject:</span></b> RE: [postgis-users] upload a folder of raster files<br> </font> </div> <br>
Ok. There was an error in the function. Fixed now. Copy again and execute. <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: Friday, September 07, 2012 10:28 AM<br>> To: Pierre Racine; PostGIS Users Discussion<br>> Subject: Re: [postgis-users] upload a folder of raster files<br>> <br>> So you mean I firstly create SplitTable as it is and then I change arguments in<br>> SELECT SplitTable(), am I right?<br>> <br>> All right but when I execute the query to create the function at the SQL Editor I<br>> get an error:     ERROR:  syntax error at or near "(", LINE 19: ...<br>> quote_ident(targettableschema) || '.' quote_ident(sourcetab...<br>> <br>> I don't change anything, only copying from the page.<br>> <br>> What is wrong?<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: Friday, September 7, 2012 4:20 PM<br>> Subject: RE: [postgis-users] upload a folder of raster files<br>> <br>> <br>> I never you had to change the SplitTable function, just change the argument you<br>> pass to it. and you have to create a new id per filename. rid is not unique per<br>> filename.<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: Friday, September 07, 2012 4:44 AM<br>> > To: Pierre Racine; PostGIS Users Discussion<br>> > Subject: Re: [postgis-users] upload a folder of raster files<br>> ><br>> > 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<br>> > 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<br>> > xyz123  FROM ' || quote_ident(public) || '.' quote_ident(cc_all) LOOP<br>> >        newtablename := cc_ || uniqueid.xyz123;<br>> >    EXECUTE 'CREATE TABLE ' || quote_ident(public) || '.' ||<br>> > quote_ident(newtablename) || ' AS SELECT * FROM ' || cc_all || ' WHERE ' ||<br>> > rid || '::text = ' ||
 quote_literal(uniqueid.xyz123);<br>> >    END LOOP;<br>> >    RETURN 1;<br>> > END;<br>> > $BODY$<br>> > LANGUAGE plpgsql VOLATILE STRICT;<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:34 PM<br>> > Subject: RE: [postgis-users] upload a folder of raster
 files<br>> ><br>> ><br>> > Then I would suggest you use the SQL method:<br>> ><br>> > -Create a new table creating a unique numeric id per filename (use<br>> > 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<br>> it<br>> > > is as simple as  cc001, cc002, cc003, ... etc  or  whatever it starts from cc that<br>> > 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<br>> > 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>> > > > <a href="http://geospatialelucubrations.blogspot.ca/2012/09/loading-many-" target="_blank">http://geospatialelucubrations.blogspot.ca/2012/09/loading-many-</a><br>> 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-<br>> > 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<br>> > folder,<br>> > > > > named in a row (file_1 to file_500), each one to a different table. Any<br>> > ideas?<br>> > > A<br>> > > > > loop or something of the basic: raster2pgsql -s 4236 -I -C -M file_1.tif -F -<br>>
 t<br>> > > > > public.demelevation | psql -d gisdb<br>> > > > ><br>> > > > > Note that using wildcard (*.tif) doesn't help, I tried but it uploads all files<br>> 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>> <br>> <br>> <br><br><br><br> </div> </div>  </div></body></html>