Subject Re: Insert within a stored procedure not inserting records
Author Peter Welch
Ann,

Thank you for your reply. My usage of the ? parameter in the Insert
Statement stems from another project where I do XML calls. If I
recall correctly, I could only get the insert to work if I set up the
stored procedure with the Insert receiving ALL of the paramters and
the Values taking only the '?' as the parameter. I couldn't even
include any other code logic -- had to be just the Insert Statement
as below.

The communication to Firebird in that case is through Jaybird which
must be supplying the transaction commits for me because I don't
specify any in the calling code.

Oh, and Rick, if you're reading this, thank you for hating to ask
about commits because that was indeed the problem with the Delphi
code. It isn't enough to have Server Autocommit checked on the
IB_Objects database object -- must ensure that the Transaction object
is also configured - or explicitly committed in the code.


====================================
<statement name = "EVN" >
<procedure>{call INS_EVN (

@... ,
@... ,
@... ,
@... ,
@... ,
@... ,
@...
,@...
,@...
,@...
,@...
,@...


)
}
</procedure>

=========================================
CREATE TABLE EVN (
CREATEDATETIME TIMESTAMP DEFAULT 'NOW' NOT NULL,
MESSAGEID ID_INT NOT NULL,
MESSAGEDATETIME TIMESTAMP NOT NULL,
CHARACTERIZATION VARCHAR(50) NOT NULL,
MRN VARCHAR(20),
EMRN VARCHAR(30),
DOB VARCHAR(10),
ACCOUNTNUMBER VARCHAR(20),
EVENTTYPECODE VARCHAR(3),
DATETIMEOFEVENT VARCHAR(26),
DATETIMEPLANNEDEVENT VARCHAR(26),
EVENTREASONCODE VARCHAR(3),
OPERATORID VARCHAR(5) )^

=========================================
CREATE PROCEDURE INS_EVN (
MESSAGEID BIGINT,
MESSAGEDATETIME TIMESTAMP,
CHARACTERIZATION VARCHAR(50),
MRN VARCHAR(20),
EMRN VARCHAR(30),
DOB VARCHAR(10),
ACCOUNTNUMBER VARCHAR(20),
EVENTTYPECODE VARCHAR(3),
DATETIMEOFEVENT VARCHAR(26),
DATETIMEPLANNEDEVENT VARCHAR(26),
EVENTREASONCODE VARCHAR(3),
OPERATORID VARCHAR(5) )
AS
Begin
INSERT INTO EVN
( MessageID ,
MessageDateTime ,
Characterization ,
MRN ,
EMRN ,
DOB ,
AccountNumber ,
EventTypeCode ,
DateTimeOfEvent ,
DateTimePlannedEvent ,
EventReasonCode ,
OperatorID
)
VALUES (
?/*0*/ ,
?/*1*/ ,
?/*2*/ ,
?/*3*/ ,
?/*4*/ ,
?/*5*/ ,
?/*6*/ ,
?/*7*/ ,
?/*8*/ ,
?/*9*/ ,
?/*10*/,
?/*11*/

);
End^
============================
Thank you all,

Pete

--- In firebird-support@yahoogroups.com, "Ann W. Harrison"
<aharrison@...> wrote:
>
> Peter Welch wrote:
> > I am trying to Insert within a stored procedure but it does not
work -
>
> Err, I'm surprised it compiles.
> >
> > The following is the metadata:
> >
> > Create PROCEDURE INS_SC ( MRN INTEGER
> > , ADMITDATETIME TIMESTAMP
> > , STATUS CHAR( 1 ) )
> > AS
> > BEGIN
> >
> > insert into sc_list
> > (mrn, admitdatetime, status)
> > values (? /* PRM_0 */ , ? /* PRM_1 */ ,? /* PRM_2
*/ );
> >
> > END
>
> should be
>
> create procedure INS_SC (MRN intege, AdmitDateTime timestamp,
> STATUS (char(1))
> as begin
>
> insert into sc_list (mrn, admitdatetime, status)
> value (:MRN, :AdmitDateTime, :status);
>
> end
>
>
> Good Luck,
>
>
> Ann
>