[GENERAL] [ask] Return Query

2009-03-15 Thread ataherster

hai all, i'm trying create function like this

CREATE OR REPLACE FUNCTION penjualan(idcb integer)
 RETURNS SETOF penjualan AS
$BODY$
BEGIN

IF ($1 IS NULL) THEN
 return query SELECT * FROM PENJUALAN;
ELSE
 return query SELECT * FROM PENJUALAN WHERE IDCABANG=$1;
END IF;

END;
$BODY$
 LANGUAGE 'plpgsql' VOLATILE
 COST 100
 ROWS 1000;

but this function is not work with this error : 
ERROR:  structure of query does not match function result type

CONTEXT:  PL/pgSQL function penjualan line 6 at RETURN QUERY

on the time i try with other table and working well

thanks for your help



--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[GENERAL] to_hex leading zeroes

2009-03-15 Thread Pedro Doria Meunier
Hi All,

I'm in a bit of a pickle here with the to_hex function not returning leading 
zeroes ...
For instance if I:
SELECT to_hex(10);

it returns 'a' not '0a' .

Any ideas on how to overcome this?

TIA,

Pedro Doria Meunier
GSM: +351961720188
Skype: pdoriam



signature.asc
Description: This is a digitally signed message part.


Re: [GENERAL] to_hex leading zeroes

2009-03-15 Thread Scott Marlowe
On Sun, Mar 15, 2009 at 6:47 AM, Pedro Doria Meunier
pdo...@netmadeira.com wrote:
 Hi All,

 I'm in a bit of a pickle here with the to_hex function not returning leading
 zeroes ...
 For instance if I:
 SELECT to_hex(10);

 it returns 'a' not '0a' .

Have you looked at lpad()?

-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Re: [GENERAL] [ask] Return Query

2009-03-15 Thread Justin

ataherster wrote:

hai all, i'm trying create function like this

CREATE OR REPLACE FUNCTION penjualan(idcb integer)
 RETURNS SETOF penjualan AS


but this function is not work with this error : ERROR:  structure of 
query does not match function result type

CONTEXT:  PL/pgSQL function penjualan line 6 at RETURN QUERY

on the time i try with other table and working well

thanks for your help 
This is because Postgresql does  know the structure of the data to be 
returned.  So the choice either use OUT command  like so  
http://www.postgresql.org/docs/current/static/plpgsql-declarations.html


Create or Replace Function penjualan(idcb, integer, OUT f1 text, OUT f2 
integer) Returns SETOF penjualan AS


Or create a new data type describing the data structure   
http://www.postgresql.org/docs/8.3/static/sql-createtype.html


Create Type myTable as ( f1 text, f2 integer)

Create or Replace Function penjualan(idcb, integer) Returns SETOF 
myTable  AS





--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Re: [GENERAL] ODBC limitation??

2009-03-15 Thread Carl Sopchak


