Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Bases de datos > PostgreSQL
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

 
 
Herramientas Buscar en Tema Desplegado
  #3  
Antiguo 17-10-2011
rmoraglez rmoraglez is offline
Registrado
NULL
 
Registrado: oct 2011
Posts: 5
Poder: 0
rmoraglez Va por buen camino
Hola:

La funcion de Postgres:

CREATE OR REPLACE FUNCTION "public"."card_for_emission" (pbin varchar, ptype integer, puser_id varchar, out result_table "pg_catalog"."refcursor") RETURNS "pg_catalog"."refcursor" AS
$body$
declare
bankpid integer;
seq_pid integer;
begin
select bank_pid into bankpid
from bin_def
where bin_def.bin_id = pbin;
if bankpid is null then
raise exception 'Invalid Bin for get card to emission';
end if;

if ptype = 1 then
-- People Card TABLE
open result_table for
select
distinct c.cardnumber, p.name, p.last_name, p.last_name2,
c.exp_date, c.card_type
from card c
inner join cardholder ch on
c.cardholder_pid = ch.cardholder_pid
inner join client cl on
cl.client_pid = ch.client_pid
inner join bank b on
b.bank_pid = cl.bank_pid
inner join people p on
p.people_pid = cl.people_pid
inner join bin_def bd on
bd.bank_pid = b.bank_pid
where
c.status = 1 and b.bank_pid = bankpid and c.printlot = 0;
insert into record_log (log_timestamp, log_table, log_table_pid,
log_user, log_action, details, log_errorcode)
values(CURRENT_TIMESTAMP(2), 'card', NULL, puser_id, 4 ,
'select card for PRINT FRONT: status=1' ||
' bank_pid='|| bankpid ||
' printlot= 0', null);
end if;
end;
$body$
LANGUAGE 'plpgsql'
VOLATILE
CALLED ON NULL INPUT
SECURITY INVOKER;


En Delphi tengo el siguiente codigo en el Create del formulario principal:

with DM do
begin
dsPrintFront.Dataset := spPrintFront;

MEmisor_Connection.Open;
spPrintFront.Parameters.ParamByName('pbin').Value := '977000';
spPrintFront.Parameters.ParamByName('ptype').Value := 1;
spPrintFront.Parameters.ParamByName('puser_id').Value := 'reina';
spPrintFront.Prepared := True;
spPrintFront.Open;
end;

En dicho formulario tengo un DBGrid y en tiempo de diseño puse DataSource = DM.dsPrintFront

Saludos,
Reina
Responder Con Cita
 



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Cuantos registros devuelve una consulta kizé MySQL 1 25-10-2010 10:13:30
Como Usar una Funcion que devuelve un escalar Iceman MS SQL Server 3 29-07-2008 21:54:12
(DBExpress)la función IsIndexField del TSQLQuery siempre me devuelve falso amezeta32 Conexión con bases de datos 0 17-08-2006 00:20:46
TIBQuery no devuelve todos los registros rochi SQL 0 27-02-2005 19:25:49
funcion que devuelve el tipo de dato de un variant samame OOP 3 08-07-2004 16:02:30


La franja horaria es GMT +2. Ahora son las 01:19:24.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi