Re: [GENERAL] Oracle and Postgresql

2008-09-03 Thread SCassidy
I don't know if Oracle changed recently, but the last few times I used it, it was incredibly annoying having to put everything in a subquery to get a LIMIT-type operation to work AFTER the sort, so that you could use their ROWNUM. For example, to get the first 50 rows of a SELECT result.

Re: [GENERAL] PostgreSQL arrays and DBD

2008-08-14 Thread SCassidy
[EMAIL PROTECTED] wrote on 08/14/2008 01:21:26 AM: Hello. I create a table: CREATE TABLE groups ( group_id serial PRIMARY KEY, name varchar(64) UNIQUE NOT NULL, guests integer[] DEFAULT '{}' ) I add a new record to the table: INSERT INTO groups (name) VALUES ('My friends');

Re: [GENERAL] [PERL DBI] Insertiing data across multiple tables

2008-07-24 Thread SCassidy
[EMAIL PROTECTED] wrote on 07/24/2008 01:36:27 PM: Does anybody know how to insert data over multiple tables transactionally? The relationship is 1:1 with the latter table having a foreign key constraint. In order to add data to Table2 I need to know the primary key value of the same

Re: [GENERAL] automating backups with windows scheduled tasks and pg_dumpall

2007-11-15 Thread SCassidy
[EMAIL PROTECTED] wrote on 11/15/2007 02:07:07 PM: Hello everybody. I'm having a bit of trouble automating pg_dumpall to do nightly backups. I have a batch file whose contents are below SET PGPASSFILE=C:\foo\bar\PG_BACKUP\PGPASSFILE\pgpass.conf C:\Program

Re: [GENERAL] not work in IE

