Tom, Jan,
> This is completely pointless, AFAICS. If you don't know what table
> is to be selected from, then you can't do *any* semantic checking or
> planning in advance, so you might as well just do the entire processing
> at runtime. That's exactly what EXECUTE does. I don't see any
> func
> Josh Berkus wrote:
>> If you think that's the best way. What we're really all wanting is a wy
>> in PL/pgSQL to pass a parameter as an object name. Doing it *without*
>> using EXECUTE would be even better than modifying EXECUTE to accomdate
>> SELECT ... INTO variable.
>>
>> If we can write q
Josh Berkus wrote:
> Tom, Jan, Michael,
>
> > While I have not looked closely, I seem to recall that plpgsql handles
> > INTO by stripping that clause out of the statement before it's passed to
> > the SQL engine. Evidently that's not happening in the EXECUTE case.
> >
> > Jan, do you agree this
Tom Lane wrote:
> Michael Ansley <[EMAIL PROTECTED]> writes:
> > CREATE FUNCTION table_count(varchar) RETURNS integer AS '
> > DECLARE
> > SQL varchar;
> > RES integer;
> > BEGIN
> > SQL = ''SELECT * INTO temp1 FROM '' || $1;
> > EXECUTE SQL;
> > SELECT count(*) INTO RES FROM temp1;
> > RETU
> "DR" == David Richter <[EMAIL PROTECTED]> writes:
DR> Folks,
DR> I wrote that function, wich doesn't work. I want to hand over the name
DR> of the tables(relation_table, update_table) and a
DR> column(column_to_fill). The intention is, to use the function also with
DR> other tables(not
Tom, Jan, Michael,
> While I have not looked closely, I seem to recall that plpgsql handles
> INTO by stripping that clause out of the statement before it's passed to
> the SQL engine. Evidently that's not happening in the EXECUTE case.
>
> Jan, do you agree this is a bug? Is it reasonable to
Title: RE: [SQL] PL/PGSQL function with parameters
Yes, that was why I wrote it in the way that I did. The table is effectively given a constant name, and the count is got from the table with a known name. But of a kludge, but in 45sec, that was all I could come up with ;-)
It would be
Michael Ansley <[EMAIL PROTECTED]> writes:
> CREATE FUNCTION table_count(varchar) RETURNS integer AS '
> DECLARE
> SQL varchar;
> RES integer;
> BEGIN
> SQL = ''SELECT * INTO temp1 FROM '' || $1;
> EXECUTE SQL;
> SELECT count(*) INTO RES FROM temp1;
> RETURN(RES
Title: RE: [SQL] PL/PGSQL function with parameters
Just for the record:
DROP FUNCTION table_count(varchar);
CREATE FUNCTION table_count(varchar) RETURNS integer AS '
DECLARE
SQL varchar;
RES integer;
BEGIN
SQL = ''SELECT * INTO temp1 FROM '
Mike, Jan,
> Michael Ansley wrote:
>
> With the latest release, I think you can do:
>
> EXEC ''SELECT * FROM '' || $1;
>
> or
>
> DECLARE SQL VARCHAR;
> ...
> SQL = ''SELECT * FROM '' || $1;
> EXEC SQL;
>
> or something similar (it may be EXECUTE), which uses the dynamic sql
> elements of pl
Mr. Richter,
> I wrote that function, wich doesn't work. I want to hand
> over the name
> of the tables(relation_table, update_table) and a
> column(column_to_fill). The intention is, to use the
> function also with
> other tables(not hard coded).
1. Try using type VARCHAR instead of TEXT for t
11 matches
Mail list logo