Re: [SQL] regexp_replace and UTF8

2009-02-02 Thread Bart Degryse
want." ? Because in that case, they should be handled too. How should that be done. Thanks, Bart >>> Jasen Betts 2009-01-31 12:47 >>> On 2009-01-30, Bart Degryse wrote: > > --=__Part8EA648F8.0__= > Content-Type: text/plain; charset=UTF-8 > Content-Transfer-Encoding:

[SQL] regexp_replace and UTF8

2009-01-30 Thread Bart Degryse
anged it to select regexp_replace('de patiënt niet', '&#(\\d+);' ( file://\d+);' ), '\x' || to_hex(CAST (to_number(E'\\1','999') AS INTEGER)), 'g') which kind of works except that the result is not what I need: 'de patix

Re: [SQL] trigger parameters, what am I doing wrong ??

2008-10-10 Thread Bart Degryse
With some version (but I don't remember which) I had the same problem. I solved it by assigning TG_ARGV[0] to a variable and use the variable in the RAISE NOTICE. >>> Tom Lane <[EMAIL PROTECTED]> 2008-10-09 19:22 >>> "Marcin Krawczyk" <[EMAIL PROTECTED]> writes: > And here's what RAISE NOTICE lo

Re: [SQL] May I have an assistance on CREATE TABLE Command

2008-09-17 Thread Bart Degryse
The idea of id's is that they are meaningless, so saying "this row was supposed to be 33" is senseless. If you want Dar es Salaam to be 33 because eg it's the postal code, then add a column postal_code to your region table but keep the id to make the reference. >>> James Kitambara <[EMAIL PROTEC

Re: [SQL] May I have an assistance on CREATE TABLE Command

2008-09-17 Thread Bart Degryse
I think (one of) the point(s) of id fields is not to change them. You can update the region_name field (eg a correct a misspelling), but the id stays the same. That way the district stays connected to the same region. >>> James Kitambara <[EMAIL PROTECTED]> 2008-09-17 8:50 >>> Hello Mambers o

Re: [SQL] DIfference between max() and greatest() ?

2008-09-12 Thread Bart Degryse
max(expression) is an aggregate function (from the manual: "maximum value of expression across all input values") greatest(value [, ...]) is not an aggregate function (from the manual: "The GREATEST function selects the largest value from a list of any number of expressions.") So max takes the

Re: [SQL] Correct Insert SQL syntax?

2008-09-05 Thread Bart Degryse
You might wanna check out the PostgreSQL manual. http://www.postgresql.org/docs/ There's definitely an answer in it to all your questions. Especially chapter 38 on migrating from Oracle to PostgreSQL might be helpful. http://www.postgresql.org/docs/8.3/interactive/plpgsql-porting.html >>> "Rube

Re: [SQL] function returning result set of varying column

2008-06-03 Thread Bart Degryse
s, Thanks for all your for the reply. I tried the function and when I execute it using select * from myfunction() it says ERROR: a column definition list is required for functions returning "record" Could you please help me to fix this error? Thanks so much for your help. -maria On T

Re: [SQL] function returning result set of varying column

2008-06-03 Thread Bart Degryse
Hi Maria, Try something like CREATE OR REPLACE FUNCTION myfunction() RETURNS SETOF RECORD AS $body$ DECLARE rec record; BEGIN FOR rec IN ( SELECT * FROM sometable) LOOP RETURN NEXT rec; END LOOP; RETURN; END; $body$ LANGUAGE 'plpgsql' VOLATILE; As you can see, the number and typ

Re: [SQL] Weeks elapsed to Months elapsed conversion

2008-05-30 Thread Bart Degryse
Approx. 52 weeks in a year, thus 13 weeks in 3 months. select numberofweeks/13*3 as numberofmonths from yourtable or if you want whole months returned select floor(numberofweeks/13*3) as numberofmonths from yourtable >>> Allan Kamau <[EMAIL PROTECTED]> 2008-05-30 11:21 >>> Hi all, I have a sim

[SQL] Field Alias Alternative

2008-04-29 Thread Bart Degryse
Is there another way to quote a field alias (containing spaces) than with double quotes? This works: SELECT actions.addresstypes.addresstype AS "Address Type" FROM actions.addresstypes I would like something like this SELECT actions.addresstypes.addresstype AS [Address Type] FROM actions.add

Re: [SQL] First day of month, last day of month

2008-04-24 Thread Bart Degryse
sory, afaikt vas djust a tiping eror. mi apollogys >>> "Scott Marlowe" <[EMAIL PROTECTED]> 2008-04-24 16:56 >>> On Thu, Apr 24, 2008 at 8:52 AM, Terry Lee Tucker <[EMAIL PROTECTED]> wrote: > > On Thursday 24 April 2008 10:47, Bart Degryse wrote: &

Re: [SQL] First day of month, last day of month

2008-04-24 Thread Bart Degryse
Well, that's what it does afaikt. >>> "Nacef LABIDI" <[EMAIL PROTECTED]> 2008-04-24 16:43 >>> Actually I want to select all rows whith dates between first day of the month 00:00:00 and last date of the month 23:59:59 On Thu, Apr 24, 2008 at 4:15 PM, Colin Wetherbee <[EMAIL PROTECTED]> wrote: F

Re: [SQL] First day of month, last day of month

2008-04-24 Thread Bart Degryse
Don't know whether it's better, but it's shorter. With extract you have to make the extraction for both year and month (unless cases where either one doesn't matter) With date_trunc('month', ...) you throw away anything smaller than month in one step. I suppose having to call the function date_tr

Re: [SQL] First day of month, last day of month

2008-04-24 Thread Bart Degryse
select * from mytable where date_trunc('month', mydate) = date_trunc('month', now()); >>> Frank Bax <[EMAIL PROTECTED]> 2008-04-24 15:06 >>> Nacef LABIDI wrote: > is there a better method to retrieve all > the rows with dates in the current month. select * from mytable where extract(month fro

Re: [SQL] After updating dataset the record goes to the end of thedataset

2008-04-22 Thread Bart Degryse
Probably what you mean is that you want the order in which the records were originally inserted into the database. In that case add a serial to your table and fetch the records like SELECT * FROM tbl WHERE 1=1 ORDER BY [myserialfield] It's not foolproof but will in many cases come close to what y

Re: [SQL] Commit every processed record

2008-04-07 Thread Bart Degryse
Well, actually there is. Do the processing in a plperlu function which uses it's own connection to the db. Then every instance of the function will have it's own transaction. Try to start that perl connection outside the function or your performance will drop too much. I use this technique to fet

Re: [SQL] in() VS exists()

2008-03-13 Thread Bart Degryse
lect count(sp.id) from specimens sp INNER JOIN (select specimen_id from specimen_measurements GROUP BY specimen_id) as foo on foo.specimen_id = sp.id; count --- 75241 (1 row) Time: 1165.487 ms Regards, Julien On Thu, 2008-03-13 at 15:28 +0100, Bart Degryse wrote: > how about > selec

Re: [SQL] in() VS exists()

2008-03-13 Thread Bart Degryse
The chapter on indexes in the manual ( http://www.postgresql.org/docs/8.2/static/indexes.html )should give you a pretty good idea on the why. IN and EXISTS are not the only possibilities, you can also use inner or outer joins. Which solution performs best depends on the data, the database version,

Re: [SQL] in() VS exists()

2008-03-13 Thread Bart Degryse
e: 81.736 ms muridae=> (of course this is a bad example, because I could just do: select count(specimen_id) from sequences group by specimen_id;, but in my application I have more fields coming from specimens of course) Julien On Thu, 2008-03-13 at 15:12 +0100, Bart Degryse wrote: > I t

Re: [SQL] in() VS exists()

2008-03-13 Thread Bart Degryse
pecimen_id from sequences); is almost the same as : select count(sp.id) from specimens sp INNER JOIN (select specimen_id from sequences GROUP BY specimen_id) as foo on foo.specimen_id = sp.id; ? Thanks, Julien On Thu, 2008-03-13 at 14:46 +0100, Bart Degryse wrote: > The chapter on indexes

Re: [SQL] Composite UNIQUE across two tables?

2008-03-07 Thread Bart Degryse
terest. Could you describe me more how you design an unique index with both a column name and a function name by an example Thx. Sebastien ____ De : [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] De la part de Bart Degryse Envoyé : vendredi 7 mars 2008 08:46 À

Re: [SQL] Composite UNIQUE across two tables?

2008-03-07 Thread Bart Degryse
create a function that, given the siteid returns the sitegroupid create a unique index on username and that function >>> "Jamie Tufnell" <[EMAIL PROTECTED]> 2008-03-06 20:04 >>> Hi, I'm remodeling our authentication tables at the moment to accomodate future changes. I've hit a wall and thought I

Re: [SQL] pl/pgsql and error handling

2008-02-28 Thread Bart Degryse
www.postgresql.org/docs/8.2/static/plpgsql-control-structures.html#PLPGSQL-ERROR-TRAPPING would be the place to look. >>> Alex Hochberger <[EMAIL PROTECTED]> 2008-02-29 6:29 >>> I do not know. It's sounds like the Oracle PL/SQL behavior is what I want. Does PostgreSQL's pl/pgsql have such a f

Re: [SQL] Function returns error (view)

2008-02-27 Thread Bart Degryse
assword('Paul'); ERROR: set-valued function called in context that cannot accept a set SQL state: 0A000 Context: PL/pgSQL function "search_password(" line 14 at return next Error at WHERE login= Paul ?? Thanks for your help Flávio 2008/2/27, Bart Degryse <[EMAIL PROTECTED]&

Re: [SQL] Function returns error (view)

2008-02-27 Thread Bart Degryse
t) just to be sure of optimal performance. Keeping that in mind I don't see any harm in advising others to do so too. But you're right in stating that it's not always necessary. >>> "Markus Bertheau" <[EMAIL PROTECTED]> 2008-02-27 10:09 >>> 20

Re: [SQL] Function returns error (view)

2008-02-26 Thread Bart Degryse
t accept a set SQL state: 0A000 Context: PL/pgSQL function "seach_password(" line 14 at return next Error at WHERE login= USER_FOO ?? Thanks for your help Flávio 2008/2/26, Bart Degryse <[EMAIL PROTECTED]>: I think you have a quoting problem You want something like WHERE logi

Re: [SQL] Function returns error (view)

2008-02-26 Thread Bart Degryse
I think you have a quoting problem You want something like WHERE login= 'Flavo' But you're making something like WHERE login = Flavo Something like this should work... CREATE OR REPLACE FUNCTION seach_password(USER_FOO IN table_user.login%TYPE) RETURNS SETOF vw_change_password AS $BODY$ DECL

Re: [SQL] duplicate key violates unique constraint

2008-02-26 Thread Bart Degryse
Shavonne, You will probably always find someone on the list who will answer your questions, but you really should read the manual too! In this case you could have found the answer by reading http://www.postgresql.org/docs/8.2/static/plpgsql-control-structures.html#PLPGSQL-ERROR-TRAPPING >>> "Shav

Re: [SQL] postgresql function not accepting null valuesinselect statement

2008-02-25 Thread Bart Degryse
ary 22, 2008 10:01 PM To: pgsql-sql@postgresql.org Subject: Re: [SQL] postgresql function not accepting null values inselect statement On Friday 22 February 2008 01:35:47 am Bart Degryse wrote: > Can you try this... > > CREATE OR REPLACE FUNCTION getfunctionaries(p_statecd integer) > RE

Re: [SQL] postgresql function not accepting null values inselect statement

2008-02-22 Thread Bart Degryse
Can you try this... CREATE OR REPLACE FUNCTION getfunctionaries(p_statecd integer) RETURNS SETOF t_functionaries AS $BODY$ DECLARE rec t_functionaries%ROWTYPE; BEGIN FOR rec IN ( SELECT f.functionaryid, f.category, f.description FROM functionaries f WHERE f.statecd IS NOT DISTI

Re: [SQL] Function description

2008-02-15 Thread Bart Degryse
>>> Gavin 'Beau' Baumanis <[EMAIL PROTECTED]> 2008-02-15 13:33 >>> >I MUST have a local / development database for testing and educational / >learning purposes - unless of course you would like me to use the production >server for testing? I do have a development database, but not locally. And

Re: [SQL] Function description

2008-02-15 Thread Bart Degryse
>>> Gavin 'Beau' Baumanis <[EMAIL PROTECTED]> 2008-02-15 12:46 >>> >The windows installer, available at; >http://www.postgresql.org/ftp/win32/ >Allows you to install the DB and / OR the tools including psql >So you can just install the psql command line tool onto your local machine. I can't instal

Re: [SQL] Function description

2008-02-15 Thread Bart Degryse
I can't install applications on my desktop pc ICT won't install that application on my desktop pc... that would require an amout of trust and... >>> Richard Huxton <[EMAIL PROTECTED]> 2008-02-15 12:17 >>> Well, the windows installer comes with the backend database server, psql.exe, pgadmin, manua

Re: [SQL] Packages

2008-02-15 Thread Bart Degryse
As far as I know not like it exists in Oracle. Alternatively you can use a schema per package, but it doesn't solve eg package variables and constants. Personally I just let my functionnames start with the "package name", so I have general_log(...), general_log_err(...), replicate_exact(...), re

Re: [SQL] Function description

2008-02-15 Thread Bart Degryse
Richard Huxton <[EMAIL PROTECTED]> 2008-02-15 11:50 >>> >>> To see how e.g. \dC etc work start psql with -E >>> >> I'm sorry, but I don't have commandline access to the database. That would >> require an amount of trust and a level of competence our ICT department is >> incapable of. > >Well,

Re: [SQL] Function description

2008-02-15 Thread Bart Degryse
>>> Richard Huxton <[EMAIL PROTECTED]> 2008-02-15 11:15 >>> >Dont' forget to cc: the list Bart :-) My mistake, sorry. Normally I only reply to the list and not to the respondent's personal address. Would that be wrong too? > >Bart Degryse wrote: >

[SQL] Function description

2008-02-15 Thread Bart Degryse
Hi all, I find some 1553 functions in pg_catalog of which only a small part is documented in the manual. Does anyone know where I can find what the others do with maybe an example.

Re: [SQL] inhibit rounding on numeric columns

2008-02-14 Thread Bart Degryse
You could probably create a before insert trigger which compares the number of fractional digits in the given number with the defined scale (surely some system table can offer you that) and raises an exception if needed. I do agree though with Niklas Johansson's remarks and wonder with him on wh

Re: [SQL] return field from different table conditionally

2008-02-13 Thread Bart Degryse
s. I've tried all sorts of variations (return a table type or a user defined type from the stored procedure, type casting the result) but to no avail. Can anyone help me out? Thanks >>> "Bart Degryse" <[EMAIL PROTECTED]> 2008-02-13 11:54 >>> I'

[SQL] return field from different table conditionally

2008-02-13 Thread Bart Degryse
I'm having trouble getting the values I want from my tables. Below you find the DDL's for all tables concerned and some data to test with. What I would like to get as a result is: for each billing_exact record the salesunit from account_ranges if there is a match between billing_exact.lineamount

Re: [SQL] Sql ORDER BY and ASC/DESC question

2008-01-30 Thread Bart Degryse
Actually there might be assuming your function is a set returning function. This example eg works perfectly and sorts the output of the function without having to use execute. CREATE TABLE "public"."error_types" ( "id" SERIAL, "errdesc" TEXT NOT NULL, "autofix" BOOLEAN DEFAULT false NOT

Re: [SQL] dynmic column names inside trigger?

2007-11-26 Thread Bart Degryse
just choose the technique you like best. I'm not aware of any performance penalties for either technique. Anyone? >>> Louis-David Mitterrand <[EMAIL PROTECTED]> 2007-11-23 18:06 >>> On Wed, Nov 21, 2007 at 09:14:14AM +0100, Bart Degryse wrote: > I would do somet

Re: [SQL] dynmic column names inside trigger?

2007-11-22 Thread Bart Degryse
> On Wed, Nov 21, 2007 at 09:14:14AM +0100, Bart Degryse wrote: > I would do something like this (not tested, but conceptually working): Hello, > BEGIN > if old.story is not null and new.story != old.story then > new.story = sanitize_text(new.story); > end if; > --checks on other

Re: [SQL] How to have a unique primary key on two tables

2007-11-22 Thread Bart Degryse
When you use serial a kind of macro is performed: in fact an integer field is created, a sequence is created with a name based on the table's name and the nextval of that sequence is used as the default value for the field. Now you have to do these steps "manually". CREATE SEQUENCE "public"."t

Re: [SQL] dynmic column names inside trigger?

2007-11-21 Thread Bart Degryse
I would do something like this (not tested, but conceptually working): CREATE or replace FUNCTION sanitize_text(webtext IN text, cleantext OUT text) AS $body$ BEGIN cleantext = translate(webtext, E'\x92\x96', '''-'); cleantext = regexp_replace(cleantext, E'\x9c', 'oe', 'g'); cleantext = regexp_re

Re: [SQL] trap for any exception

2007-11-16 Thread Bart Degryse
I think you should carefully read what the manual tells about PL/pgSQL (http://www.postgresql.org/docs/8.2/static/plpgsql.html) and especially about Trapping Errors (http://www.postgresql.org/docs/8.2/static/plpgsql-control-structures.html#PLPGSQL-ERROR-TRAPPING). >>> Stephan Szabo <[EMAIL PR

Re: [SQL] ALL() question

2007-11-14 Thread Bart Degryse
The doc says "The right-hand side is a parenthesized subquery, which must return exactly one column..." That's what you have if using "... where test_bit_id = all(select id from test_bits where id in (1,2,3,4));" The doc continues "...The left-hand expression is evaluated and compared to each ro

Re: [SQL] Select in From clause

2007-11-12 Thread Bart Degryse
Consider this: CREATE TABLE "public"."test" ( "id" INTEGER NOT NULL, "tbl" TEXT ) WITHOUT OIDS; INSERT INTO "public"."test" ("id", "tbl") VALUES (1, 'status'); INSERT INTO "public"."test" ("id", "tbl") VALUES (2, 'yearplan'); Following two statements will return one record. select tbl from

Re: [SQL] Rule Error

2007-10-04 Thread Bart Degryse
You have defined the fields KODEGL and NAMAREK as uppercased field names. In your rule you refer to an unquoted field KODEGL twice and twice to an unquoted field NAMAREK. Default behaviour of PostgreSQL for unquoted fieldnames is to lowercase them. As such these fields effectively don't exist in y

[SQL] select sum within transaction problem

2007-09-11 Thread Bart Degryse
Dear all I have a function like below (simplified). Everything works the way I want it to except for one thing. After the select statement sum_revenues is NULL instead of the real sum. Has this something to do with the earlier deletes and inserts not being committed yet? I assumed they would have

[SQL] Failing join with set returning function

2007-09-07 Thread Bart Degryse
I've written a function that calculates the number of days for every month in a given range and returns that as a set of records. CREATE OR REPLACE FUNCTION general_daysinmonth( date1 IN date, date2 IN date, month OUT date, days OUT integer) RETURNS SETOF record AS $body$ DECLARE startda

Re: [SQL] Use of delete...returning in function problem

2007-09-04 Thread Bart Degryse
Amazing what a bracket can do :) Thanks for the help. >>> Richard Huxton <[EMAIL PROTECTED]> 2007-09-04 12:45 >>> Bart Degryse wrote: > I'm trying to use a delete statement with returning clause in a function: > FOR rec IN ( > delete from billin

[SQL] Use of delete...returning in function problem

2007-09-04 Thread Bart Degryse
I'm trying to use a delete statement with returning clause in a function: CREATE OR REPLACE FUNCTION "public"."test_delete"() RETURNS void AS $body$ DECLARE rec billing_errors_new; BEGIN FOR rec IN ( delete from billing_errors_new where errortypeid IN (1,2) returning *) LO

Re: [SQL] Database normalization

2007-08-28 Thread Bart Degryse
Im using Django as my Object relational Mapper so im pretty sure I can not add a constraint such as ... Then you should seriously consider changing your mapper. >>> "Sebastian Ritter" <[EMAIL PROTECTED]> 2007-08-28 16:37 >>> Thanks for the information. Both tables would be exactly sames apart fr

Re: [SQL] raise exception and transaction handling

2007-07-30 Thread Bart Degryse
Alternative that always works no matter how many raise exceptions there are: Create a (perlu) function that opens a second connection to your database and does the insert into m_proba. Since this is a seperate connection, it's also a seperate transaction and thus not rolled back by your "main" tr

[SQL] Quote problem

2007-07-06 Thread Bart Degryse
Consider a perl function like this CREATE OR REPLACE FUNCTION public.test(text) RETURNS VOID AS $body$ my $var = shift; spi_exec_query("INSERT INTO tbltest(field1) VALUES ('$var')"); $body$ LANGUAGE 'plperlu' VOLATILE; and a table CREATE TABLE tbltest ( field1 text ) WITHOUT OIDS; When I ca

Re: [SQL] dblink inside plpgsql function

2007-07-03 Thread Bart Degryse
What Pavel mentions might indeed be an issue, but I think there's another one too. I think you have to call your function giving more information to the statement on what types will be returned. Since you use dblink I assume that the table or view reminder_services you are basically selecting fr

Re: [SQL] NO DATA FOUND Exception

2007-06-26 Thread Bart Degryse
In case you would like to use set returning functions... if your function will return records with the same structure as an existing table CREATE FUNCTION my_func() RETURNS SETOF my_table AS ... if not you have to define the returning type CREATE TYPE func_row AS ("field1" varchar(10), "field2

Re: [SQL] Transactions and Exceptions

2007-06-26 Thread Bart Degryse
>>>> Richard Huxton <[EMAIL PROTECTED]> 2007-06-22 19:00 >>> >Bart Degryse wrote: >>> 2. Using dblink / dbi-link to reconnect to the database, which means >>> your logging will take place in its own transaction. >> This I like more. Though I d

Re: [SQL] yet another simple SQL question

2007-06-26 Thread Bart Degryse
"A. Kretschmer" <[EMAIL PROTECTED]> 2007-06-25 20:07 >>> >am Mon, dem 25.06.2007, um 12:44:25 -0500 mailte Joshua folgendes: >> Ok, >> >> You guys must be getting sick of these newbie questions, but I can't >> resist since I am learning a lot from these email lists and getting >> results

Re: [SQL] Transactions and Exceptions

2007-06-22 Thread Bart Degryse
>>> Richard Huxton <[EMAIL PROTECTED]> 2007-06-22 15:24 >>> >Bart Degryse wrote: >> Dear all, >> I'm having a problem with transactions and exceptions and need your advice. >> I want a function to do two things: >> - log something to a tabl

[SQL] Transactions and Exceptions

2007-06-22 Thread Bart Degryse
Dear all, I'm having a problem with transactions and exceptions and need your advice. I want a function to do two things: - log something to a table (which is basically an insert) - raise an exception under certain conditions My problem is that when I raise the exception the insert is rolled back.

Re: [SQL] perlu: did I find a bug, or did I make one?

2007-06-04 Thread Bart Degryse
ing 2 times the 'lil' error message and two times the 'bol' error message. >>> Tom Lane <[EMAIL PROTECTED]> 2007-06-04 16:52 >>> "Bart Degryse" <[EMAIL PROTECTED]> writes: > CREATE TRIGGER "afh_test_tr" BEFORE INSERT > ON

[SQL] perlu: did I find a bug, or did I make one?

2007-06-04 Thread Bart Degryse
Situation: I'm writing a function that fetches data in an Oracle database and stores it in postgresql database. The function works, but I can't seem to get the error handling right. I get something but it's not what I expect. This is what I get: executing 14 generated 4 errors ERROR: lil foutje

Re: [SQL] slow query execution

2007-05-31 Thread Bart Degryse
Sorry, I don't know C++ enough to help you much. I also don't understand your problem well enough. >>> Trigve Siver <[EMAIL PROTECTED]> 2007-05-31 9:46 >>> Hi, thanks for reply No, I'm working with c++ and libpqxx (pgsql c++ binding). I'm using Win32 Listview control with LS_OWNERDATA style. I

Re: [SQL] slow query execution

2007-05-31 Thread Bart Degryse
Am I right in assuming that you're working on a VB application with a ListView AxtiveX Control in it? If so consider putting the value of the ID field of your table in the Tag Property of each item in your listview. By looping over all items in your listview you can then check the property for c

[SQL] spi and error messages

2007-05-30 Thread Bart Degryse
Hi, I'm writing some function to fetch data from an Oracle database and store it in a PostgreSQL database. CREATE OR REPLACE FUNCTION public.replicate_billing(text, date, date) RETURNS void AS $body$ use DBI; my $dbh_ora = DBI->connect('dbi:Oracle:database=bmssa;host=firev120-1.indicator.b

Re: [SQL] SQL Query Validate Records Multiple Tables - HelpNeeded

2007-05-16 Thread Bart Degryse
I'm working on something similar at the moment. Don't know about you, but I have an additional problem: I have to deal with rather large datasets (>2 recs per query) to be moved between the two databases (Oracle and PostgreSQL in my case). After doing lots of performance test, for me the con

Re: [SQL] Needs Function

2007-05-03 Thread Bart Degryse
Well, actually it was there last week too :) >>> "Aaron Bono" <[EMAIL PROTECTED]> 2007-05-03 16:14 >>> On 5/3/07, Rodrigo De León <[EMAIL PROTECTED]> wrote: See: http://archives.postgresql.org/pgsql-general/2005-12/msg00080.php Man, where was this last week when I needed it. I will have

[SQL] plperlu hash problem

2007-04-26 Thread Bart Degryse
I have a little Perl problem. When I call function dbi_select_test like SELECT * from dbi_select_test() I get the expected result. However when I call SELECT * from dbi_select I get an error message saying "ERROR: error from Perl function: setof-composite-returning Perl function must call return_

[SQL] plperlu hash problem

2007-04-23 Thread Bart Degryse
I have a little Perl problem. When I call function dbi_select_test like SELECT * from dbi_select_test() I get the expected result. However when I call SELECT * from dbi_select I get an error message saying "ERROR: error from Perl function: setof-composite-returning Perl function must call return_

Re: [SQL] We all are looped on Internet: request+transport = invariant

2007-04-23 Thread Bart Degryse
I'll continue with the analogy It is not impossible to attach wings to a sportscar. When you do, you will probably get the sportscar flying. However: 1. Why would you even try, if airplanes (which are designed from scratch to fly) already exist. Just use them 2. If you try nevertheless, is getting

Re: Fwd: Re[2]: [SQL] We all are looped on Internet: request + transport = invariant

2007-04-23 Thread Bart Degryse
If these people really work with hierarchically structured data, let them try a hierarchical database (even though PostgreSQL is your favourite database). They will profit 100fold from the advantages such a database has for such data. I now several biologists specialized in taxonomy (which is by na

Re: [SQL] We all are looped on Internet: request +transport = invariant

2007-04-22 Thread Bart Degryse
A hierarchical is specialized in managing data which is hierarchically structured, while a relational database is not. Maybe this analogy is clearer: If you want to fly you could attach wings to your sportscar, but it's more logical to use a plane. >>> Dmitry Turin <[EMAIL PROTECTED]> 2007-04-20 1

Re: [SQL] Retrieve month from date

2007-04-20 Thread Bart Degryse
Please always include the error message you get when something isn't working. If you defined your table with quoted identifiers (create table "StudentFeesPayment" as ...) then try Select max("ReceiptNo") from "StudentFeesPayment" where Extract(Month from "ReceiptMonthYear")=4; else try Select

Re: [SQL] We all are looped on Internet: request + transport = invariant

2007-04-20 Thread Bart Degryse
Trees like you seem to suggest are called hierarchies. If you prefer hierarchies over relationnality you could use a hierarchical database instead of a relational database. When you search the internet you can find plenty of information on eg Adabas, GT.M., IMS, DMSII, Focus, Metakit and many ot

Re: [SQL] ERROR: column "crc" does not exist

2007-04-12 Thread Bart Degryse
Try either - defining the field as: crc character varying(255) - rewrite your select as: Select * from base.points where "CRC" = 'e19e26330a0db2f2435106b16623fa82'; >>> <[EMAIL PROTECTED]> 2007-04-12 14:23 >>> Hi list, I have a table with many fields and the latest field is: "CRC" character var

Re: [SQL] Select and Count

2007-03-20 Thread Bart Degryse
Don't know any ASP but maybe Response.Write only accepts strings. In that case you would need to do something like <% Response.Write cStr(sch_sin) %> Maybe you can let the database do the summing: <% option explicit %> <% Dim strSQL Dim oRs Dim oConn oConn = ... 'Fill t

Re: [SQL] ERROR: duplicate key violates unique constraint

2007-03-20 Thread Bart Degryse
Use INSERT INTO reference(reference_text, reference_type, Topic_Id) VALUES (DEFAULT,'123','2',1); instead. Since referencelist_nr is a serial PostgreSQL will provide the next free integer itself. >>> "remco lengers" <[EMAIL PROTECTED]> 2007-03-20 10:11 >>> Hi List, Its been a while since I wo

Re: [SQL] INSERT INTO

2007-03-16 Thread Bart Degryse
I don't use ASP but in PHP I would do something in the line of $valuetoinsert = "SANT'ANGELO LODIGIANO"; $query = "INSERT INTO TABLE2 (TE_INDI) VALUES ('" . str_replace("'", "''", $valuetoinsert) . "')"; I'm sure ASP has also a string replacement function >>> "Shavonne Marietta Wijesinghe" <[

Re: [SQL] For loop

2007-03-13 Thread Bart Degryse
etion one more time. I must have a function ? Isn't another way to implement it without using functions ? Ezequias Bart Degryse escreveu: > Please post your complete CREATE FUNCTION statement. Error code 42601 > refers to some syntax error which probably occurs just before you > s

Re: [SQL] For loop

2007-03-13 Thread Bart Degryse
(if loop) ERROR: syntax error at or near "LOOP" SQL state: 42601 Character: 1 I installed the pgsql but I don't think it is a problem of language. What could be wrong ? I am not using functions too. I am using the SQL tool of PgAdmin III. Any help would be glad.

Re: [SQL] For loop

2007-03-13 Thread Bart Degryse
As you can see in the manual (http://www.postgresql.org/docs/8.1/interactive/plpgsql-control-structures.html) you have to remove the ; after the initial LOOP LOOP statements IF i > 100 THEN EXIT; END LOOP; Or you can try... WHILE i <= 100 LOOP statements END LOOP; Or e

Re: [SQL] CREATE TABLE

2007-03-09 Thread Bart Degryse
Because being consistent is easily overlooked I would advise not to quote the table names Instead of calling your table thisTableIsBig call it this_table_is_big >>> Andrew Sullivan <[EMAIL PROTECTED]> 2007-03-09 15:21 >>> On Fri, Mar 09, 2007 at 02:56:06PM +0100, Shavonne Marietta Wijesinghe wr

Re: [SQL] A form of inheritance with PostgreSQL

2007-03-09 Thread Bart Degryse
Just a little example of what I've been using on version 8.0.3 with total satisfaction. CREATE TABLE "public"."tblMovementDetails" ( "ID" INTEGER NOT NULL, "PlanningDetailID" INTEGER NOT NULL, "MovementID" INTEGER NOT NULL, "UserID" VARCHAR(5) NOT NULL, "Number" INTEGER DEFAULT 0 NOT N

Re: [SQL] convert to a string

2007-03-06 Thread Bart Degryse
; <[EMAIL PROTECTED]> 2007-03-06 15:32 >>> when i try the set oRs = oConn.Execute("SELECT N_GEN::int FROM MyTable ORDER BY N_GEN DESC") it returns 1 and for the rest i doens't change. alsways 10 :( - Original Message - From: Bart Degryse ( mailto:[EMAIL

Re: [SQL] Time of executed query

2007-03-06 Thread Bart Degryse
t the database give me this information. I don't know if > > it is possible becouse if we retrieve many rows and if we want to put > > this result in a new column the same time will be replicated many > > times and consuming more processing. > > > > Any other sugge

Re: [SQL] convert to a string

2007-03-06 Thread Bart Degryse
I assume GetFieldValue is the name of a VB function or property get? Try either Set oRs = oConn.Execute("SELECT N_GEN::int FROM MyTable ORDER BY N_GEN DESC") or GetFieldValue = cint(oRs("N_GEN")) + 1 or GetFieldValue = clng(oRs("N_GEN")) + 1 In the last two cases make sure that the funct

Re: [SQL] Time of executed query

2007-03-06 Thread Bart Degryse
AIL PROTECTED]> 2007-03-06 14:37 >>> I preffer that the database give me this information. I don't know if it is possible becouse if we retrieve many rows and if we want to put this result in a new column the same time will be replicated many times and consuming more processing. Any ot

Re: [SQL] Time of executed query

2007-03-06 Thread Bart Degryse
note the time just before your operation starts note the time just after it ends show timeafter - timebefore >>> "Ezequias Rodrigues da Rocha" <[EMAIL PROTECTED]> 2007-03-06 14:20 >>> Hi list, It is possible to retrieve the time of a SQL statement leads to execute ? I would like to put in my appl

Re: [SQL] How to store a password encripted in a userdefinedtable

2007-03-01 Thread Bart Degryse
Why md5 function return a different string from user role of postgresql ? It allways put an md5 string concated with another sequence of string. Why does it occurs ? Ezequias 2007/3/1, Ezequias Rodrigues da Rocha <[EMAIL PROTECTED]>: > I know it. Thank you so much. > > Ezequias

Re: [SQL] How to store a password encripted in a user definedtable

2007-03-01 Thread Bart Degryse
update yourtable set passwordfield = md5(passwordfield) watch out: md5 is irreversable! you can't "un_md5" >>> "Ezequias Rodrigues da Rocha" <[EMAIL PROTECTED]> 2007-03-01 15:08 >>> John, That was what I was looking for for a long time. Now I will change my teller password account to md5. Co

Re: [SQL] How to store a password encripted in a user definedtable

2007-03-01 Thread Bart Degryse
Maybe a little example - create a table with two columns: username and password (eg. tbl_users) - in a secure environment (thus not over the internet) insert records into the table INSERT INTO tbl_users(username, password) VALUES ('John', md5('johnspassword')) - make a website with a login page

Re: [SQL] Uppercase and Lowercase

2007-02-19 Thread Bart Degryse
CEDURE "public"."func_change_case"(); >>> "Hiltibidal, Robert" <[EMAIL PROTECTED]> 2007-02-19 16:55 >>> Exactly. Since its only a select group of words this query applies to its better to correct for this before the information goes into the dat

Re: [SQL] Uppercase and Lowercase

2007-02-19 Thread Bart Degryse
"VIA SENATO" in to "Via senato" but what i need is "Via Senato" Anyoneee?? Shavonne Wijesinghe - Original Message - From: Bart Degryse ( mailto:[EMAIL PROTECTED] ) To: pgsql-sql@postgresql.org Sent: Monday, February 19, 2007 4:25 PM S

Re: [SQL] Uppercase and Lowercase

2007-02-19 Thread Bart Degryse
Replace && by || >>> "Shavonne Marietta Wijesinghe" <[EMAIL PROTECTED]> 2007-02-19 16:22 >>> Hello In my PostgreSQL database i have records inserted in Uppercase. For example: VIA SENATO What i want is to change them to "Via Senato". Ofcourse i'm looking for a automatico way. I wrote this co

Re: [SQL] Sum sets of records

2007-02-12 Thread Bart Degryse
select sum(case when id = 'C' then value else -value end) as total from mytable >>> "Ezequias Rodrigues da Rocha" <[EMAIL PROTECTED]> 2007-02-12 16:41 >>> Hi list, I would like a little help from you to get the sum value of various subsets of my table. My table is like this id | type | value 1

Re: [SQL] interval as hours or minutes ?

2007-02-08 Thread Bart Degryse
Use trunc instead of round. Also take a look at ceil and floor functions >>> Aarni Ruuhimäki <[EMAIL PROTECTED]> 2007-02-08 11:01 >>> On Thursday 08 February 2007 00:09, you wrote: > select extract(epoch from (timestamp '2007-02-07 16:24:00' - timestamp > '2007-02-05 13:00:01'))/60 as minutes; > >

Re: [SQL] Duplicate records

2007-02-02 Thread Bart Degryse
B where A.field1 = B.field1 and A.field2 = B.field2 >>> "Ezequias Rodrigues da Rocha" <[EMAIL PROTECTED]> 2007-02-02 14:59 >>> Thank you but are you talking of two tables ? I intent to check in only one table. Please explain to me. Ezequias 2007/2/2, Bart Degr

  1   2   >