[SQL] parse bug

2002-11-12 Thread floyds

seems like an error in the sql parser to me:

# create table test (acol smallint[]);
CREATE
# insert into test (acol) values ('{ 0 }');
ERROR:  pg_atoi: error in "0 ": can't parse " "
# insert into test (acol) values ('{ 0}');
INSERT 28472 1

the only difference is the trailing " " after the 0;


Regards,

Floyd Shackelford
4 Peaks Technology Group, Inc.
VOICE: 334.735.9428
FAX:   916.404.7125
EMAIL: [EMAIL PROTECTED]
ICQ #: 161371538

acta non verba



---(end of broadcast)---
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to [EMAIL PROTECTED] so that your
message can get through to the mailing list cleanly



[SQL] empty arrays

2003-01-01 Thread floyds

using: psql (PostgreSQL) 7.2.1

why does an empty array return an array of length 1 rather than array of
length 0? one would think that the results below would have returned { }
instead of {0}.

simple test using psql:

# create table test_table ( test_column integer[] );
CREATE
# insert into test_table (test_column) values ( '{ }' );
INSERT 43475 1
# select * from test_table;

test_column

 {0}
(1 row)


i want to be able to store a zero-length array field in the database. how do
i specify this with  sql?

Regards,

Floyd Shackelford
4 Peaks Technology Group, Inc.
VOICE: 334.735.9428
FAX:   916.404.7125
EMAIL: [EMAIL PROTECTED]
ICQ #: 161371538

Shackelford Motto: ACTA NON VERBA - Actions, not words

Alabama StateMotto: AUDEMUS JURA NOSTRA DEFENDERE - We Dare Defend Our
Rights



---(end of broadcast)---
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/users-lounge/docs/faq.html



[SQL] column doesn't get calculated

2003-07-19 Thread floyds


this must be a problem with my sql, but this one has me stumped. the column:
Debit."cumm_dbt_blnce" - Credit."cumm_crd_blnce" in the long sql statement
below comes out as the literal: Debit."cumm_dbt_blnce" -
Credit."cumm_crd_blnce" rather than as the calculated value. WHY!?!?!

this works with simple sql:

select a."field1" - b."field2" from (select field1 as "field1" from
someTable) as a, (select field2 as "field2" from someOtherTable) as b;

but with my more complex sql, it doesn't. it comes out as a literal string.
it's almost like postgresql forgot to process this column.


select
  cred_vend_acct_table.num as "num" ,
  cred_vend_acct_table.name as "name" ,
  abs_vend_acct_type_table.name as "name" ,
  Debit."cumm_dbt_blnce" - Credit."cumm_crd_blnce" as "undefined" ,
  Debit."cumm_dbt_blnce" as "cumm_dbt_blnce" ,
  Credit."cumm_crd_blnce" as "cumm_crd_blnce" ,
  cred_vend_acct_table.objid as "__OBJID__" ,
  cred_vend_acct_table.clsref as "__CLSREF__"
from
  only cred_vend_acct_table ,
  abs_vend_acct_type_table ,
  (  select
   daily_acct_blnce_table.cumm_dbt_blnce as "cumm_dbt_blnce"
 from
   only daily_acct_blnce_table
 where
  (  (  ( daily_acct_blnce_table.company_objid *= 2147483647 )  )  and
 (  ( daily_acct_blnce_table.status = 'e' )  )  and
 ( daily_acct_blnce_table.abs_acct_objref[2] =
cred_vend_acct_table.objid )  and
 ( daily_acct_blnce_table.abs_acct_objref[1] =
cred_vend_acct_table.clsref )  and
 daily_acct_blnce_table.dte =
   (  select
max(daily_acct_blnce_table.dte) as "dte"
  from
only daily_acct_blnce_table
  where
(  (  ( daily_acct_blnce_table.company_objid *=
147483647 )  )  and
   (  ( daily_acct_blnce_table.status = 'e' )  )  and
   ( daily_acct_blnce_table.abs_acct_objref[2] =
cred_vend_acct_table.objid )  and
   ( daily_acct_blnce_table.abs_acct_objref[1] =
cred_vend_acct_table.clsref )  )  )  )  )
 as Debit ,
 (  select
  daily_acct_blnce_table.cumm_crd_blnce as "cumm_crd_blnce"
from
  only daily_acct_blnce_table
where
  (  (  ( daily_acct_blnce_table.company_objid *= 2147483647 )  )
and
 (  ( daily_acct_blnce_table.status = 'e' )  )  and
 ( daily_acct_blnce_table.abs_acct_objref[2] =
cred_vend_acct_table.objid )  and
 ( daily_acct_blnce_table.abs_acct_objref[1] =
cred_vend_acct_table.clsref )  and
 daily_acct_blnce_table.dte =
   (  select
max(daily_acct_blnce_table.dte) as "dte"
  from
only daily_acct_blnce_table
  where
(  (  ( daily_acct_blnce_table.company_objid *=
2147483647 )  )  and
   (  ( daily_acct_blnce_table.status = 'e' )  )  and
   ( daily_acct_blnce_table.abs_acct_objref[2] =
cred_vend_acct_table.objid )  and
   ( daily_acct_blnce_table.abs_acct_objref[1] =
cred_vend_acct_table.clsref ) ) ) ) )
 as Credit
