Hello -
I'm recently a newbie to mysql, but have experiance in oracle, mssql, access, etc...
Here is my problem, i've created the table needed to test the audit procedures. the data element that the id is going to be inserted into is auto_increment.
I don't know what the problem could be.
here is the table code:
[code=mysql]
-- Table: tblaudit
-- DROP TABLE IF EXISTS `tblaudit`;
CREATE TABLE `tblaudit` (
`AuditId` int(8) NOT NULL,
`UserName` varchar(50) NOT NULL,
`TableName` varchar(50) NOT NULL,
`FieldName` varchar(50) NOT NULL,
`OldValue` longtext ,
`NewValue` longtext ,
`DTAdded` timestamp NOT NULL DEFAULT CURRENT_TIMESTA MP,
`TestId` bigint AUTO_INCREMENT NOT NULL,
/* Keys */
PRIMARY KEY (`TestId`)
) ENGINE = InnoDB
CHARACTER SET `utf8` COLLATE `utf8_unicode_c i`;
[/code]
here is the procedure code
[code=mysql]
DELIMITER |
CREATE PROCEDURE `add_tblAudit`
(
IN `pUserName` varchar(50),
IN `pTableName` varchar(50),
IN `pFieldName` varchar(50),
IN `pOldValue` longtext,
IN `pNewValue` longtext
)
BEGIN
DECLARE insertId;
INSERT INTO `tblAudit` (`UserName`, `TableName`, `FieldName`, `OldValue`, `NewValue`)
VALUES (pUserName, pTableName, pFieldName, pOldValue, pNewValue);
SELECT last_insert_id( ) INTO insertId;
INSERT INTO `tblAudit`(`Tes tId`) VALUES (insertId);
END|
DELIMITER ;
[/code]
thanks for your help in advance!
I'm recently a newbie to mysql, but have experiance in oracle, mssql, access, etc...
Here is my problem, i've created the table needed to test the audit procedures. the data element that the id is going to be inserted into is auto_increment.
I don't know what the problem could be.
here is the table code:
[code=mysql]
-- Table: tblaudit
-- DROP TABLE IF EXISTS `tblaudit`;
CREATE TABLE `tblaudit` (
`AuditId` int(8) NOT NULL,
`UserName` varchar(50) NOT NULL,
`TableName` varchar(50) NOT NULL,
`FieldName` varchar(50) NOT NULL,
`OldValue` longtext ,
`NewValue` longtext ,
`DTAdded` timestamp NOT NULL DEFAULT CURRENT_TIMESTA MP,
`TestId` bigint AUTO_INCREMENT NOT NULL,
/* Keys */
PRIMARY KEY (`TestId`)
) ENGINE = InnoDB
CHARACTER SET `utf8` COLLATE `utf8_unicode_c i`;
[/code]
here is the procedure code
[code=mysql]
DELIMITER |
CREATE PROCEDURE `add_tblAudit`
(
IN `pUserName` varchar(50),
IN `pTableName` varchar(50),
IN `pFieldName` varchar(50),
IN `pOldValue` longtext,
IN `pNewValue` longtext
)
BEGIN
DECLARE insertId;
INSERT INTO `tblAudit` (`UserName`, `TableName`, `FieldName`, `OldValue`, `NewValue`)
VALUES (pUserName, pTableName, pFieldName, pOldValue, pNewValue);
SELECT last_insert_id( ) INTO insertId;
INSERT INTO `tblAudit`(`Tes tId`) VALUES (insertId);
END|
DELIMITER ;
[/code]
thanks for your help in advance!
Comment