This error occurs to me sometimes when the call is hung up. The rest is saved normally. I expose a bad record and a good one
[Dec 6 19:47:19] ERROR[31348][C-00000045]: cdr_mysql.c:349 mysql_log:
Failed to insert into database: (1292) Incorrect datetime value:
‘SIP/sip_lbascunan/961258985,160,wWTt’ for column ‘answer’ at row 1
Good Row
‘1575675020.46’, ‘1575675020.46’, ‘“343591171” <343591171>’,
‘343591171’, ‘101961258985’, ‘engine’, ‘SIP/asterisk-63-0000002e’,
‘SIP/opsmovil-0000002f’, ‘Hangup’, ‘’, ‘2019-12-06 20:30:20’, NULL,
‘2019-12-06 20:30:20’, ‘0’, ‘0’, ‘NO ANSWER’, ‘3’, ‘’, ‘’, ‘55’, ‘’
Bad Row
‘1575674496.30’, ‘1575674496.30’, ‘“SISTEMAS” <1084>’, ‘1084’,
‘90962108827’, ‘lbascunan’, ‘SIP/1084-0000001e’,
‘SIP/sip_lbascunan-0000001f’, ‘Dial’,
‘SIP/sip_lbascunan/962108827,160,wWTt’, ‘2019-12-06 20:21:36’,
‘SIP/sip_lbascunan/962108827,160,wWTt’, ‘2019-12-06 20:22:00’, ‘24’,
‘0’, ‘NO ANSWER’, ‘3’, ‘’, ‘’, ‘35’, ‘’
I had to change the Answer field from Varchar to Datetime so that I could save.
This is my Table CDR
CREATE TABLE `cdr` (
`uniqueid` varchar(32) NOT NULL DEFAULT '',
`linkedid` varchar(32) NOT NULL DEFAULT '',
`clid` varchar(80) NOT NULL DEFAULT '',
`src` varchar(80) NOT NULL DEFAULT '',
`dst` varchar(80) NOT NULL DEFAULT '',
`dcontext` varchar(80) NOT NULL DEFAULT '',
`channel` varchar(80) NOT NULL DEFAULT '',
`dstchannel` varchar(80) NOT NULL DEFAULT '',
`lastapp` varchar(80) NOT NULL DEFAULT '',
`lastdata` varchar(80) NOT NULL DEFAULT '',
`start` datetime NOT NULL,
`answer` datetime NOT NULL,
`end` datetime NOT NULL,
`duration` int(11) NOT NULL DEFAULT '0',
`billsec` int(11) NOT NULL DEFAULT '0',
`disposition` varchar(45) NOT NULL DEFAULT '',
`amaflags` int(11) NOT NULL DEFAULT '0',
`accountcode` varchar(20) NOT NULL DEFAULT '',
`userfield` varchar(255) NOT NULL DEFAULT '',
`sequence` varchar(32) NOT NULL DEFAULT '',
`peeraccount` varchar(32) NOT NULL DEFAULT '',
PRIMARY KEY (`uniqueid`),
KEY `start` (`start`),
KEY `dst` (`dst`),
KEY `accountcode` (`accountcode`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Just incorrect quatation.
Check special symbols in callerid(name).
Anyway it is nothing to answer. Just bad system design and no check for sql injection.
Related
CREATE DATABASE mylaboratory;
USE mylaboratory;
DROP TABLE IF EXISTS `Account`;
CREATE TABLE `Account` (
`Email` varchar(255) NOT NULL COMMENT '계정 이메일 (ID)',
`HashedPassword` longtext NOT NULL COMMENT '계정 암호화 된 비밀번호',
`FullName` varchar(255) NOT NULL COMMENT '계정 성명',
`AvatarImagePath` varchar(255) NOT NULL DEFAULT '/upload/Management/Profile/default-avatar.jpg' COMMENT '계정 아바타 이미지 경로',
`Role` varchar(255) NOT NULL DEFAULT 'User' COMMENT '계정 역할 (Admin 또는 User)',
`Locked` tinyint(1) NOT NULL COMMENT '계정 잠금',
`LoginAttempt` int(11) NOT NULL COMMENT '로그인 시도 횟수',
`EmailConfirmed` tinyint(1) NOT NULL COMMENT '이메일 확인 여부',
`AgreedServiceTerms` tinyint(1) NOT NULL COMMENT '약관 동의 여부',
`RegistrationToken` longtext DEFAULT NULL COMMENT '회원가입 인증 토큰',
`ResetPasswordToken` longtext DEFAULT NULL COMMENT '비밀번호 찾기 인증 토큰',
`Created` datetime(6) NOT NULL DEFAULT '1900-01-01 00:00:00.000000' COMMENT '계정 생성일',
`Updated` datetime(6) NOT NULL DEFAULT '1900-01-01 00:00:00.000000' COMMENT '계정 업데이트일',
`Message` longtext DEFAULT NULL COMMENT '계정 상태 메시지',
`Deleted` tinyint(1) NOT NULL COMMENT '계정 삭제 여부',
PRIMARY KEY (`Email`),
CONSTRAINT `Accounts_check` CHECK (`Role` = 'Admin' or `Role` = 'User')
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT 'MyLaboratory.Site 계정';
CREATE TABLE mylaboratory.Asset (
Email varchar(255) NOT NULL COMMENT '계정 이메일 (ID)',
ProductName varchar(255) NOT NULL COMMENT '상품명 (은행 계좌명, 증권 계좌명, 현금 등)',
item varchar(255) NOT NULL COMMENT '항목 (자유입출금 자산, 신탁 자산, 현금 자산, 저축성 자산, 투자성 자산, 부동산, 동산, 기타 실물 자산, 보험 자산)',
Amount BIGINT(255) NOT NULL COMMENT '금액',
MonetaryUnit varchar(255) NOT NULL COMMENT '화폐 단위 (KRW, USD, ETC)',
Created DATETIME(6) NOT NULL COMMENT '생성일',
Updated DATETIME(6) NOT NULL COMMENT '업데이트일',
Note varchar(255) NULL COMMENT '비고',
Reserved0 varchar(100) NULL,
Reserved1 varchar(100) NULL,
Reserved2 varchar(100) NULL,
Reserved3 varchar(100) NULL,
Reserved4 varchar(100) NULL,
PRIMARY KEY (Email, ProductName),
KEY Asset_FK (Email),
CONSTRAINT Asset_FK FOREIGN KEY (Email) REFERENCES mylaboratory.Account(Email)
)
ENGINE=InnoDB
DEFAULT CHARSET=utf8
COLLATE=utf8_general_ci
COMMENT='계정 자산';
Error:
Error occurred during SQL query execution
SQL Error [1005] [HY000]: (conn=61) Can't create table mylaboratory.asset (errno: 150 "Foreign key constraint is incorrectly formed")
I can't figure it out what is wrong in foreign key syntax.
MariaDB 10.2.38 version.
You can not use two different character sets with a foreign key, they have to be the same or at least compatible
CREATE TABLE Asset (
Email varchar(255) NOT NULL COMMENT '계정 이메일 (ID)',
ProductName varchar(255) NOT NULL COMMENT '상품명 (은행 계좌명, 증권 계좌명, 현금 등)',
item varchar(255) NOT NULL COMMENT '항목 (자유입출금 자산, 신탁 자산, 현금 자산, 저축성 자산, 투자성 자산, 부동산, 동산, 기타 실물 자산, 보험 자산)',
Amount BIGINT(255) NOT NULL COMMENT '금액',
MonetaryUnit varchar(255) NOT NULL COMMENT '화폐 단위 (KRW, USD, ETC)',
Created DATETIME(6) NOT NULL COMMENT '생성일',
Updated DATETIME(6) NOT NULL COMMENT '업데이트일',
Note varchar(255) NULL COMMENT '비고',
Reserved0 varchar(100) NULL,
Reserved1 varchar(100) NULL,
Reserved2 varchar(100) NULL,
Reserved3 varchar(100) NULL,
Reserved4 varchar(100) NULL,
PRIMARY KEY (Email, ProductName),
KEY Asset_FK (Email),
CONSTRAINT Asset_FK FOREIGN KEY (Email) REFERENCES Account(Email)
)
ENGINE=InnoDB
DEFAULT CHARSET=utf8mb4
I have a query that does what is required
SELECT v.* FROM vehicle v
WHERE v.company_id = 2 AND v.id NOT IN
(
SELECT h.vehicle_id
FROM hire h
WHERE
h.start_date is not null and h.end_date is null
)
So now I am trying to code this query in Symfony/Doctrine
I have this
$qb = $this->_em->createQueryBuilder();
$subq = $this->_em->createQueryBuilder();
$subq ->select('h.vehicle')
->from('AppBundle\Entity\Hire', 'h')
->andWhere('h.startDate is not null and h.endDate is null');
$qb->select('v')
->from('AppBundle\Entity\Vehicle', 'v')
->where($qb->expr()->notIn('v.id',$subq->getDQL()))
->andWhere('v.company = :company')
->setParameter('company', $company)
->orderBy('v.registrationNumber', 'ASC')
;
$t = $qb->getDQL();
return $qb;
As you see I tried dumping the DQL to see if that gave me any clues and here is is
SELECT v
FROM AppBundle\Entity\Vehicle v
WHERE (v.id NOT IN(SELECT h.vehicle FROM AppBundle\Entity\Hire h WHERE h.startDate is not null and h.endDate is null))
AND v.company = :company
ORDER BY v.registrationNumber ASC
I tried converting this back to simple SQL i.e. removing the AppBundle stuff and converting the column names back to actual column name and it runs and get the right result.
But I am getting this error
Doctrine\ORM\Query\QueryException:
[Semantical Error] line 0, col 69 near 'vehicle FROM': Error: Invalid PathExpression. Must be a StateFieldPathExpression.
at vendor\doctrine\orm\lib\Doctrine\ORM\Query\QueryException.php:63
at Doctrine\ORM\Query\QueryException::semanticalError('line 0, col 69 near \'vehicle FROM\': Error: Invalid PathExpression. Must be a StateFieldPathExpression.', object(QueryException))
The 2 tables involved are
CREATE TABLE `hire` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`company_id` int(11) DEFAULT NULL,
`driver_id` int(11) DEFAULT NULL,
`vehicle_id` int(11) DEFAULT NULL,
`corporate_hire` tinyint(1) DEFAULT NULL,
`end_date` datetime DEFAULT NULL,
`end_miles` decimal(10,1) DEFAULT NULL,
`start_date` datetime DEFAULT NULL,
`start_miles` decimal(10,1) DEFAULT NULL,
`created_by` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`updated_by` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`deleted_by` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`deleted_at` datetime DEFAULT NULL,
`created_at` datetime DEFAULT NULL,
`updated_at` datetime DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `IDX_B8017EFC979B1AD6` (`company_id`),
KEY `IDX_B8017EFCC3423909` (`driver_id`),
KEY `IDX_B8017EFC545317D1` (`vehicle_id`),
CONSTRAINT `FK_B8017EFC545317D1` FOREIGN KEY (`vehicle_id`) REFERENCES `vehicle` (`id`) ON DELETE SET NULL,
CONSTRAINT `FK_B8017EFC979B1AD6` FOREIGN KEY (`company_id`) REFERENCES `company` (`id`) ON DELETE SET NULL,
CONSTRAINT `FK_B8017EFCC3423909` FOREIGN KEY (`driver_id`) REFERENCES `driver` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB AUTO_INCREMENT=29 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
and
CREATE TABLE `vehicle` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`company_id` int(11) DEFAULT NULL,
`storage_id` int(11) DEFAULT NULL,
`created_by` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`updated_by` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`deleted_by` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`deleted_at` datetime DEFAULT NULL,
`created_at` datetime DEFAULT NULL,
`updated_at` datetime DEFAULT NULL,
`date_of_manufacture` datetime DEFAULT NULL,
`engine_size` int(11) DEFAULT NULL,
`make` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
`model` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
`registration_number` varchar(10) COLLATE utf8_unicode_ci NOT NULL,
`vin` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `IDX_1B80E486979B1AD6` (`company_id`),
KEY `IDX_1B80E4865CC5DB90` (`storage_id`),
CONSTRAINT `FK_1B80E4865CC5DB90` FOREIGN KEY (`storage_id`) REFERENCES `storage` (`id`) ON DELETE SET NULL,
CONSTRAINT `FK_1B80E486979B1AD6` FOREIGN KEY (`company_id`) REFERENCES `company` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB AUTO_INCREMENT=25 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
I am not sure what an Invalid Path Expression should be making me look for as an actual error.
What's working for us is (adapted to your example, so not tested):
$subQuery->select('IDENTITY(h.vehicle)');
$subQuery->from('AppBundle\Entity\Hire', 'h');
$dqlString = $subQuery->getQuery()->getDQL();
$query->andWhere('v.id' 'NOT IN (' . $dqlString . ')');
The only two differences that I see are:
subQuery returns IDENTITY() of h.vehicle, so only the 'identifier' (which is id in most cases)
our andWhere condition in main query is created manually - but your expression builder should work the same way.
So my assumption ist that your $subq ->select('h.vehicle') doesn't return ids which can be used in the NOT IN condition of your main query, which might be proven by your resolved DQL SELECT v : this will return all fields, but you'd required v.id only.
How can i change default storage of queue log from /var/log/asterisk/queue_log file to asteriskcdrdb.queue_log table in MySQL in Asterisk 11?
You should have in /etc/asterisk/extconfig.conf:
[settings]
queue_log => mysql,dsn,tablename
and in /etc/asterisk/res_config_mysql.conf:
[dsn]
dbname = database_name
dbuser = database_user
dbpass = database_pass
dbcharset = utf8
requirements = warn
The schema for the table is:
CREATE TABLE `tablename` (
`id` bigint(255) unsigned NOT NULL AUTO_INCREMENT,
`time` varchar(26) NOT NULL DEFAULT '',
`callid` varchar(40) NOT NULL DEFAULT '',
`queuename` varchar(20) NOT NULL DEFAULT '',
`agent` varchar(20) NOT NULL DEFAULT '',
`event` varchar(20) NOT NULL DEFAULT '',
`data` varchar(100) NOT NULL DEFAULT '',
`data1` varchar(40) NOT NULL DEFAULT '',
`data2` varchar(40) NOT NULL DEFAULT '',
`data3` varchar(40) NOT NULL DEFAULT '',
`data4` varchar(40) NOT NULL DEFAULT '',
`data5` varchar(40) NOT NULL DEFAULT '',
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
KEY `queue` (`queuename`),
KEY `event` (`event`)
) DEFAULT CHARSET=utf8;
I suggest that you take a look at the following link:
http://www.voip-info.org/wiki/view/Asterisk+queue_log+on+MySQL
Bear in mind that most of these configurations are already well know, and will be documented on the www.voip-info.org wiki.
Ok i have query something like this
$drzava ="CREATE TABLE IF NOT EXISTS`wp_drzava` (
`ID` int(11) NOT NULL AUTO_INCREMENT,
`Kod` varchar(2) NOT NULL,
`Naziv` varchar(100) NOT NULL,
`NazivSrb` varchar(100) NOT NULL,
`NazivSrbGenetiv` varchar(100) NOT NULL,
`jePrevedeno` tinyint(4) DEFAULT '0',
`jeDrzava` tinyint(1) DEFAULT '1',
`PhoneCode` varchar(10) DEFAULT NULL,
`NazivRo` varchar(255) DEFAULT NULL,
PRIMARY KEY (`ID`)
) ENGINE=MyISAM AUTO_INCREMENT=304 DEFAULT CHARSET=utf8;
INSERT INTO wp_drzava VALUES ('249', 'RO', 'Romania', 'Rumunija', 'Rumunije', null, '1', '+40', 'România ')";
Problem seems to be in România record, so i get not record inserted. I try dbDelta() function and also $wpdb->query() but i get no result. Can someone help me to resolve this problem
INSERT INTO wp_drzava(ID, Kod, Naziv, NazivSrb, NazivSrbGenetiv, jePrevedeno, jeDrzava, PhoneCode, NazivRo) VALUES ('249', 'RO', 'Romania', 'Rumunija', 'Rumunije', null, '1', '+40', 'România ')";
Answer is
$drzava = array();
$drzava[] ="CREATE TABLE IF NOT EXISTS`wp_drzava` (
`ID` int(11) NOT NULL AUTO_INCREMENT,
`Kod` varchar(2) NOT NULL,
`Naziv` varchar(100) NOT NULL,
`NazivSrb` varchar(100) NOT NULL,
`NazivSrbGenetiv` varchar(100) NOT NULL,
`jePrevedeno` tinyint(4) DEFAULT '0',
`jeDrzava` tinyint(1) DEFAULT '1',
`PhoneCode` varchar(10) DEFAULT NULL,
`NazivRo` varchar(255) DEFAULT NULL,
PRIMARY KEY (`ID`)
) ENGINE=MyISAM AUTO_INCREMENT=304 DEFAULT CHARSET=utf8;"
$drzava[] ="INSERT INTO wp_drzava VALUES ('249', 'RO', 'Romania', 'Rumunija', 'Rumunije', null, '1', '+40', 'România ')";
So we must insert array into dbDelta function!
I am importing database and i got an error
1062 - Duplicate entry '1' for key PRIMARY.
i tried to upload table individually But it gives me error for those table which have at least one row.
i don't want to delete any record of any table.
here is one table which is giving error.
CREATE TABLE IF NOT EXISTS `wpbeta_aff_affiliates` (
`affiliate_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(100) NOT NULL,
`email` varchar(512) DEFAULT NULL,
`from_date` date NOT NULL,
`thru_date` date DEFAULT NULL,
`status` varchar(10) NOT NULL DEFAULT 'active',
`type` varchar(10) DEFAULT NULL,
PRIMARY KEY (`affiliate_id`),
KEY `affiliates_afts` (`affiliate_id`,`from_date`,`thru_date`,`status`),
KEY `affiliates_sft` (`status`,`from_date`,`thru_date`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ;
--
-- Dumping data for table `wpbeta_aff_affiliates`
--
INSERT INTO `wpbeta_aff_affiliates` (`affiliate_id`, `name`, `email`, `from_date`, `thru_date`, `status`, `type`) VALUES
(1, 'Direct', NULL, '2013-07-03', NULL, 'active', 'direct');
You do not need to specify the record id (with the exception of some circumstances when you need to keep the connection between records in different tables). Try using this query:
INSERT INTO wpbeta_aff_affiliates (name, email, from_date, thru_date, status, type) VALUES ('Direct', NULL, '2013-07-03', NULL, 'active', 'direct');