[SQL] Using function like where clause

2007-08-09 Thread Ranieri Mazili
Hello, I have 2 questions. 1) Can I use a function that will return a string in a where clause like bellow? select * from table where my_function_making_where() and another_field = 'another_think' 2) Can I use a function that will return a string to return the list of columns that I

[SQL] Restricting columns by users

2007-08-07 Thread Ranieri Mazili
Hello, I'm looking for a method to restrict columns by users on postgresql, searching in google I found what I want, but in mysql, below I reproduce the paragraph that shows what I exactly want: "MySQL can also restrict access on the table level and even on the column level. What this means i

[SQL] Using function like where clause

2007-08-06 Thread Ranieri Mazili
Hello, I have 2 questions. 1) Can I use a function that will return a string in a where clause like bellow? select * from table where my_function_making_where() and another_field = 'another_think' 2) Can I use a function that will return a string to return the list of columns that I

[SQL] Tunning PostgreSQL performance for views on Windows

2007-07-26 Thread Ranieri Mazili
Hello, I'm developing a BI and as database it's using postgresql 8.2, how data are very detailed, I'm creating a view to consolidate the most important data, but the performance of view is very poor, 1 minute to perform more or less without where clause. I need to know how I can increase the perf

Re: [SQL] [GENERAL] Working with dates

2007-07-05 Thread Ranieri Mazili
Original Message Subject: [GENERAL] Working with dates From: Ranieri Mazili <[EMAIL PROTECTED]> To: [EMAIL PROTECTED], pgsql-sql@postgresql.org Date: 5/7/2007 16:00 Hello, I need to do the following select: Number of days of month - weekends - holydays So this quer

[SQL] Working with dates

2007-07-05 Thread Ranieri Mazili
Hello, I need to do the following select: Number of days of month - weekends - holydays So this query will return the number of days that people can work Look that I have the holydays in one table, it's bellow: CREATE TABLE holidays ( id_holidays serial NOT NULL, dt_holiday date, holiday_d

Re: [SQL] [GENERAL] Subquery problems

2007-06-19 Thread Ranieri Mazili
Original Message Subject: Re:[GENERAL] Subquery problems From: Merlin Moncure <[EMAIL PROTECTED]> To: Ranieri Mazili <[EMAIL PROTECTED]> Date: 19/6/2007 10:40 On 6/19/07, Ranieri Mazili <[EMAIL PROTECTED]> wrote: Hello, I'm having another "prob

[SQL] Subquery problems

2007-06-19 Thread Ranieri Mazili
Hello, I'm having another "problem", I have a function that declares 12 variable, one per month and each them execute a select like bellow: *DIV_MES01 := (select count(distinct production_date) from production where extract(month from production_date) = '01' and extract(year from production_da

Re: [SQL] [GENERAL] Setting Variable - (Correct)

2007-06-18 Thread Ranieri Mazili
Original Message Subject: Re:[SQL] [GENERAL] Setting Variable - (Correct) From: Michael Glaesemann <[EMAIL PROTECTED]> To: Ranieri Mazili <[EMAIL PROTECTED]> Date: 18/6/2007 13:50 [Please reply to the list so that others may benefit from and participate in th

Re: [SQL] [GENERAL] Setting Variable - (Correct)

2007-06-18 Thread Ranieri Mazili
Original Message Subject: Re:[SQL] [GENERAL] Setting Variable - (Correct) From: Michael Glaesemann <[EMAIL PROTECTED]> To: Michael Glaesemann <[EMAIL PROTECTED]> Date: 18/6/2007 13:15 On Jun 18, 2007, at 10:17 , Michael Glaesemann wrote: Looking over your function, I'm a litt

[SQL] Setting Variable - (Correct)

2007-06-18 Thread Ranieri Mazili
Hello, I'm trying do the following function: CREATE OR REPLACE FUNCTION lost_hours_temp(date) RETURNS text AS $BODY$ DECLARE START_DATE date; END_DATE date; QUERY text; BEGIN START_DATE := $1; END_DATE := START_DATE - interval '3 year'; WHILE EXTRACT(YEAR FROM START_DATE) = E

[SQL] Setting variable

2007-06-18 Thread Ranieri Mazili
Hello, I need to know why can't I do it? CREATE OR REPLACE FUNCTION lost_hours_temp(date) RETURNS text AS $BODY$ DECLARE START_DATE date; END_DATE date; QUERY text; BEGIN START_DATE := $1; END_DATE := START_DATE - interval '3 year'; The last line (END_DATE := START_DATE - interval

[SQL] Exec a text variable as select

2007-06-18 Thread Ranieri Mazili
Hello, I'm creating a function that will create a select statement into a while, this select will be stored into a text variable, after while ends I need to execute this query stored into variable, on SQLSERVER I can do: EXEC(text_variable) How can I do this on Postgres? I appreciate any help

[SQL] CREATE RULE with WHERE clause

2007-06-05 Thread Ranieri Mazili
Hello, I need to create a rule, but I need that it have a WHERE clause, how bellow: CREATE RULE rule_role_sul AS ON SELECT TO t1 WHERE roles = 'role_sul' DO INSTEAD SELECT field1, field2 FROM t2; CREATE RULE rule_role_sul AS ON SELECT TO t1 WHERE roles = 'role_norte' DO IN

[SQL] Inserting a path into Database

2007-06-04 Thread Ranieri Mazili
Hello, I need to insert a path into a table, but because "\" I have a error by postgres, so how can I insert a path like bellow into a table: insert into production values ('C:\Program Files\My program'); I appreciate any help Thanks ---(end of broadcast)-

[SQL] Encrypted column

2007-06-04 Thread Ranieri Mazili
quot; and "password" are correct using a sql query ? I appreciate any help Thanks Ranieri Mazili ---(end of broadcast)--- TIP 7: You can help support the PostgreSQL project by donating at http://www.postgresql.org/about/donate

[SQL] Jumping Weekends

2007-06-04 Thread Ranieri Mazili
mp weekends, it's continues normally, someone knows what's happen or what am I doing wrong? I appreciate any help. Thanks Ranieri Mazili ---(end of broadcast)--- TIP 4: Have you searched our list archives? http://archives.postgresql.org