On Fri, Feb 04, 2005 at 09:06:49AM -0700, Ignacio Colmenero wrote:
> 1. Is there anything in Postgre or third-party solutions similar to Oracle's
> SQL Loader, to upload a flat file into a table, according to certain rules?
> Any solutions you have tried before to solve this issue?
PostgreSQL (or Postgres, but not "Postgre") has a COPY command:
http://www.postgresql.org/docs/8.0/static/sql-copy.html
> 2. What are the nuts and bolts to run a SQL script from a batch file? I have
> browsed the documentation and I haven't seen anything clear.
When you say "batch file" are you referring to Windows batch files?
I can't help with Windows issues, but presumably the psql command
on that platform works the same way as on Unix, where you can use
"psql -f filename" or redirect the file to psql's standard input:
psql -f foo.sql
psql < foo.sql
If you're using a language that supports "here documents" then you
could do something like this:
psql <<END_OF_SQL
SELECT version();
SELECT current_timestamp;
END_OF_SQL
See the psql documentation for more information:
http://www.postgresql.org/docs/8.0/static/app-psql.html
> 3. Can I store more than one polygon in a polygon datatype field, like
> ((x1,y1),(x2,y2),.),((x10,y10),(x11,y11),.) or I have to install PostGIS?
If it fits your needs, you could define a column to be an array of
polygons:
CREATE TABLE foo (poly polygon[]);
INSERT INTO foo VALUES ('{"((1,1),(2,2),(3,3))","((4,4),(5,5),(6,6))"}');
SELECT * FROM foo;
poly
-----------------------------------------------
{"((1,1),(2,2),(3,3))","((4,4),(5,5),(6,6))"}
SELECT poly[1] FROM foo;
poly
---------------------
((1,1),(2,2),(3,3))
(1 row)
See the documentation for "Arrays" and "Array Functions and Operators":
http://www.postgresql.org/docs/8.0/static/arrays.html
http://www.postgresql.org/docs/8.0/static/functions-array.html
> 4. Can I query an object in another database, like in Oracle's dblink?
You can query other PostgreSQL databases with the contrib/dblink
module. You can also write set-returning functions in procedural
languages like PL/Perl, PL/Tcl, and PL/Python, so you can exploit
any database-querying capabilities those languages provide. David
Fetter's DBI-Link module does this, for example. I've written my
own functions to query other databases and wrapped them in views,
so a query like "SELECT * FROM viewname" might actually pull data
from Oracle, MySQL, MSSQL, etc.
--
Michael Fuhr
http://www.fuhr.org/~mfuhr/