Re: [SQL] How to get CURRENT_DATE in a pl/pgSQL function

2010-05-19 Thread silly sad

On 05/18/10 23:27, Kenneth Marshall wrote:


It works using 'now' and I assume that since curtime is


now() is NOT the CURRENT timestamp in fact,
it is about the timestamp of the current transaction has been started.

it is the really USEFUL value, still u have to remember this meaning.

--
Sent via pgsql-sql mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql


Re: [SQL] How to get CURRENT_DATE in a pl/pgSQL function

2010-05-19 Thread Tim Landscheidt
Brian Modra  wrote:

>>> It works using 'now' and I assume that since curtime is
>>> of type DATE that the assignment casts the return automatically
>>> to type DATE. Thank you for the ideas.
>>> [...]

>> What's wrong with Pavel's correct and to-the-point answer?

> No need actually to cast... just use current_date without the quotes.
> Its not a string.

Where did Pavel suggest to cast or use a string?

Tim


-- 
Sent via pgsql-sql mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql


Re: [SQL] How to get CURRENT_DATE in a pl/pgSQL function

2010-05-19 Thread Jasen Betts
On 2010-05-18, Kenneth Marshall  wrote:
> I am trying to write a function that updates the
> date column to the current date. According to:
>
> http://www.postgresql.org/docs/8.4/static/functions-datetime.html#FUNCTIONS-DATETIME-CURRENT
>
> you can use CURRENT_DATE. When I try to use it in
> the following pl/pgSQL function it gives the error:
>
> ERROR:  date/time value "current" is no longer supported
> CONTEXT:  PL/pgSQL function "merge_data" line 4 at assignment
>
> Here is the code I am using:
>
> CREATE FUNCTION merge_data(key INT, i INT) RETURNS
> VOID AS
> $$
> DECLARE
> curtime date;
> BEGIN
> curtime := 'CURRENT_DATE';


use one of

  CURRENT_DATE
  'today' 
  NOW()   
  CURRENT_TIMESTAMP   
  'now'

there are probably others which will work too.


-- 
Sent via pgsql-sql mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql


Re: [SQL] How to get CURRENT_DATE in a pl/pgSQL function

2010-05-19 Thread Kenneth Marshall
On Wed, May 19, 2010 at 12:26:07PM +0400, silly sad wrote:
> On 05/18/10 23:27, Kenneth Marshall wrote:
>
>> It works using 'now' and I assume that since curtime is
>
> now() is NOT the CURRENT timestamp in fact,
> it is about the timestamp of the current transaction has been started.
>
> it is the really USEFUL value, still u have to remember this meaning.
>
That is a good point. My main concern was locking the value
to to point when the pl/pgSQL function was called initially
because of the prepare process. Any of these will work if
assigned to a variable and not included directly in the SQL
statement.

Cheers,
Ken

-- 
Sent via pgsql-sql mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql


[SQL] user function and bind

2010-05-19 Thread David Harel

Hi,
I need an example how to write user function with columns binding and 
how to use it on PHP


--
Thanks.

David Harel,

==

Home office +972 77 7657645
Cellular:   +972 54 4534502
Snail Mail: Amuka
D.N Merom Hagalil
13802
Israel
Email:  [email protected]




Re: [SQL] user function and bind

2010-05-19 Thread Justin Graf
On 5/19/2010 9:56 AM, David Harel wrote:
> Hi,
> I need an example how to write user function with columns binding and 
> how to use it on PHP
> -- 
> Thanks.
>


I'm not sure i understand your   question.  You want a function to 
return record type correct??








All legitimate Magwerks Corporation quotations are sent in a .PDF file 
attachment with a unique ID number generated by our proprietary quotation 
system. Quotations received via any other form of communication will not be 
honored.

CONFIDENTIALITY NOTICE: This e-mail, including attachments, may contain legally 
privileged, confidential or other information proprietary to Magwerks 
Corporation and is intended solely for the use of the individual to whom it 
addresses. If the reader of this e-mail is not the intended recipient or 
authorized agent, the reader is hereby notified that any unauthorized viewing, 
dissemination, distribution or copying of this e-mail is strictly prohibited. 
If you have received this e-mail in error, please notify the sender by replying 
to this message and destroy all occurrences of this e-mail immediately.
Thank you.
<>
-- 
Sent via pgsql-sql mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql


Re: [SQL] user function and bind

2010-05-19 Thread Gary Chambers
David,

> I need an example how to write user function with columns binding and how to
> use it on PHP

If I'm understanding your request correctly:

$dbh = pgpconnect("dbname=db host=dbhost user=dbuser password=pw");
$query = 'SELECT * FROM table WHERE x=$1 AND y=$2 AND z=$3';
$stmt = pg_query_params($dbh, $query, array($x, $y, $z));

-- Gary Chambers

/* Nothing fancy and nothing Microsoft! */

-- 
Sent via pgsql-sql mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql