Dear Postgresql experts,
I'm writing a simple plpgsql function that selects a row from a table, modifies it
slightly, and inserts the modified version. This sounds simple, but I can't find how
to do the insert in a simple generic fashion: although SELECT has a form that puts the
result in a re
value back
into the table. The syntax I was hoping to find is something like INSERT r INTO
table, but it doesn't seem to exist. So maybe I have to construct an explicit INSERT
(...) VALUES (...) statement as a string. That's OK, but is there an "introspection
mechanism" that lets m
Hi,
Quote from Section 37.11 of the manual:
# There are no default values for parameters in PostgreSQL.
# You can overload function names in PostgreSQL. This is often used
to work around the lack of default parameters.
So for your example:
> CREATE FUNCTION test(integer,integer) RETURNS INTEG
Phil> Insert from a record variable?
Riccardo> Try insert into table select r.*;
Tom> in 7.5
Tom> insert into table select r.*;
Tom> insert into table values(r.*);
Tom> so long as r is declared to be of a named rowtype (not just
Tom> RECORD)
Thanks! Unfortunately I need record, rather
I wrote:
> perhaps rather than inspecting the record variable to see what fields
> it contains, I can look at the table to see what columns it contains
This is my effort. It doesn't work, because I can only EXECUTE
SQL statements, not PLPGSQL statements. I need to EXECUTE an
assignment statement
Phil> execute ''column_values :=
Phil> column_values || quote_literal(r.'' || cr.column_name || '')'';
basic> FOR rec IN EXECUTE
basic> ''select column_values || quote_literal(r.'' ||
basic> cr.column_name || '') alias column_values''; LOOP
basic> column_values := rec.column_values;
basi
Graham Leggett wrote:
> I have an existing table containing a column in it containing
> a money value. I would like to normalise this column into a
> separate table, as the money value is to be expanded to contain
> a tax value, etc.
>
> I have been trying to find a SQL query that will do the
> fo
Graham Leggett <[EMAIL PROTECTED]> wrote:
> >>- Select the money column from the table
> >>- Populate the new normalised table with each row containing
> >> the value from the original money column
> >>- Write the primary keys of the new rows in the normalised
> >> table, back to a new column in
Dear Postgresql experts,
I have a base table that declares a primary key spanning a couple of columns:
create table B (
id integer,
xx someothertype,
.
primary key (id, xx)
);
and a number of derived tables that inherit from B:
create table T (
) inherits (B);
An index is aut
I asked if derived tables use primary key indexes generated in the base tables that
they inherit from.
Franco Bruno Borghesi replied:
> [the derived table] is not inheriting any indexes, neither the
> primary key constraint.
OK, thanks! I had come to the conclusion that it was not using the ind
Kenneth Gonsalves <[EMAIL PROTECTED]> wrote:
> in my app i have a table where the id serves as a foreign key for
> one or more other tables. if i want to delete a row in the table,
> i currently search the other tables where this table is referenced
> to see if the row is in use - and then, if not
in my app i have a table where the id serves as a foreign key for
one or more other tables. if i want to delete a row in the table,
i currently search the other tables where this table is referenced
to see if the row is in use - and then, if not in use, permit
deletion.
Now if i want the delete but
Theodore,
Because jobnumber is declared as text, you are getting "dictionary
order" (lexicographic) ordering on the values. In a dictionary, "abc"
comes after "a", obviously. So indeed "999" will come after
"1000". To get the effect that you want you need to treat jobnumber as
a numb
13 matches
Mail list logo