> G'Day All,
>
> Please put me out of my misery. Give the following stored procedure.....

Gimme a second, but first, and MOST importantly:

> DECLARE VARIABLE NextTranID Integer;
> BEGIN
>   SELECT MAX(TranID) FROM CAS INTO :NextTranID;
>   NextTranID = NextTranID + 1;
>   INSERT INTO CAS VALUES (:NextTranID, "Some Magical SQL");
> END

This REALLY REALLY REALLY should be:

CREATE GENERATOR GEN_TRANID;


create procedure writetotranlog( something varchar(255)) AS
 DECLARE VARIABLE NextTranID Integer;
 BEGIN
   NextTranID = Gen_ID(GEN_TRANID,1);
   INSERT INTO CAS VALUES (:NextTranID, :something);
 END


Thats exactly the POINT of generators!!!!

this works fine for me:

make a generator:

create generator tempgen;
(or make it in SQLExplorer)

create the procedure testproc:

CREATE PROCEDURE TESTPROC (
  THING VARCHAR(255)
)  AS
declare variable myint integer;
BEGIN
  myint = gen_id(tempgen,1);
  insert into jobtype values (:thing || cast(:myint as varchar(255)));
END

(I just concat (||) the thing I pass in with my integer, converted to a
string)

And the trigger:

CREATE TRIGGER PRIVILAGETRIGGER1 FOR PRIVILAGE AFTER INSERT POSITION 0 AS
BEGIN
execute procedure testproc("trigger");
END


Works for me. I get exactly the results I would expect from this.

Nic.






---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz

Reply via email to