2007-10-12 Thread SCassidy
Try checking the web server log. For example, if using apache, check /etc/httpd/logs/error_log, or the location your logs directory is installed. Very often web-based applications send STDERR to the web server log. Susan Cassidy manju arumugam [EMAIL PROTECTED] Sent by: [EMAIL

Re: [GENERAL] accessing PG using Perl:DBI

2007-08-30 Thread SCassidy
First, read the Perl DBI documentation that is relevant: perldoc DBD::Pg perldoc DBI Your examples do not make sense. You prepare a SQL statement, not just data. E.g.: $sth = $dbh-prepare(INSERT INTO test3(nameval, boolval) VALUES (?, ?)) or die($sth-errstr); foreach my $nm ('Joe', 'Fred',

Re: [GENERAL] bytea perl

2007-05-25 Thread SCassidy
You don't use quote when using placeholders, but you will have to escape the special characters, as mentioned previously. The note in DBD:Pg perldoc that says this: NOTE: The undocumented (and invalid) support for the SQL_BINARY data type is officially deprecated. Use

Re: [GENERAL] bytea perl

2007-05-24 Thread SCassidy
Hi, First, I would advise never using insert into xx values (y,x) without explicitly naming the columns; same for select statements - never use select * (a table change can mess things up). By the way, I just noticed in the release notes for the very latest couple of versions of DBD:Pg that

Re: [GENERAL] What does this error mean?

2007-05-23 Thread SCassidy
Hi, If you have a statement using placeholders like: select id from info where device_type = ? and drive_mfg = ? and then prepare and execute it, something like: $sth=$dbh-prepare($stmt) || errexit(bad prepare for stmt $stmt, error: $DBI::errstr);

Re: [GENERAL] Performance issues of one vs. two split tables.

2007-05-15 Thread SCassidy
One other possible reason for splitting the table up in two chunks is to grant different rights on the 2 sets of columns. Susan Cassidy Bill Moseley [EMAIL PROTECTED] Sent by: [EMAIL PROTECTED] 05/15/2007 09:44 AM To Postgres General pgsql-general@postgresql.org cc Subject Re: [GENERAL]

Re: [GENERAL] Writing oracle/postgress generic SQL

2007-02-23 Thread SCassidy
I've converted stuff from PostgreSQL to Oracle before, and some of the biggest pains were OFFSET ... LIMIT ... in PostgreSQL vs. ROWNUM or ROW_NUMBER in Oracle (depending on version of Oracle, including having to wrap the query with ROWNUM/ROW_NUMBER in a subselect - I greatly prefer OFFSET

Re: [GENERAL] Question - Query based on WHERE OR

2007-01-11 Thread SCassidy
You could have your program check to see if the lastname form field was empty, and send different queries to the database depending on what they entered. I'm a perl person, not php, so my php syntax might not be perfect, but you'll get the idea: if ($lastname ==) { $query=SELECT foo, baz,

Re: [GENERAL] shell script to populate array values

2006-12-12 Thread SCassidy
What's stopping you from using the variable? It works fine for me. The only problem I see is that you are quoting an integer value (SELECT '$SERVERCOLLECTIONTIMEID', column1 FROM mytable;) for no reason (leave off the single quotes around $SERVERCOLLECTIONTIMEID), although it does not seem to

Re: [GENERAL] shell script to populate array values

2006-12-11 Thread SCassidy
You should be able to use something like this in a bash script: psql -U postgres -hMYSERVER --quiet --no-align --field-separator ' ' -t -c SELECT servername,instanceport from server where serverclass = 3 and isactive = 'True' Admin | while read -a SVRDATA ;do echo name: ${SVRDATA[0]} port:

Re: [GENERAL] counting days

2006-08-29 Thread SCassidy
If I understood you correctly, you want the number of weekdays (e.g. an integer number of days) between 2 specified dates. This seems to work (although I am not the greatest plpgsql function person - not enough practice - there may be better ways): CREATE or REPLACE FUNCTION count_weekdays

Re: [GENERAL] US Telephone Number Type

2006-07-10 Thread SCassidy
In California, we definitely care about the area code, as there are several area codes (at least 4) in San Diego County. I have to use 1+area code to dial home from work, and vice-versa. Susan Martijn van

Re: [GENERAL] table has many to many relationship with itself - how

2006-06-14 Thread SCassidy
Starting with this: create sequence languages_seq increment by 1; create table languages ( id integer primary key default nextval('languages_seq'), language_name varchar(100) ); insert into languages (id, language_name) values (1, 'English'); insert into languages (id, language_name) values

Re: [GENERAL] UTF-8 context of BYTEA datatype??

2006-05-30 Thread SCassidy
Did you try escaping the data: my $rc=$sth-bind_param(1, escape_bytea($imgdata), { pg_type = DBD::Pg::PG_BYTEA }); Susan Rafal

Re: [GENERAL] UTF-8 context of BYTEA datatype??

2006-05-30 Thread SCassidy
Sorry, forgot: sub escape_bytea { my ($instring)[EMAIL PROTECTED]; my $returnstring=join ('',map { my $tmp=ord($_); ($tmp = 32 and $tmp = 126 and $tmp != 92) ? $_ : sprintf('\%03o',$tmp);} split (//,$instring)); return $returnstring; } # end sub escape_bytea

Re: [GENERAL] allow LIMIT in UPDATE and DELETE

2006-05-19 Thread SCassidy
Regarding Oracle's ROWNUM - since they have to use that instead of OFFSET and LIMIT, that isn't much of an argument for the Oracle way. When converting queries into Oracle SQL, I always _really_ miss OFFSET and LIMIT. They are much easier to use than ROWNUM, especially with ORDER BY. I think

Re: [GENERAL] Exporting postgres query to CSV

2006-05-09 Thread SCassidy
A word of advice: if there is any chance that a column (e.g. text) contains an embedded newline, you will be much better off outputting the data in simple xml, instead of CSV. This works very well with Excel for import. I just did a simple program for this recently. Susan

[GENERAL] error message on http://techdocs.postgresql.org/ during redirect

2006-04-04 Thread SCassidy
If I click on a link while on the http://techdocs.postgresql.org/ site, for example, under Quick Reference Material, PostgreSQL Notes, I briefly see an error message that says: Notice: Use of undefined constant userid - assumed 'userid' in

Re: [GENERAL] PostgreSQL's XML support comparison against other

2006-03-29 Thread SCassidy
If you have just a column containing a chunk of xml, and want to transform it into individual columns, such that each element/attribute is its own column, it should be pretty easy. Here's a simple perl example: Table public.testxml1 Column | Type |

Re: [GENERAL] index for inet and (contains) function

2006-03-22 Thread SCassidy
Depending on the types of queries you need to do, maybe you could kludge it up for speed by doing something like adding another column (or two) that can be easily indexed, and whose values can be derived from the existing data. You could then use the indexed column to narrow down the result set.

Re: [GENERAL] Need a GNU SQL CLI tool for Win32 with ODBC support.

2006-03-02 Thread SCassidy
Since you mentioned Java, I thought I'd mention this. There is no reason you cannot write a command line tool using Java. I'm no Java guru, but I quickly wrote a simple Java program to connect to PostgreSQL (on a Linux box) from a Windows box. I used a nice command line parser library called

Re: [GENERAL] what is the data type for files(.txt,.doc,.jpeg) in

2006-02-07 Thread SCassidy
For item (2), couldn't you modify the existing /etc/rc.d/rc2.d/K15postgresql, /etc/rc.d/rc3.d/K15postgresql, or whatever script(s), or add another script in the /etc/rc.d/rc*.d directories to be run just prior to shutting down the database? Of course, this would only work if the system was taken

Re: [GENERAL] pg_dump error codes

2006-01-03 Thread SCassidy
Here is a simple one, that keeps 2 copies (one for odd-numbered days and one for even-numbered days), and emails the admin with the status: #!/bin/sh #This script is to back up the production databases DBLIST=db1 proddb1 proddb2 PGUSER=dbusername DUMPDIR=/disk1/database/backups

Re: [GENERAL] Changing ids conflicting with serial values?

2005-11-03 Thread SCassidy
Strange - I had never realized that PostgreSQL would allow you to UPDATE a primary key value. I thought that other db's I had used (e.g. Sybase, Oracle, SQL Server, etc.) in the past would not allow that, and you had to DELETE, then INSERT to modify a row that needed a different primary key. Of

Re: [GENERAL] a stored procedure ..with integer as the parameter

2005-10-21 Thread SCassidy
First, you should not quote an integer value going into an integer column - bad habit to get into. Second, empty string is not an integer. Susan

Re: [pgsql-advocacy] [GENERAL] Oracle buys Innobase

2005-10-19 Thread SCassidy
A PostgreSQL to Oracle converter might be a really big project. Having ported an application from PostgreSQL (7.3) to Oracle 9i, as I recall, my biggest problems were: - Quoting issues: the original PostgreSQL application quoted integer/numeric type, and Oracle will not allow that, so I had to

Re: [GENERAL] Securing Postgres

2005-10-05 Thread SCassidy
You do know that MySQL lets you reset the root password if you forget it, don't you? See: http://dev.mysql.com/doc/mysql/en/resetting-permissions.html Not terribly secure, after all. Susan

Re: [GENERAL] DBI/DBD::Pg mem. use goes exponential

2005-09-29 Thread SCassidy
Hi, You cannot actually say that do is more correct than prepare/execute (for a non-select statement), because do is just a shortcut. According to the DBI documentation, it does a prepare and execute for you. In fact, if you look at the DBI.pm code, that is what it is doing. I do agree that

Re: [GENERAL] accessing postgresql via odbc?

2005-08-10 Thread SCassidy
Hi, I just did this myself (I'm a Unix/Linux person). Three steps: 1. Install the PostgreSQL ODBC driver on the Windows box. (download from http://www.postgresql.org/ftp/odbc/versions/msi/). 2. Configure the DSN on the Windows box: Go to Control Panel / Admin Tools / Data Sources (ODBC),

Re: [GENERAL] Suppressing Error messages.

2005-08-09 Thread SCassidy
Hi, To get rid of the automatic output, turn PrintError off. For example: $dbh = DBI-connect(dbi:Pg:dbname=$dbname;host=${dbserver};, $dbuser, ,{PrintError = 0}) or errexit( Unable to connect to dbname $dbname, err: $DBI::errstr); See the perldoc DBI documentation for full information. Here

Re: [GENERAL] Instalation batch file

2005-08-03 Thread SCassidy
Hi, If the psql program is always going to be in C:\Program Files\PostgreSQL\8.0\bin, couldn't you eliminate the cd, and just specify the full path (if psql is not in the current PATH) as needed? Or, add it to the PATH:PATH %path%;C:\Program Files\PostgreSQL\8.0\bin If you running the .bat

Re: [GENERAL] Perl DBI and postgres

2005-07-28 Thread SCassidy
Hi, Well, since we don't seem to have the actual code (you seem to have paraphrased it), I can't tell for sure. However, here (assuming this is sort of the way you actually are using it): my $target_sth = $target_dbh-prepare( q{ SELECT columns FROM the table

Re: [GENERAL] double entries into database when using IE

2005-07-05 Thread SCassidy
Hi, If a web page has JavaScript called on a submit button, like 'onClick=someFunction();, and the function does some stuff, then does a form.submit(), and DOES NOT REMEMBER TO RETURN FALSE, then the browser is supposed to go ahead and submit the form. So, something like that could possibly

Re: [GENERAL] PostgreSQL, WIndows, regular backup

2005-06-30 Thread SCassidy
This works to put the date in the filename on Windows 2000: In a .bat file: @echo off for /f tokens=1-4 delims=/ %%i in (%date%) do ( set dow=%%i set month=%%j set day=%%k set year=%%l ) set datestr=%month%_%day%_%year% echo datestr is %datestr% set

[GENERAL] setting up PostgreSQL on Linux RHL9 to allow ODBC connections from Windows

2005-06-22 Thread SCassidy
Hi, I have seen a bunch of different documentation on how to set up to allow ODBC, but I am a little confused about how much/what has to be set up to allow an ODBC connection from Windows (mostly 2003, some XP) to an existing PostgreSQL (7.4.6) database on Linux (RedHat 9 version 2.4.20-6smp).

Re: [GENERAL] Calculated bigserial column in a view

2005-04-26 Thread SCassidy
If you want a unique key across several tables, can you not do something like: CREATE SEQUENCE detail_seq INCREMENT BY 1; CREATE TABLE table1 ( table1_id INTEGER PRIMARY KEY DEFAULT nextval('detail_seq'), item1_name VARCHAR(100) NOT NULL ); CREATE TABLE table2 (

[GENERAL] Strange results of ORDER BY clause when item begins with slash or backslash

2005-01-19 Thread SCassidy
I am seeing some unexpected results for an ORDER BY in a query. It looks to me as if the sorting is confused about how to handle the slash or backslash character in a string. It acts as if ignoring it. Here is a sample: Table public.test_table Column | Type |

[GENERAL] to_char(interval, text) deprecated in future - how do we get consistent interval output without it?

2005-01-14 Thread SCassidy
I saw the note in the docs that to_char(interval, text) is deprecated, and will be removed. I searched the archives and saw more mentions of this, but no real explanation as to how it is planned for us to get consistent output formatting when querying a column containing interval data. For