Re: [SQL] Question about SQL Control Structure(if then, for loop)

2006-05-17 Thread A. Kretschmer
am 16.05.2006, um 21:51:45 -0400 mailte Jay Chiu folgendes: > Can someone tell me how to use if/for in psql? The document In plain SQL isn't if, then, else and so on. > shows the control structures in the PL/pgSQL section. Must I use > if/for inside some procedure/function? Yes. HTH, Andreas

Re: [SQL] Add column and specify the column position in a table

2006-05-17 Thread Guillaume LELARGE
Emi Lu a écrit : > I am trying to insert one column to a specific position in a table. > > In mysql, I can do: > . create table test(id varchar(3), name varchar(12)); > . alter table test add column givename varchar(12) after id; > > > I am looking for similar things in postgresql to add a new c

[SQL] Question about SQL Control Structure(if then, for loop)

2006-05-17 Thread Jay Chiu
Hello, I am new to PostgreSQL and want to use the IF-THEN; LOOP statements in my SQL command file. Thus I may use psql -f cfile to exceute. However I always got syntax error on if/for in psql. For example: RDM=# for i in 1 .. 10 loop RDM-# select "test" RDM-# end loop; ERROR: syntax error at or

[SQL] table constraint + INSERT

2006-05-17 Thread Risto Tamme
Title: table constraint + INSERT Hello I use PostgreSQL in my program and I found a strange behavior, at least for me. I have a simple table with constraint CREATE TABLE "PART" (   "P_PARTKEY" int4 NOT NULL,   "P_RETAILPRICE" numeric,   CONSTRAINT "PART_PRIMARY" PRIMARY KEY ("P_PARTKEY"),

Re: [SQL] [pgsql-www] MySQL DB to PostgresSQL DB

2006-05-17 Thread Jeff MacDonald
greetings, I don't know if pgsql-www is the right place for your questions or not, but I'll be nice and give you a few ideas on how to get your questions answered.. :) On Tue, 2006-05-16 at 00:19 +0200, Jose Apablaza wrote: > Dear all, > > This is my first post and I will try to be short and cl

[SQL] how referencing %rowtype variables without column names

2006-05-17 Thread lingyu . tseng
I wrote a trigger and use %rowtype , the problue is I need to put the column name in a variable like Declare columnname VARCHAR(20); NOTIFYRULE NOTIFY_RULE%ROWTYPE begin columnname='TYPE' /* ONE OF NOTIFY_RULE column*/ SELECT * INTO NOTIFYRULE FROM NOTIFY_RULE WHERE STATUS=:OLD.STATUS; end; ho

[SQL] MySQL DB to PostgresSQL DB

2006-05-17 Thread Jose Apablaza
Dear all, This is my first post and I will try to be short and clear in my questions and I hope you can help me with that. I have a MySQL DB and I want to export to PostgreSQL DB. My questions are; - Is posible to export MySQL DB to PostgreSQL DB? - Does PostgreSQL DB has tools to import MySQL DB?

[SQL] insert related data into two tables

2006-05-17 Thread filippo2991
Hello, I have two tables like these: TABLE_1: people registry fields: ID_T1, SURNAME, NAME ID_T1 is primary key TABLE_2: work groups fields: ID_T2, TASK ID_T2 is foreign key related to ID_T1 the first table is the list of employees, the second the task. Sometime I need to insert a new employe

[SQL] help..postgresql mulyiple return values

2006-05-17 Thread Michael Joseph Tan
hi, im new in postgresql, generally new in databases.   im trying to make a function using PGAdminIII which returns several types, example, my query is:   "select count(id) as requests, organization from connection_requests group by organization"   id is of type int8, organization is of ty

[SQL] Add column and specify the column position in a table

2006-05-17 Thread Emi Lu
Hello, I am trying to insert one column to a specific position in a table. In mysql, I can do: . create table test(id varchar(3), name varchar(12)); . alter table test add column givename varchar(12) after id; I am looking for similar things in postgresql to add a new column to the correct po

Re: [SQL] Table constraints and INSERT

2006-05-17 Thread Tom Lane
Niklas Johansson <[EMAIL PROTECTED]> writes: > You must cast the integer column to a float or numeric, try: Since the CHECK is expecting an exact result, better use numeric. regards, tom lane ---(end of broadcast)--- TIP 5:

Re: [SQL] Recursive SELECT problem

2006-05-17 Thread Dave Page
> -Original Message- > From: Tom Lane [mailto:[EMAIL PROTECTED] > Sent: 17 May 2006 15:07 > To: Dave Page > Cc: pgsql-sql@postgresql.org > Subject: Re: [SQL] Recursive SELECT problem > > "Dave Page" writes: > > I'm trying to write a query to determine whether or not the current > >

Re: [SQL] Recursive SELECT problem

2006-05-17 Thread Tom Lane
"Dave Page" writes: > I'm trying to write a query to determine whether or not the current > login role has CREATEDB (or CREATEROLE) privileges, either directly or > inherited from a parent role. Those privileges don't inherit, so I'm not sure why you need a recursive check.

Re: [SQL] Table constraints and INSERT

2006-05-17 Thread Niklas Johansson
On 17 maj 2006, at 08.42, Risto Tamme wrote: INSERT INTO "PART" ("P_PARTKEY","P_RETAILPRICE") VALUES(999,90109.89); but it fails: ERROR: new row for relation "PART" violates check constraint "PART_check" The P_PARTKEY column is an integer, which means the expression P_PARTKEY/10 will yield

[SQL] Recursive SELECT problem

2006-05-17 Thread Dave Page
Hi, I'm trying to write a query to determine whether or not the current login role has CREATEDB (or CREATEROLE) privileges, either directly or inherited from a parent role. The query: SELECT EXISTS (SELECT 1 FROM pg_authid WHERE rolcreatedb = TRUE AND pg_has_role(rolname, 'MEMBER')) AS has_creat

Re: [SQL] Database OID

2006-05-17 Thread Kis János Tamás
2006. May 17. Wednesday 09.51 dátummal Achilleus Mantzios ezt írta: > > > > How can I find the database OID from simple SQL command? > > SELECT oid,* from pg_database ; > I'm stupid! Thanks, kjt McAfee SCM 4.1 által ellenőrizve! ---(end of broadcast)

Re: [SQL] Database OID

2006-05-17 Thread Achilleus Mantzios
O Kis Jαnos Tamαs έγραψε στις May 17, 2006 : > Hi, > > How can I find the database OID from simple SQL command? SELECT oid,* from pg_database ; > > Thanks, > kjt > > > McAfee SCM 4.1 αltal ellenυrizve! > > ---(end of broadcast)---TIP > 6: exp

[SQL] Database OID

2006-05-17 Thread Kis János Tamás
Hi, How can I find the database OID from simple SQL command? Thanks, kjt McAfee SCM 4.1 által ellenőrizve! ---(end of broadcast)--- TIP 6: explain analyze is your friend