where
  ( ( ( cred_vend_acct_table.company_objid *= 2147483647 )  and
  ( abs_vend_acct_type_table.company_objid *= 2147483647 )  )  and
( ( cred_vend_acct_table.status = 'e' )  and
  ( abs_vend_acct_type_table.status = 'e' )  )  and
cred_vend_acct_table.owner_objref[1]  = 100110 and
cred_vend_acct_table.owner_objref[2]  = 2147483647 and
(  (  ( cred_vend_acct_table.abs_acct_type_objref[1]  =
abs_vend_acct_type_table.clsref )  and
  ( cred_vend_acct_table.abs_acct_type_objref[2]  =
abs_vend_acct_type_table.objid )  )  )  )
order by 2  asc
limit 100


Regards,

Floyd Shackelford
4 Peaks Technology Group, Inc.
VOICE: 334.735.9428
FAX:   702.995.6462
EMAIL: [EMAIL PROTECTED]
ICQ #: 161371538
PGP Fone at private.fwshackelford.com on request

Shackelford Motto: ACTA NON VERBA - Actions, not words

Alabama StateMotto: AUDEMUS JURA NOSTRA DEFENDERE - We Dare Defend Our
Rights

The Philosophy of Liberty: http://www.isil.org/resources/introduction.swf



---(end of broadcast)---
TIP 5: Have you checked our extensive FAQ?

   http://www.postgresql.org/docs/faqs/FAQ.html


Re: [SQL] column doesn't get calculated - update # 2

2003-07-19 Thread floyds

i was wrong. it doesn't work as a prepared statement nor as a dynamic string
using jdbc.

it works fine if i paste it into psql.

is it possible that a problem with a calculated column and a subselect in
conjunction is a jdbc bug?

Regards,

Floyd Shackelford
4 Peaks Technology Group, Inc.
VOICE: 334.735.9428
FAX:   702.995.6462
EMAIL: [EMAIL PROTECTED]
ICQ #: 161371538
PGP Fone at private.fwshackelford.com on request

Shackelford Motto: ACTA NON VERBA - Actions, not words

Alabama StateMotto: AUDEMUS JURA NOSTRA DEFENDERE - We Dare Defend Our
Rights

The Philosophy of Liberty: http://www.isil.org/resources/introduction.swf



-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Wednesday, July 16, 2003 10:05 AM
To: Pgsql-Sql
Cc: Josh Wardle; Gregory S. Dodson
Subject: RE: column doesn't get calculated - updated



when i copy/paste the select stmt into psql, it works. or if i use it
"dynamically". it doesn't work properly when i use it in a prepared
statement -- which is what i am doing.


Regards,

Floyd Shackelford
4 Peaks Technology Group, Inc.
VOICE: 334.735.9428
FAX:   702.995.6462
EMAIL: [EMAIL PROTECTED]
ICQ #: 161371538
PGP Fone at private.fwshackelford.com on request

Shackelford Motto: ACTA NON VERBA - Actions, not words

Alabama StateMotto: AUDEMUS JURA NOSTRA DEFENDERE - We Dare Defend Our
Rights

The Philosophy of Liberty: http://www.isil.org/resources/introduction.swf



-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Tuesday, July 15, 2003 11:14 AM
To: Pgsql-Sql
Subject: column doesn't get calculated




this must be a problem with my sql, but this one has me stumped. the column:
Debit."cumm_dbt_blnce" - Credit."cumm_crd_blnce" in the long sql statement
below comes out as the literal: Debit."cumm_dbt_blnce" -
Credit."cumm_crd_blnce" rather than as the calculated value. WHY!?!?!

this works with simple sql in psql:

select a."field1" - b."field2" from (select field1 as "field1" from
someTable) as a, (select field2 as "field2" from someOtherTable) as b;

