Subject | units and procedures |
---|---|
Author | Marcello Miorelli |
Post date | 2001-05-31T01:17:02Z |
Okay Francis,
So I will send you a delphi unit, a form, and an interbase procedure where
there is a blob insertion. I need also to show you the table where the blob
is to be stored.
Table:
CREATE TABLE "HISTORIC"
(
"COD_CLIENT" FLOAT NOT NULL,
"DT_HISTORIC" DATE DEFAULT 'TODAY' NOT NULL,
"SEQ" FLOAT DEFAULT 1 NOT NULL,
"COD_AMB" DOUBLE PRECISION DEFAULT NULL,
"COD_CID" VARCHAR(5) CHARACTER SET ISO8859_1 DEFAULT NULL COLLATE PT_PT,
"COD_PHYSICIAN" FLOAT NOT NULL,
"COD_PACT" FLOAT NOT NULL,
"TXT_MEMO" BLOB SUB_TYPE TEXT SEGMENT SIZE 80 CHARACTER SET ISO8859_1,
CONSTRAINT "PKHISTORICO" PRIMARY KEY ("COD_CLIENT", "DT_HISTORIC", "SEQ")
);
ALTER TABLE "HISTORIC" ADD CONSTRAINT "FKHISTORICO_AMB" FOREIGN KEY
("COD_AMB") REFERENCES AMB ("COD_AMB");
ALTER TABLE "HISTORIC" ADD CONSTRAINT "FKHISTORICO_CID" FOREIGN KEY
("COD_CID") REFERENCES CID10 ("COD_CID");
ALTER TABLE "HISTORIC" ADD CONSTRAINT "FKHISTORICO_CLIENTE" FOREIGN KEY
("COD_CLIENT") REFERENCES CLIENT ("COD_CLIENT");
ALTER TABLE "HISTORIC" ADD CONSTRAINT "FKHISTORICO_CONVENIO" FOREIGN KEY
("COD_PACT") REFERENCES PACT ("COD_PACT");
ALTER TABLE "HISTORIC" ADD CONSTRAINT "FKHISTORICO_MEDICO" FOREIGN KEY
("COD_PHYSICIAN") REFERENCES PHYSICIAN ("COD_PHYSICIAN");
Stored Procedure:
CREATE PROCEDURE "INHISTORIC"
(
COD_CLIENT FLOAT,
DT_HISTORIC TIMESTAMP,
SEQ FLOAT,
COD_AMB DOUBLE PRECISION,
COD_CID VARCHAR(5) CHARACTER SET ISO8859_1,
COD_PHYSICIAN FLOAT,
COD_PACT FLOAT,
MAHA_VISHNU BLOB CHARACTER SET ISO8859_1,
P1 VARCHAR(1) CHARACTER SET ISO8859_1
)
RETURNS
(
R1 FLOAT
)
AS
BEGIN EXIT; END ^
ALTER PROCEDURE "INHISTORIC"
(
COD_CLIENT FLOAT,
DT_HISTORIC TIMESTAMP,
SEQ FLOAT,
COD_AMB DOUBLE PRECISION,
COD_CID VARCHAR(5) CHARACTER SET ISO8859_1,
COD_PHYSICIAN FLOAT,
COD_PACT FLOAT,
MAHA_VISHNU BLOB CHARACTER SET ISO8859_1,
P1 VARCHAR(1) CHARACTER SET ISO8859_1
)
RETURNS
(
R1 FLOAT
)
AS
/*--------------------------------------------------------------------------
--------*/
/* HARE KRISHNA HARE KRISHNA KRISHNA KRISHNA HARE HARE
*/
/* HARE RAMA HARE RAMA RAMA RAMA HARE HARE
*/
/*--------------------------------------------------------------------------
--------*/
declare variable Shiva float;
begin
r1 = -1;
if ((cod_physician = 0) or (cod_physician is NULL) or (cod_pact = 0) or
(cod_pact is NULL)) then
exception historic_pact_physician;
r1 = 1;
if (:cod_amb <= 0) then
cod_amb = NULL;
if (:cod_cid = '') then
cod_cid = NULL;
if ((:seq < 1) or (:seq is NULL)) then
Seq = 1;
select count(*) from historic
where cod_client = :cod_client
and dt_historic = :dt_historic
and seq = :seq
into :Shiva;
if (:Shiva is NULL) then
Shiva = 0;
if (Shiva < 1) then begin
insert into historic( COD_CLIENT,
DT_HISTORIC,
SEQ,
COD_AMB,
COD_CID,
COD_PHYSICIAN,
COD_PACT,
TXT_MEMO)values(
:COD_CLIENT,
:DT_HISTORIC,
:SEQ,
:COD_AMB,
:COD_CID,
:COD_PHYSICIAN,
:COD_PACT,
:Maha_Vishnu);
when SQLCODE -530 do begin
r1 = -1;
exception historico_foreign_key;
end/*WHEN*/
end/*IF*/
else
if (upper(p1) = 'Y') then begin
update Historic
set cod_amb = :cod_amb,
txt_memo = :maha_vishnu,
cod_cid = :cod_cid,
cod_physician = :cod_physician,
cod_pact = :cod_pact
where cod_client = :cod_client
and dt_historic = :dt_historic
and seq = :seq;
when SQLCODE -530 do begin
r1 = -1;
exception historico_foreign_key;
end/*WHEN*/
end /*IF*/
else begin
select (max(seq)+1) from Historic
where cod_client = :cod_client
and dt_historic = :dt_historic
into :seq;
if ((:seq < 1) or (:seq is NULL)) then
Seq = 1;
insert into historic( COD_CLIENT,
DT_HISTORIC,
SEQ,
COD_AMB,
COD_CID,
COD_PHYSICIAN,
COD_PACT,
TXT_MEMO)values(
:COD_CLIENT,
:DT_HISTORIC,
:SEQ,
:COD_AMB,
:COD_CID,
:COD_PHYSICIAN,
:COD_PACT,
:Maha_Vishnu);
when SQLCODE -530 do begin
r1 = -1;
exception historico_foreign_key;
end/*WHEN*/
end/*ELSE*/
/*--------------------------------------------------------------------------
--------*/
/* HARE KRISHNA HARE KRISHNA KRISHNA KRISHNA HARE HARE
*/
/* HARE RAMA HARE RAMA RAMA RAMA HARE HARE
*/
/*--------------------------------------------------------------------------
--------*/
end
^
SET TERM ; ^
Francis, these programs, table and stored procedure have been working very
well and fast since december of last year if I am not misled.
Any dobts just ask me again.
If you would like to call me 55 - 54 - 221 - 87 -48
I could see your e-mail address is quickhire, it means you hire people
around to work with interbase?
If so let me know. :-)
Hope it helps,
Peace
Marcello
So I will send you a delphi unit, a form, and an interbase procedure where
there is a blob insertion. I need also to show you the table where the blob
is to be stored.
Table:
CREATE TABLE "HISTORIC"
(
"COD_CLIENT" FLOAT NOT NULL,
"DT_HISTORIC" DATE DEFAULT 'TODAY' NOT NULL,
"SEQ" FLOAT DEFAULT 1 NOT NULL,
"COD_AMB" DOUBLE PRECISION DEFAULT NULL,
"COD_CID" VARCHAR(5) CHARACTER SET ISO8859_1 DEFAULT NULL COLLATE PT_PT,
"COD_PHYSICIAN" FLOAT NOT NULL,
"COD_PACT" FLOAT NOT NULL,
"TXT_MEMO" BLOB SUB_TYPE TEXT SEGMENT SIZE 80 CHARACTER SET ISO8859_1,
CONSTRAINT "PKHISTORICO" PRIMARY KEY ("COD_CLIENT", "DT_HISTORIC", "SEQ")
);
ALTER TABLE "HISTORIC" ADD CONSTRAINT "FKHISTORICO_AMB" FOREIGN KEY
("COD_AMB") REFERENCES AMB ("COD_AMB");
ALTER TABLE "HISTORIC" ADD CONSTRAINT "FKHISTORICO_CID" FOREIGN KEY
("COD_CID") REFERENCES CID10 ("COD_CID");
ALTER TABLE "HISTORIC" ADD CONSTRAINT "FKHISTORICO_CLIENTE" FOREIGN KEY
("COD_CLIENT") REFERENCES CLIENT ("COD_CLIENT");
ALTER TABLE "HISTORIC" ADD CONSTRAINT "FKHISTORICO_CONVENIO" FOREIGN KEY
("COD_PACT") REFERENCES PACT ("COD_PACT");
ALTER TABLE "HISTORIC" ADD CONSTRAINT "FKHISTORICO_MEDICO" FOREIGN KEY
("COD_PHYSICIAN") REFERENCES PHYSICIAN ("COD_PHYSICIAN");
Stored Procedure:
CREATE PROCEDURE "INHISTORIC"
(
COD_CLIENT FLOAT,
DT_HISTORIC TIMESTAMP,
SEQ FLOAT,
COD_AMB DOUBLE PRECISION,
COD_CID VARCHAR(5) CHARACTER SET ISO8859_1,
COD_PHYSICIAN FLOAT,
COD_PACT FLOAT,
MAHA_VISHNU BLOB CHARACTER SET ISO8859_1,
P1 VARCHAR(1) CHARACTER SET ISO8859_1
)
RETURNS
(
R1 FLOAT
)
AS
BEGIN EXIT; END ^
ALTER PROCEDURE "INHISTORIC"
(
COD_CLIENT FLOAT,
DT_HISTORIC TIMESTAMP,
SEQ FLOAT,
COD_AMB DOUBLE PRECISION,
COD_CID VARCHAR(5) CHARACTER SET ISO8859_1,
COD_PHYSICIAN FLOAT,
COD_PACT FLOAT,
MAHA_VISHNU BLOB CHARACTER SET ISO8859_1,
P1 VARCHAR(1) CHARACTER SET ISO8859_1
)
RETURNS
(
R1 FLOAT
)
AS
/*--------------------------------------------------------------------------
--------*/
/* HARE KRISHNA HARE KRISHNA KRISHNA KRISHNA HARE HARE
*/
/* HARE RAMA HARE RAMA RAMA RAMA HARE HARE
*/
/*--------------------------------------------------------------------------
--------*/
declare variable Shiva float;
begin
r1 = -1;
if ((cod_physician = 0) or (cod_physician is NULL) or (cod_pact = 0) or
(cod_pact is NULL)) then
exception historic_pact_physician;
r1 = 1;
if (:cod_amb <= 0) then
cod_amb = NULL;
if (:cod_cid = '') then
cod_cid = NULL;
if ((:seq < 1) or (:seq is NULL)) then
Seq = 1;
select count(*) from historic
where cod_client = :cod_client
and dt_historic = :dt_historic
and seq = :seq
into :Shiva;
if (:Shiva is NULL) then
Shiva = 0;
if (Shiva < 1) then begin
insert into historic( COD_CLIENT,
DT_HISTORIC,
SEQ,
COD_AMB,
COD_CID,
COD_PHYSICIAN,
COD_PACT,
TXT_MEMO)values(
:COD_CLIENT,
:DT_HISTORIC,
:SEQ,
:COD_AMB,
:COD_CID,
:COD_PHYSICIAN,
:COD_PACT,
:Maha_Vishnu);
when SQLCODE -530 do begin
r1 = -1;
exception historico_foreign_key;
end/*WHEN*/
end/*IF*/
else
if (upper(p1) = 'Y') then begin
update Historic
set cod_amb = :cod_amb,
txt_memo = :maha_vishnu,
cod_cid = :cod_cid,
cod_physician = :cod_physician,
cod_pact = :cod_pact
where cod_client = :cod_client
and dt_historic = :dt_historic
and seq = :seq;
when SQLCODE -530 do begin
r1 = -1;
exception historico_foreign_key;
end/*WHEN*/
end /*IF*/
else begin
select (max(seq)+1) from Historic
where cod_client = :cod_client
and dt_historic = :dt_historic
into :seq;
if ((:seq < 1) or (:seq is NULL)) then
Seq = 1;
insert into historic( COD_CLIENT,
DT_HISTORIC,
SEQ,
COD_AMB,
COD_CID,
COD_PHYSICIAN,
COD_PACT,
TXT_MEMO)values(
:COD_CLIENT,
:DT_HISTORIC,
:SEQ,
:COD_AMB,
:COD_CID,
:COD_PHYSICIAN,
:COD_PACT,
:Maha_Vishnu);
when SQLCODE -530 do begin
r1 = -1;
exception historico_foreign_key;
end/*WHEN*/
end/*ELSE*/
/*--------------------------------------------------------------------------
--------*/
/* HARE KRISHNA HARE KRISHNA KRISHNA KRISHNA HARE HARE
*/
/* HARE RAMA HARE RAMA RAMA RAMA HARE HARE
*/
/*--------------------------------------------------------------------------
--------*/
end
^
SET TERM ; ^
Francis, these programs, table and stored procedure have been working very
well and fast since december of last year if I am not misled.
Any dobts just ask me again.
If you would like to call me 55 - 54 - 221 - 87 -48
I could see your e-mail address is quickhire, it means you hire people
around to work with interbase?
If so let me know. :-)
Hope it helps,
Peace
Marcello
----- Original Message -----
From: "Francis Brock" <fbrock@...>
To: "Marcello Miorelli" <jjkalki@...>
Sent: Wednesday, May 30, 2001 6:26 AM
Subject: Re: End result of insert and retreiving blobs from a stored
procedure
Hi Marcello,
You had made reference in your news group post that you had code you'd be
willing to share: Both Delphi code and InterBase stored procedure(s). Just
interested in seeing your interpretation of the solution to storing and
retrieving blobs. Thanks.
Peace,
Francis
[Non-text portions of this message have been removed]