Hola lista, quisiera consultarles como hacer insercion, borrado y
actualizaciones a traves de vistas

tengo la db stock con las tablas

stock-# \d clientes
                                    Table "public.clientes"
  Column   |          Type          |
Modifiers
-----------+------------------------+-----------------------------------------------------------
 codigo    | integer                | not null default
nextval('clientes_codigo_seq'::regclass)
 nombre    | character varying(50)  | not null
 apellido  | character varying(50)  | not null
 cuip      | character varying(11)  | not null
 direccion | character varying(100) |
 telefono  | character varying(20)  |
Indexes:
    "clientes_pkey" PRIMARY KEY, btree (codigo)
    "clientes_cuip_key" UNIQUE, btree (cuip)
    "unico_nombre_apellido_idx" UNIQUE, btree (nombre, apellido)

stock=# \d productos
                                     Table "public.productos"
   Column    |          Type          |
Modifiers
-------------+------------------------+------------------------------------------------------------
 codigo      | integer                | not null default
nextval('productos_codigo_seq'::regclass)
 nombre      | character varying(15)  | not null
 descripcion | character varying(250) |
Indexes:
    "productos_pkey" PRIMARY KEY, btree (codigo)
    "productos_nombre_key" UNIQUE, btree (nombre)


stock=# \d ventas
                                        Table "public.ventas"
  Column   |              Type              |
Modifiers
-----------+--------------------------------+---------------------------------------------------------
 codigo    | integer                        | not null default
nextval('ventas_codigo_seq'::regclass)
 producto  | integer                        | not null
 cliente   | integer                        | not null
 cantidad  | integer                        | not null
 fechahora | timestamp(0) without time zone | not null default now()
Indexes:
    "ventas_pkey" PRIMARY KEY, btree (codigo)
Check constraints:
    "ventas_cantidad_check" CHECK (cantidad > 0)
Foreign-key constraints:
    "ventas_cliente_fkey" FOREIGN KEY (cliente) REFERENCES clientes(codigo)
    "ventas_producto_fkey" FOREIGN KEY (producto) REFERENCES
productos(codigo)


y la vista

stock=# \d ventasxcliente
         View "public.ventasxcliente"
  Column  |         Type          | Modifiers
----------+-----------------------+-----------
 nombre   | character varying(50) |
 apellido | character varying(50) |
 producto | character varying(15) |
View definition:
 SELECT c.nombre, c.apellido, p.nombre AS producto
   FROM clientes c, productos p, ventas v
  WHERE v.cliente = c.codigo AND v.producto = p.codigo;


Desde ya saludos y gracias

Responder a