On Saturday, March 14, 2009, Adrian Klaver wrote:
 On Saturday 14 March 2009 5:40:40 pm Carl Sopchak wrote:
  When I run the following query through psql, it executes successfully.
  However, when I run it through ODBC (via OpenOffice Base), I get the
  error
 
  SQL Status: HY000
  Error code: 1000
 
  syntax error, unexpected $end, expecting BETWEEN or IN or SQL_TOKEN_LIKE
 
  Is this some limitation of ODBC?  (I don't think so, so I'm going to ask
  on the OpenOffice lists, but thought I'd check here, too...)
 
  Query:
 
  select number_of_years,
  max(case when trial_id = 1 then period_results else null end) as
  MaxResults1, min(case when trial_id = 1 then period_results else null
  end) as MaxResults1, max(case when trial_id = 2 then period_results else
  null end) as MaxResults2, min(case when trial_id = 2 then period_results
  else null end) as MaxResults2 from trial_results
  where trial_id in (1,2)
  group by number_of_years
  order by number_of_years;
 
 
  This is on Linux, Fedora 8, using PostgreSQL 8.3.6 and unixODBC...
 
  Thanks for the help,
 
  Carl

 This is an OO problem, at some point OO Base translates ODBC and JDBC
 queries into its native SDBC format and it has some parser limitations. To
 get this to run you will have to turn of the query builder and just run it
 as a pass through query.

Thanks for the suggestion.  I've searched for hours trying to find how to 
force pass-through with no luck.  Got any ideas?

Thanks for the help,

Carl

-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Re: [GENERAL] ODBC limitation??

2009-03-15 Thread Carl Sopchak


On Saturday, March 14, 2009, Dann Corbit wrote:
  -Original Message-
  From: pgsql-general-ow...@postgresql.org [mailto:pgsql-general-
  ow...@postgresql.org] On Behalf Of Carl Sopchak
  Sent: Saturday, March 14, 2009 5:41 PM
  To: pgsql-general@postgresql.org
  Subject: [GENERAL] ODBC limitation??
 
  When I run the following query through psql, it executes successfully.
  However, when I run it through ODBC (via OpenOffice Base), I get the
  error
 
  SQL Status: HY000
  Error code: 1000
 
  syntax error, unexpected $end, expecting BETWEEN or IN or
  SQL_TOKEN_LIKE
 
  Is this some limitation of ODBC?  (I don't think so, so I'm going to
  ask on
  the OpenOffice lists, but thought I'd check here, too...)
 
  Query:
 
  select number_of_years,
  max(case when trial_id = 1 then period_results else null end) as
  MaxResults1,
  min(case when trial_id = 1 then period_results else null end) as
  MaxResults1,
  max(case when trial_id = 2 then period_results else null end) as
  MaxResults2,
  min(case when trial_id = 2 then period_results else null end) as
  MaxResults2
  from trial_results
  where trial_id in (1,2)
  group by number_of_years
  order by number_of_years;
 
 
  This is on Linux, Fedora 8, using PostgreSQL 8.3.6 and unixODBC...

 I am not speaking with specific knowledge about the official PostgreSQL
 ODBC driver, but support for the above grammar is not demanded by the
 actual ODBC specification.  Many ODBC drivers have a pass-through mode.
 You might check the documentation for the official driver and see if it
 has one.  Any query that will work from PSQL will work in pass-through
 mode.

Thanks for the suggestion.

Frankly, I'm quite surprised that the ODBC driver specification talks at all 
about SQL grammar, although I have absolutely no knowledge of the 
specification.  I would think that the commands traveling over ODBC would not 
be interpreted by ODBC at all.  Why would it need to?

Also, the above grammar is standard SQL, if I'm not mistaken.  If the ODBC 
spec talks about grammar, I would think that it would support such a 
widely-used standard...

In any case, I've been searching for how to turn on pass-through to no avail.  
Got any pointers?

Thanks for the help,

Carl

-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Re: [GENERAL] ODBC limitation??

2009-03-15 Thread Carl Sopchak


On Saturday, March 14, 2009, Adrian Klaver wrote:
 On Saturday 14 March 2009 5:40:40 pm Carl Sopchak wrote:
  When I run the following query through psql, it executes successfully.
  However, when I run it through ODBC (via OpenOffice Base), I get the
  error
 
  SQL Status: HY000
  Error code: 1000
 
  syntax error, unexpected $end, expecting BETWEEN or IN or SQL_TOKEN_LIKE
 
  Is this some limitation of ODBC?  (I don't think so, so I'm going to ask
  on the OpenOffice lists, but thought I'd check here, too...)
 
  Query:
 
  select number_of_years,
  max(case when trial_id = 1 then period_results else null end) as
  MaxResults1, min(case when trial_id = 1 then period_results else null
  end) as MaxResults1, max(case when trial_id = 2 then period_results else
  null end) as MaxResults2, min(case when trial_id = 2 then period_results
  else null end) as MaxResults2 from trial_results
  where trial_id in (1,2)
  group by number_of_years
  order by number_of_years;
 
 
  This is on Linux, Fedora 8, using PostgreSQL 8.3.6 and unixODBC...
 
  Thanks for the help,
 
  Carl

 This is an OO problem, at some point OO Base translates ODBC and JDBC
 queries into its native SDBC format and it has some parser limitations. To
 get this to run you will have to turn of the query builder and just run it
 as a pass through query.

Using Pass-Through did the trick.  Thanks for the help!

Carl

P.S.,  In OpenOffice, on the SQL view window, there's a button with a box 
and SQL in it.  Activating that turns on pass-through.

-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Re: [GENERAL] [ask] Return Query

2009-03-15 Thread Tom Lane
ataherster atahers...@yahoo.co.id writes:
 ... but this function is not work with this error : 
 ERROR:  structure of query does not match function result type
 CONTEXT:  PL/pgSQL function penjualan line 6 at RETURN QUERY

This looks like a known limitation in plpgsql: it's not very good with
rowtypes that contain dropped columns.  Have you dropped some columns
in table PENJUALAN?  If so, try remaking the table from scratch.

regards, tom lane

-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[GENERAL] Best-N aggregates

2009-03-15 Thread Oliver Kennedy

Hi,

I'm looking to write an aggregate of the form

compute_over_best_n ( A, B )

where I'm trying to compute a value over the first n (where n is data- 
dependent) values in the input table, sorted over column A.  Column B  
contains supplemental information used to determine n (that is, when  
to stop the aggregate).  My first thought was to pass a sortop to  
CREATE AGGREGATE, but the fact that I need column B prevents me from  
using a sort.  Is there any way to trick postgres into only sorting  
over the first parameter, without getting rid of the second?  Thanks.


- Oliver Kennedy

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[GENERAL] Scanning a large binary field

2009-03-15 Thread Kynn Jones
I have a C program that reads a large binary file, and uses the read
information plus some user-supplied arguments to generate an in-memory data
structure that is used during the remainder of the program's execution.  I
would like to adapt this code so that it gets the original binary data from
a Pg database rather than a file.
One very nice feature of the original scheme is that the reading of the
original file was done piecemeal, so that the full content of the file
(which is about 0.2GB) was never in memory all at once, which kept the
program's memory footprint nice and small.

Is there any way to replicate this small memory footprint if the program
reads the binary data from a Pg DB instead of from a file?

FWIW, my OS is Linux.

TIA!

Kynn


Re: [GENERAL] Scanning a large binary field

2009-03-15 Thread John R Pierce

Kynn Jones wrote:
I have a C program that reads a large binary file, and uses the read 
information plus some user-supplied arguments to generate an in-memory 
data structure that is used during the remainder of the program's 
execution.  I would like to adapt this code so that it gets the 
original binary data from a Pg database rather than a file.


One very nice feature of the original scheme is that the reading of 
the original file was done piecemeal, so that the full content of the 
file (which is about 0.2GB) was never in memory all at once, which 
kept the program's memory footprint nice and small.


Is there any way to replicate this small memory footprint if the 
program reads the binary data from a Pg DB instead of from a file?


is this binary data in any way record or table structured such that it 
could be stored as multiple rows and perrhaps fields?if not, why 
would you want to put a 200MB blob of amorphous data into a relational 
database?




--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Re: [GENERAL] Scanning a large binary field

2009-03-15 Thread Kynn Jones
On Sun, Mar 15, 2009 at 5:06 PM, John R Pierce pie...@hogranch.com wrote:

 Kynn Jones wrote:

 I have a C program that reads a large binary file, and uses the read
 information plus some user-supplied arguments to generate an in-memory data
 structure that is used during the remainder of the program's execution.  I
 would like to adapt this code so that it gets the original binary data from
 a Pg database rather than a file.

 One very nice feature of the original scheme is that the reading of the
 original file was done piecemeal, so that the full content of the file
 (which is about 0.2GB) was never in memory all at once, which kept the
 program's memory footprint nice and small.

 Is there any way to replicate this small memory footprint if the program
 reads the binary data from a Pg DB instead of from a file?


 is this binary data in any way record or table structured such that it
 could be stored as multiple rows and perrhaps fields?if not, why would
 you want to put a 200MB blob of amorphous data into a relational database?


That's a fair question.  The program in question already gets from the
relational database most of the external data it needs.  The only exception
to this is these large amorphous blobs, as you describe them.  My only
reason for wanting to put the blobs in the DB as well is to consolidate all
the external data sources for the program.

Kynn


Re: [GENERAL] Scanning a large binary field

2009-03-15 Thread John R Pierce

Kynn Jones wrote:
That's a fair question.  The program in question already gets from the 
relational database most of the external data it needs.  The only 
exception to this is these large amorphous blobs, as you describe 
them.  My only reason for wanting to put the blobs in the DB as well 
is to consolidate all the external data sources for the program.


well, look at the LO (large object) facility of postgres.   this is 
available to apps that call libpq directly, I have no idea if any of the 
generic 'portable' APIs would have any such hooks.




--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[GENERAL] Re: [Pkg-postgresql-public] Postgres major version support policy on Debian

2009-03-15 Thread Cédric Villemain
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Martin Pitt a écrit :
 Gerfried Fuchs [2008-10-06 17:04 +0200]:
  I'm sorry to have done the addition of pg 8.2 initially, and propably
 should also be sorry for adding pg 8.3 to backports.org, I thought it
 would be a service to the users, 
 
 It is, and I think that -8.3 in backports makes perfect sense. 
 It is what Lenny will ship with, and thus will be maintained for the
 next couple of years.
 
 (If it helps, I'll do -8.3 package maintenance for the next 5 years
 for Ubuntu 8.04 LTS)
 
 Martin
 

Any plan for 8.4 pre-beta package ? (Devrim Gunduz provide usefull rpm package,
I'd like to have the same in debian).

Can it be in the experimental repository ?

- --
Cédric Villemain
Administrateur de Base de Données
Cel: +33 (0)6 74 15 56 53
http://dalibo.com - http://dalibo.org
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEARECAAYFAkm9h/kACgkQo/dppWjpEvx9SACfVd+hFon1lRqe41sDS9avjAsU
pYcAnRz89iHwyqwDpHVrRRO4Wz9aKoM5
=sPVB
-END PGP SIGNATURE-

-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Re: [GENERAL] Maximum transaction rate

2009-03-15 Thread Marco Colombo
Joshua D. Drake wrote:
 
 I understand but disabling cache is not an option for anyone I know. So
 I need to know the other :)
 
 Joshua D. Drake
 

Come on, how many people/organizations do you know who really need 30+ MB/s
sustained write throughtput in the disk subsystem but can't afford a
battery backed controller at the same time?

Something must take care of writing data in the disk cache on permanent
storage; write-thru caches, battery backed controllers, write barriers
are all alternatives, choose the one you like most.

The problem here is fsync(). We know that not fsync()'ing gives you a big
performance boost, but that's not the point. I want to choose, and I want
a true fsync() when I ask for one. Because if the data don't make it to
the disk cache, the whole point about wt, bb and wb is moot.

.TM.

-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[GENERAL] Oracle to PostgreSQL

2009-03-15 Thread Greenhorn
Hi,

I have almost 1300 files from Oracle (no access to oracle server).  I
have to create the tables and data as follows.

-- start script

-- file name:  aa_asset_type.sql

CREATE TABLE AS_ASSET_TYPE
(
  MAIN_TYPE CHAR(3) NOT NULL,
  SUB_TYPE  NUMBER(3)   NOT NULL,
  DESCRIPTION   VARCHAR2(25)DEFAULT ' '
   NOT NULL,
  SERVICE_SCHEDULE  VARCHAR2(8) DEFAULT ' '
   NOT NULL,
  PRODUCT_CODE  CHAR(4) DEFAULT ' '
   NOT NULL
);

GRANT ALTER, DELETE, INDEX, INSERT, REFERENCES, SELECT, UPDATE ON
GENADMIN.AS_ASSET_TYPE TO PUBLIC;

INSERT INTO AS_ASSET_TYPE ( MAIN_TYPE, SUB_TYPE, DESCRIPTION, SERVICE_SCHEDULE,
PRODUCT_CODE ) VALUES (
'000', 0, ' ', ' ', '');
INSERT INTO AS_ASSET_TYPE ( MAIN_TYPE, SUB_TYPE, DESCRIPTION, SERVICE_SCHEDULE,
PRODUCT_CODE ) VALUES (
'001', 0, ' ', ' ', '');
INSERT INTO AS_ASSET_TYPE ( MAIN_TYPE, SUB_TYPE, DESCRIPTION, SERVICE_SCHEDULE,
PRODUCT_CODE ) VALUES (
'100', 0, 'BUILDINGS', ' ', '');

-- file name:  as_master.sql

CREATE TABLE AS_MASTER
(
  ASSET_NO VARCHAR2(16) DEFAULT ' '
   NOT NULL,
  FUND CHAR(1)  NOT NULL,
  FINAL_ACCOUNT_NO NUMBER(6)NOT NULL,
  ITEM_NO  NUMBER(6)NOT NULL,
  SUB_NO   NUMBER(6)NOT NULL,
  TYPE NUMBER(6)DEFAULT 0
   NOT NULL,
  SUB_TYPE NUMBER(6)DEFAULT 0
   NOT NULL,
  LOCATION NUMBER(6)DEFAULT 0
   NOT NULL,
  SUB_LOCATION NUMBER(6)DEFAULT 0
   NOT NULL,
  LEVEL_A  VARCHAR2(4)  DEFAULT ' '
   NOT NULL,
  LEVEL_B  VARCHAR2(4)  DEFAULT ' '
   NOT NULL,
  LEVEL_C  VARCHAR2(4)  DEFAULT ' '
   NOT NULL,
  LEVEL_D  VARCHAR2(4)  DEFAULT ' '
   NOT NULL,
  LEVEL_E  VARCHAR2(4)  DEFAULT ' '
   NOT NULL,
  OPENING_ACQ_VALUENUMBER(15,2) DEFAULT 0
   NOT NULL,
  OPENING_ACQ_QTY  NUMBER(12)   DEFAULT 0
   NOT NULL,
  WITHDRAWAL_VALUE NUMBER(15,2) DEFAULT 0
   NOT NULL,
  WITHDRAWAL_QTY   NUMBER(12)   DEFAULT 0
   NOT NULL,
  PROFIT_LOSS_VALUENUMBER(15,2) DEFAULT 0
   NOT NULL,
  DEPREC_VALUE NUMBER(15,2) DEFAULT 0
   NOT NULL,
  PROFIT_LOSS_YTD  NUMBER(15,2) DEFAULT 0
   NOT NULL,
  DEPREC_YTD   NUMBER(15,2) DEFAULT 0
   NOT NULL,
  DEPREC_LAST_MONTHNUMBER(6)DEFAULT 0
   NOT NULL,
  DEPREC_LAST_YEAR NUMBER(6)DEFAULT 0
   NOT NULL,
  DEPREC_METHODCHAR(1)  DEFAULT ' '
   NOT NULL,
  DEPREC_RATE_2NUMBER(15,6) DEFAULT 0
   NOT NULL,
  DEPREC_ROUND_FACTOR  NUMBER(6)DEFAULT 0
   NOT NULL,
  DEPREC_FREQUENCY CHAR(1)  DEFAULT ' '
   NOT NULL,
  DEPREC_MINIMUM_VAL   NUMBER(12)   DEFAULT 0
   NOT NULL,
  DEPREC_TYPE  NUMBER(6)DEFAULT 0
   NOT NULL,
  DEPREC_FOLIO_DR  VARCHAR2(8)  DEFAULT ' '
   NOT NULL,
  DEPREC_FOLIO_CR  VARCHAR2(8)  DEFAULT ' '
   NOT NULL,
  INSURANCE_VALUE  NUMBER(12)   DEFAULT 0
   NOT NULL,
  INSURANCE_CATEGORY   VARCHAR2(2)  DEFAULT ' '
   NOT NULL,
  INSURANCE_POLICY VARCHAR2(10) DEFAULT ' '
   NOT NULL,
  INSURANCE_CODE   CHAR(1)  DEFAULT ' '
   NOT NULL,
  ASSET_FILE_NOVARCHAR2(10) DEFAULT ' '
   NOT NULL,
  PROPERTY_REF VARCHAR2(20) DEFAULT ' '
   NOT NULL,
  LAST_AUDIT_DATE  DATE NULL,
  LAST_AUDIT_PAGE  NUMBER(6)DEFAULT 0
   NOT NULL,
  DESCRIPTION_1VARCHAR2(40) DEFAULT ' '
   NOT NULL,
  DESCRIPTION_2VARCHAR2(40) DEFAULT ' '
   NOT NULL
);


GRANT ALTER, DELETE, INDEX, INSERT, REFERENCES, SELECT, UPDATE ON
GENADMIN.AS_MASTER TO PUBLIC;

ALTER TABLE GENADMIN.AS_MASTER ADD (
  PRIMARY KEY
 (ASSET_NO));

INSERT INTO AS_MASTER ( ASSET_NO, FUND, FINAL_ACCOUNT_NO, ITEM_NO,
SUB_NO, TYPE, SUB_TYPE,
LOCATION, SUB_LOCATION, LEVEL_A, LEVEL_B, LEVEL_C, LEVEL_D, LEVEL_E,
OPENING_ACQ_VALUE,
OPENING_ACQ_QTY, WITHDRAWAL_VALUE, WITHDRAWAL_QTY, PROFIT_LOSS_VALUE,
DEPREC_VALUE, PROFIT_LOSS_YTD,
DEPREC_YTD, DEPREC_LAST_MONTH, DEPREC_LAST_YEAR, DEPREC_METHOD,
DEPREC_RATE_2, DEPREC_ROUND_FACTOR,
DEPREC_FREQUENCY, DEPREC_MINIMUM_VAL, DEPREC_TYPE, DEPREC_FOLIO_DR,
DEPREC_FOLIO_CR,
INSURANCE_VALUE, INSURANCE_CATEGORY, INSURANCE_POLICY, INSURANCE_CODE,
ASSET_FILE_NO, PROPERTY_REF,
LAST_AUDIT_DATE, LAST_AUDIT_PAGE, DESCRIPTION_1, 

Re: [GENERAL] Oracle to PostgreSQL

2009-03-15 Thread John R Pierce

Greenhorn wrote:

Unfortunately When I execute the above files using \i I am getting errors like

ERROR:  syntax error at or near (
LINE 4:   SUB_TYPE  NUMBER(3)   NOT NULL,

Obviously 'number' is not PostgreSQL data type so is 'varchar2'.  What
is your suggestion to create these tables in PostgreSQL?  Should I
pre-process using Sed/Awk to find/replace the field type first?  Any
recommendation is greatly appreciated :)
  


change number to numeric, and varchar2 to char and you'll likely be good.



--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Re: [GENERAL] Oracle to PostgreSQL

2009-03-15 Thread Thomas Kellerer

John R Pierce wrote on 16.03.2009 00:41:

Greenhorn wrote:
Unfortunately When I execute the above files using \i I am getting 
errors like


ERROR:  syntax error at or near (
LINE 4:   SUB_TYPE  NUMBER(3)   NOT NULL,

Obviously 'number' is not PostgreSQL data type so is 'varchar2'.  What
is your suggestion to create these tables in PostgreSQL?  Should I
pre-process using Sed/Awk to find/replace the field type first?  Any
recommendation is greatly appreciated :)
  


change number to numeric, and varchar2 to char and you'll likely be good.




My guess would have been that varchar is the equivalent to varchar2

char does a blank padding and is different in behaviour to varchar (as it is in 
Oracle)


Thomas





--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Re: [GENERAL] Oracle to PostgreSQL

2009-03-15 Thread John R Pierce

Thomas Kellerer wrote:


change number to numeric, and varchar2 to char and you'll likely be 
good.





My guess would have been that varchar is the equivalent to varchar2

char does a blank padding and is different in behaviour to varchar (as 
it is in Oracle)



geez, yeah, what you said!BTDT, and had the t-shirt.i think ill 
have another beer now.





--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[GENERAL] PostgreSQL on Webmin

2009-03-15 Thread Kostadin Solakov
Hi there!

 

I just installed Webmin on my dedicated server and I really had hard time
making all configuration that were needed to migrate my site. Anyway, now
everything is working except for one thing. I can't connect to the database
through PHP. Remote connection is working fine, but local doesn't. 

The connection string looks like this:

 

pg_connect('host=localhost port=5432 user=user password=pass dbname=db')

 

I made the necessary changes in postgresql.conf

listen_addresses = '*'

port=5432

 

And I added this in pg_nba.conf: 

 

local   all all  trust

local   all user ident sameuser

local   dbuser password

 

But still I cannot connect using php. The connection file is the same as it
was on my previous host (shared one) so it's supposed to be working.

I created the same  database and user.

 

Any idea?

 

Thanks in advance!

 

 

Kostadin Solakov

 

GSM +389 75 470 503

Email: kostadin.sola...@gmail.com

Skype: kostadin.solakov

MSN: sola...@hotmail.com

LinkedIn: http://www.linkedin.com/kostadinsolakov

 

 



Re: [GENERAL] PostgreSQL on Webmin

2009-03-15 Thread John R Pierce

Kostadin Solakov wrote:


Hi there!

I just installed Webmin on my dedicated server and I really had hard 
time making all configuration that were needed to migrate my site. 
Anyway, now everything is working except for one thing. I can’t 
connect to the database through PHP. Remote connection is working 
fine, but local doesn’t.


The connection string looks like this:

pg_connect('host=localhost port=5432 user=user password=pass dbname=db')

I made the necessary changes in postgresql.conf

listen_addresses = '*'

port=5432

And I added this in pg_nba.conf:

local all all trust

local all user ident sameuser

local db user password

But still I cannot connect using php. The connection file is the same 
as it was on my previous host (shared one) so it’s supposed to be working.


I created the same database and user.




the first local all all takes precedence as that matches any local 
(domain socket) connections. as is, you're saying any process running 
your server can connect to any database as any user with no 
authorization required.


however, none of those lines affect localhost IP connections, those 
instead would match a `host  127.0.0.1/32 `




I most typically use the following...

local all all ident sameuser # allow local domain connections to 
authenticate only as themselves
host all all 127.0.0.1/32 md5 # allow localhost IP connections to 
authenticate with passwords only


and sometimes...

host all all my.ip.sub.net/24 md5 # allow any user on my IP subnet to 
authneticate with passwords





--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[GENERAL] Is there any defect when use null column in postgresql?

2009-03-15 Thread leopay
I wanna if there is any defact when use null column in postgresql,
e.g. performance issue


[GENERAL] is there any defect when use null column in postgresql?

2009-03-15 Thread leopay
I wanna if there is any defact when use null column in pg,
e.g. performance issue


Re: [GENERAL] is there any defect when use null column in postgresql?

2009-03-15 Thread Scott Marlowe
On Sun, Mar 15, 2009 at 9:00 PM, leopay leo...@gmail.com wrote:
 I wanna if there is any defact when use null column in pg,
 e.g. performance issue

none that I know of.  Any more specific scenarios you're wondering about?

-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Re: [GENERAL] is there any defect when use null column in postgresql?

2009-03-15 Thread leopay
On Mon, Mar 16, 2009 at 11:36 AM, Scott Marlowe scott.marl...@gmail.comwrote:

 On Sun, Mar 15, 2009 at 9:00 PM, leopay leo...@gmail.com wrote:
  I wanna if there is any defact when use null column in pg,
  e.g. performance issue

 none that I know of.  Any more specific scenarios you're wondering about?

when do the query, the column contain none value could use the index?


Re: [GENERAL] is there any defect when use null column in postgresql?

2009-03-15 Thread Scott Marlowe
On Sun, Mar 15, 2009 at 9:39 PM, leopay leo...@gmail.com wrote:


 On Mon, Mar 16, 2009 at 11:36 AM, Scott Marlowe scott.marl...@gmail.com
 wrote:

 On Sun, Mar 15, 2009 at 9:00 PM, leopay leo...@gmail.com wrote:
  I wanna if there is any defact when use null column in pg,
  e.g. performance issue

 none that I know of.  Any more specific scenarios you're wondering about?

 when do the query, the column contain none value could use the index?

Older versions, no, modern versions yes.  When that changed, I don't
know, as I'm running only 8.3 anymore.

-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[GENERAL] pg_ctl issue

2009-03-15 Thread Jack W
I installed PostgreSql on Window2003 server under an administrator account.
I can start postgresql from Windows Service.
But when run the following command, it fails:

C:\Program Files\PostgreSQL\8.3\binpg_ctl start -D C:\Program
Files\PostgreSQL\8.3\data
server starting

C:\Program Files\PostgreSQL\8.3\binFATAL:  postgres: could not locate
matching postgres executable


And the following command works well:

C:\Program Files\PostgreSQL\8.3\binpg_ctl stop -D C:\Program
Files\PostgreSQL\8.3\data


Thanks.

Jack


[Fwd: Re: [GENERAL] [ask] Return Query]

2009-03-15 Thread ataherster


---BeginMessage---

thanks Justin, my problem resolved, but i trying to re-create table and 
function, i'm using PGAdmin III to Create Script
table and function before delete my table and function, after that I run Create 
Sript without change my script
and working well

my question is : whether that bug in postgreSQL? 



I feel afraid if will happen again like this by itself

thanks before for your help

Note : I'm sory about my english, my english is very bad


Justin wrote:


ataherster wrote:
  

hai all, i'm trying create function like this

CREATE OR REPLACE FUNCTION penjualan(idcb integer)

 RETURNS SETOF penjualan AS


but this function is not work with this error : ERROR:  structure of 
query does not match function result type

CONTEXT:  PL/pgSQL function penjualan line 6 at RETURN QUERY

on the time i try with other table and working well

thanks for your help 

This is because Postgresql does  know the structure of the data to be 
returned.  So the choice either use OUT command  like so  
http://www.postgresql.org/docs/current/static/plpgsql-declarations.html
  
Create or Replace Function penjualan(idcb, integer, OUT f1 text, OUT f2 
integer) Returns SETOF penjualan AS
  
Or create a new data type describing the data structure   
http://www.postgresql.org/docs/8.3/static/sql-createtype.html
  
Create Type myTable as ( f1 text, f2 integer)
  
Create or Replace Function penjualan(idcb, integer) Returns SETOF 
myTable  AS
  
  
  



---End Message---

-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general