but with my more complex sql, it doesn't. it comes out as a literal string.
it's almost like postgresql forgot to process this column.


select
  cred_vend_acct_table.num as "num" ,
  cred_vend_acct_table.name as "name" ,
  abs_vend_acct_type_table.name as "name" ,
  Debit."cumm_dbt_blnce" - Credit."cumm_crd_blnce" as "undefined" ,
  Debit."cumm_dbt_blnce" as "cumm_dbt_blnce" ,
  Credit."cumm_crd_blnce" as "cumm_crd_blnce" ,
  cred_vend_acct_table.objid as "__OBJID__" ,
  cred_vend_acct_table.clsref as "__CLSREF__"
from
  only cred_vend_acct_table ,
  abs_vend_acct_type_table ,
  (  select
   daily_acct_blnce_table.cumm_dbt_blnce as "cumm_dbt_blnce"
 from
   only daily_acct_blnce_table
 where
  (  (  ( daily_acct_blnce_table.company_objid *= 2147483647 )  )  and
 (  ( daily_acct_blnce_table.status = 'e' )  )  and
 ( daily_acct_blnce_table.abs_acct_objref[2] =
cred_vend_acct_table.objid )  and
 ( daily_acct_blnce_table.abs_acct_objref[1] =
cred_vend_acct_table.clsref )  and
 daily_acct_blnce_table.dte =
   (  select
max(daily_acct_blnce_table.dte) as "dte"
  from
only daily_acct_blnce_table
  where
(  (  ( daily_acct_blnce_table.company_objid *=
147483647 )  )  and
   (  ( daily_acct_blnce_table.status = 'e' )  )  and
   ( daily_acct_blnce_table.abs_acct_objref[2] =
cred_vend_acct_table.objid )  and
   ( daily_acct_blnce_table.abs_acct_objref[1] =
cred_vend_acct_table.clsref )  )  )  )  )
 as Debit ,
 (  select
  daily_acct_blnce_table.cumm_crd_blnce as "cumm_crd_blnce"
from
  only daily_acct_blnce_table
where
  (  (  ( daily_acct_blnce_table.company_objid *= 2147483647 )  )
and
 (  ( daily_acct_blnce_table.status = 'e' )  )  and
 ( daily_acct_blnce_table.abs_acct_objref[2] =
cred_vend_acct_table.objid )  and
 ( daily_acct_blnce_table.abs_acct_objref[1] =
cred_vend_acct_table.clsref )  and
 daily_acct_blnce_table.dte =
   (  select
max(daily_acct_blnce_table.dte) as "dte"
  from
only daily_acct_blnce_table
  where
(  (  ( daily_acct_blnce_table.company_objid *=
2147483647 )  )  and
   (  ( daily_acct_blnce_table.status = 'e' )  )  and
   ( daily_acct_blnce_table.abs_acct_objref[2] =
cred_vend_acct_table.objid )  and
   ( daily_acct_blnce_table.abs_acct_objref[1] =
cred_vend_acct_table.clsref ) ) ) ) )
 as Credit
where
  ( ( ( cred_vend_acct_table.company_objid *= 2147483647 )  and
  ( abs_vend_acct_type_table.company_objid *= 2147483647 )  )  and
( ( cred_vend_acct_table.status = 'e' )  and
  ( abs_vend_acct_type_table.status =

Re: [SQL] column doesn't get calculated - updated

2003-07-19 Thread floyds

when i copy/paste the select stmt into psql, it works. or if i use it
"dynamically". it doesn't work properly when i use it in a prepared
statement -- which is what i am doing.


Regards,

Floyd Shackelford
4 Peaks Technology Group, Inc.
VOICE: 334.735.9428
FAX:   702.995.6462
EMAIL: [EMAIL PROTECTED]
ICQ #: 161371538
PGP Fone at private.fwshackelford.com on request

Shackelford Motto: ACTA NON VERBA - Actions, not words

Alabama StateMotto: AUDEMUS JURA NOSTRA DEFENDERE - We Dare Defend Our
Rights

The Philosophy of Liberty: http://www.isil.org/resources/introduction.swf



-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Tuesday, July 15, 2003 11:14 AM
To: Pgsql-Sql
Subject: column doesn't get calculated




this must be a problem with my sql, but this one has me stumped. the column:
Debit."cumm_dbt_blnce" - Credit."cumm_crd_blnce" in the long sql statement
below comes out as the literal: Debit."cumm_dbt_blnce" -
Credit."cumm_crd_blnce" rather than as the calculated value. WHY!?!?!

this works with simple sql:

select a."field1" - b."field2" from (select field1 as "field1" from
someTable) as a, (select field2 as "field2" from someOtherTable) as b;

but with my more complex sql, it doesn't. it comes out as a literal string.
it's almost like postgresql forgot to process this column.


select
  cred_vend_acct_table.num as "num" ,
  cred_vend_acct_table.name as "name" ,
  abs_vend_acct_type_table.name as "name" ,
  Debit."cumm_dbt_blnce" - Credit."cumm_crd_blnce" as "undefined" ,
  Debit."cumm_dbt_blnce" as "cumm_dbt_blnce" ,
  Credit."cumm_crd_blnce" as "cumm_crd_blnce" ,
  cred_vend_acct_table.objid as "__OBJID__" ,
  cred_vend_acct_table.clsref as "__CLSREF__"
from
  only cred_vend_acct_table ,
  abs_vend_acct_type_table ,
  (  select
   daily_acct_blnce_table.cumm_dbt_blnce as "cumm_dbt_blnce"
 from
   only daily_acct_blnce_table
 where
  (  (  ( daily_acct_blnce_table.company_objid *= 2147483647 )  )  and
 (  ( daily_acct_blnce_table.status = 'e' )  )  and
 ( daily_acct_blnce_table.abs_acct_objref[2] =
cred_vend_acct_table.objid )  and
 ( daily_acct_blnce_table.abs_acct_objref[1] =
cred_vend_acct_table.clsref )  and
 daily_acct_blnce_table.dte =
   (  select
max(daily_acct_blnce_table.dte) as "dte"
  from
only daily_acct_blnce_table
  where
(  (  ( daily_acct_blnce_table.company_objid *=
147483647 )  )  and
   (  ( daily_acct_blnce_table.status = 'e' )  )  and
   ( daily_acct_blnce_table.abs_acct_objref[2] =
cred_vend_acct_table.objid )  and
   ( daily_acct_blnce_table.abs_acct_objref[1] =
cred_vend_acct_table.clsref )  )  )  )  )
 as Debit ,
 (  select
  daily_acct_blnce_table.cumm_crd_blnce as "cumm_crd_blnce"
from
  only daily_acct_blnce_table
where
  (  (  ( daily_acct_blnce_table.company_objid *= 2147483647 )  )
and
 (  ( daily_acct_blnce_table.status = 'e' )  )  and
 ( daily_acct_blnce_table.abs_acct_objref[2] =
cred_vend_acct_table.objid )  and
 ( daily_acct_blnce_table.abs_acct_objref[1] =
cred_vend_acct_table.clsref )  and
 daily_acct_blnce_table.dte =
   (  select
max(daily_acct_blnce_table.dte) as "dte"
  from
only daily_acct_blnce_table
  where
(  (  ( daily_acct_blnce_table.company_objid *=
2147483647 )  )  and
   (  ( daily_acct_blnce_table.status = 'e' )  )  and
   ( daily_acct_blnce_table.abs_acct_objref[2] =
cred_vend_acct_table.objid )  and
   ( daily_acct_blnce_table.abs_acct_objref[1] =
cred_vend_acct_table.clsref ) ) ) ) )
 as Credit
where
  ( ( ( cred_vend_acct_table.company_objid *= 2147483647 )  and
  ( abs_vend_acct_type_table.company_objid *= 2147483647 )  )  and
( ( cred_vend_acct_table.status = 'e' )  and
  ( abs_vend_acct_type_table.status = 'e' )  )  and
cred_vend_acct_table.owner_objref[1]  = 100110 and
cred_vend_acct_table.owner_objref[2]  = 2147483647 and
(  (  ( cred_vend_acct_table.abs_acct_type_objref[1]  =
abs_vend_acct_type_table.clsref )  and
  ( cred_vend_acct_table.abs_acct_type_objref[2]  =
abs_vend_acct_type_table.objid )  )  )  )
order by 2  asc
limit 100


Regards,

Floyd Shackelford
4 Peaks Technology Group, Inc.
VOICE: 334.735.9428
FAX:   702.995.6462
EMAIL: [EMAIL PROTECTED]
ICQ #: 161371538
PGP Fone at private.fwshackelford.com on request

Shackelford Motto: ACTA NON VERBA - Actions, not words

Alabama StateMotto: AUDEMUS JURA NOSTRA DEFENDERE - We Dare Defend Our
Rights

The Philosophy of Liberty: http://www.isil.org/resources/introduction.swf



---(end of broadcast)---
TIP 7: don't forget to increase

[SQL] composite type in a table

2003-08-22 Thread floyds

is there any way to use a composite type in a table?

here's an example:

say i want to create a type to hold currency:

create type currency_type as ( base_objid int, base_amt decimal,
conversion_rate decimal, converted_objid int );


i'd like to be able to define a column in a table of type currency_type:

create table currency_table ( myMoney currency_type );


unfortunately, i get:

ERROR:  Attribute "mymoney" has composite type currency_type


it sure would be nice if it was as simple as this, but it isn't. what's the
easiest way to create a composite-like type that can be added to a table?

also, how does one access the internal fields of a composite type?


Regards,

Floyd Shackelford
VOICE: 334.735.9428
FAX:   702.995.6462
EMAIL: [EMAIL PROTECTED]
ICQ #: 161371538
PGP Key ID: 0x2E84F2F2
PGP Fone at private.fwshackelford.com on request

Shackelford Motto: ACTA NON VERBA - Actions, not words

Alabama State Motto: AUDEMUS JURA NOSTRA DEFENDERE - We Dare Defend Our
Rights

The Philosophy of Liberty: http://www.isil.org/resources/introduction.swf

"Just because you do not take an interest in politics doesn't mean politics
won't take an interest in you."
-- Pericles (430 B.C.)

"I cannot undertake to lay my finger on that article of the Constitution
which granted a right to Congress of expending, on objects of benevolence,
the money of their constituents"
--James Madison



---(end of broadcast)---
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]


[SQL] recursive sql

2003-09-05 Thread floyds

can anyone recommend a good reference source for doing recursive sql on
postgresql? i want to do something similar to a BOM expansion. (i.e. i need
to traverse a self-referencing table that stores a tree structure and answer
a question like "Get me A and all of A's descendents")

Regards,

Floyd Shackelford
4 Peaks Technology Group, Inc.
VOICE: 334.735.9428
FAX:   702.995.6462
EMAIL: [EMAIL PROTECTED]
ICQ #: 161371538
PGP Key ID: 0x2E84F2F2
PGP Fone at private.fwshackelford.com on request

Shackelford Motto: ACTA NON VERBA - Actions, not words

Alabama StateMotto: AUDEMUS JURA NOSTRA DEFENDERE - We Dare Defend Our
Rights

The Philosophy of Liberty: http://www.isil.org/resources/introduction.swf

"We have allowed our constitutional republic to deteriorate into a virtually
unchecked direct democracy. Today's political process is nothing more than a
street fight between various groups seeking to vote themselves other
people's money. Individual voters tend to support the candidate that
promises them the most federal loot in whatever form, rather than the
candidate who will uphold the rule of law." --Rep. Ron Paul


---(end of broadcast)---
TIP 9: the planner will ignore your desire to choose an index scan if your
  joining column's datatypes do not match


[SQL] contrib/ltree

2003-09-09 Thread floyds

how do i get jdbc to recognize the ltree type that comes with the
contrib/ltree extension?

This:

  Object object = resultSet.getObject(columnNumber);

generates the following exception:

  Exception caused by: No class found for ltree
at
org.postgresql.jdbc1.AbstractJdbc1Connection.getObject(AbstractJdbc1Connecti
on.java:693)
at
org.postgresql.jdbc2.AbstractJdbc2Connection.getObject(AbstractJdbc2Connecti
on.java:117)
at
org.postgresql.jdbc2.AbstractJdbc2ResultSet.getObject(AbstractJdbc2ResultSet
.java:147)
  ...


Regards,

Floyd Shackelford
4 Peaks Technology Group, Inc.
VOICE: 334.735.9428
FAX:   702.995.6462
EMAIL: [EMAIL PROTECTED]
ICQ #: 161371538
PGP Key ID: 0x2E84F2F2
PGP Fone available on request at private.fwshackelford.com

Shackelford Motto: ACTA NON VERBA - Actions, not words

Alabama State Motto: AUDEMUS JURA NOSTRA DEFENDERE - We Dare Defend Our
Rights

The Philosophy of Liberty: http://www.isil.org/resources/introduction.swf

"We have allowed our constitutional republic to deteriorate into a virtually
unchecked direct democracy. Today's political process is nothing more than a
street fight between various groups seeking to vote themselves other
people's money. Individual voters tend to support the candidate that
promises them the most federal loot in whatever form, rather than the
candidate who will uphold the rule of law." --Rep. Ron Paul


---(end of broadcast)---
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])