I am trying to create a table in my database using the following mysql query. But I am getting some row size error.
create table PJC_TXN_XFACE_STAGE_ALL (rowid int AUTO_INCREMENT,error_flag varchar(50),error_message varchar(500),Transaction_Type VARCHAR(100),
Business_Unit_Name VARCHAR(2),
Business_Unit_ID double,
Transaction_Source VARCHAR(240),
Transaction_Source_ID double,
Document VARCHAR(240),
Document_ID double,
Document_Entry VARCHAR(240),
Document_Entry_ID double,
Expenditure_Batch VARCHAR(50),
Batch_Ending_Date VARCHAR(100),
Batch_Description VARCHAR(250),
Expenditure_Item_Date VARCHAR(100),
Person_Number VARCHAR(30),
Person_Name VARCHAR(2000),
Person_ID double,
Human_Resources_Assignment VARCHAR(80),
Human_Resources_Assignment_ID double,
Project_Number VARCHAR(25),
Project_Name VARCHAR(240),
Project_ID double,
Task_Number VARCHAR(100),
Task_Name VARCHAR(255),
Task_ID double,
Expenditure_Type VARCHAR(240),
Expenditure_Type_ID double,
Expenditure_Organization VARCHAR(240),
Expenditure_Organization_ID double,
Quantity double,
Unit_of_Measure VARCHAR(80),
Unit_of_Measure_Code VARCHAR(30),
Work_Type VARCHAR(240),
Work_Type_ID double,
Billable VARCHAR(1),
Capitalizable VARCHAR(1),
Accrual_Batch VARCHAR(1),
Original_Transaction_Reference VARCHAR(120),
Unmatched_Negative_Transaction VARCHAR(1),
Reversed_Original_Transaction VARCHAR(120),
Expenditure_Item_Comment VARCHAR(240),
Accounting_Date VARCHAR(100),
Transaction_Currency_Code VARCHAR(15),
Transaction_Currency VARCHAR(80),
Raw_Cost_in_Transaction_Currency double,
Burdened_Cost_in_Transaction_Currency double,
Raw_Cost_Credit_CCID double,
Raw_Cost_Credit_Account VARCHAR(2000),
Raw_Cost_Debit_CCID double,
Raw_Cost_Debit_Account VARCHAR(2000),
Burdened_Cost_Credit_CCID double,
Burdened_Cost_Credit_Account VARCHAR(2000),
Burdened_Cost_Debit_CCID double,
Burdened_Cost_Debit_Account VARCHAR(2000),
Burden_Cost_Credit_CCID double,
Burden_Cost_Credit_Account VARCHAR(2000),
Burden_Cost_Debit_CCID double,
Burden_Cost_Debit_Account VARCHAR(2000),
Provider_Ledger_Currency_Code VARCHAR(15),
Provider_Ledger_Currency VARCHAR(80),
Raw_Cost_in_Provider_Ledger_Currency double,
Burdened_Cost_in_Provider_Ledger_Currency double,
Provider_Ledger_Conversion_Rate_Type VARCHAR(30),
Provider_Ledger_Conversion_Rate_Date VARCHAR(100),
Provider_Ledger_Conversion_Date_Type VARCHAR(4),
Provider_Ledger_Currency_Conversion_Rate double,
Provider_Ledger_Currency_Conversion_Rounding_Limit double,
Converted VARCHAR(1),
Context_Category VARCHAR(40),
User_Defined_Attribute_1 VARCHAR(150),
User_Defined_Attribute_2 VARCHAR(150),
User_Defined_Attribute_3 VARCHAR(150),
User_Defined_Attribute_4 VARCHAR(150),
User_Defined_Attribute_5 VARCHAR(150),
User_Defined_Attribute_6 VARCHAR(150),
User_Defined_Attribute_7 VARCHAR(150),
User_Defined_Attribute_8 VARCHAR(150),
User_Defined_Attribute_9 VARCHAR(150),
User_Defined_Attribute_10 VARCHAR(150),
Reserved_Attribute_1 VARCHAR(150),
Reserved_Attribute_2 VARCHAR(150),
Reserved_Attribute_3 VARCHAR(150),
Reserved_Attribute_4 VARCHAR(150),
Reserved_Attribute_5 VARCHAR(150),
Reserved_Attribute_6 VARCHAR(150),
Reserved_Attribute_7 VARCHAR(150),
Reserved_Attribute_8 VARCHAR(150),
Reserved_Attribute_9 VARCHAR(150),
Reserved_Attribute_10 VARCHAR(150),
Attribute_Category VARCHAR(30),
Attribute_1 VARCHAR(150),
Attribute_2 VARCHAR(150),
Attribute_3 VARCHAR(150),
Attribute_4 VARCHAR(150),
Attribute_5 VARCHAR(150),
Attribute_6 VARCHAR(150),
Attribute_7 VARCHAR(150),
Attribute_8 VARCHAR(150),
Attribute_9 VARCHAR(150),
Attribute_10 VARCHAR(150),
PRIMARY KEY(rowid));
Error:
Row size too large. The maximum row size for the used table type, not counting BLOBs, is 65535. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs
Do not splay an array across columns.
For example, you are allowing for 10 attributes. Have you thought about what to do when you need 11? Instead of having 10 columns, have a separate table with any number of attributes for each PJC_TXN_XFACE_STAGE_ALL.
Ditto for costs and maybe other things.
Dates should be in DATE datatype, not VARCHAR(100)
I see cases of number, name, id -- shouldn't those be in another table, with only the id here?
The 8-byte DOUBLE is rarely a good datatype for an ID. What do the IDs look like?
Say NOT NULL where appropriate.
If that does not shrink the schema enough to fit into the limitation; let's see the new CREATE TABLE and we can look for more fixes. (There are other techniques that I have yet to mention.)
Hi I have created a table and now creating a stored procedure.
CREATE PROCEDURE p_order_insert (in in_agent_id Varchar(10),in in_rate_city varchar(15),in in_sendername varchar(50),in in_senderaddress1 varchar(50),in in_senderaddress2 varchar(50),in in_senderaddress3 varchar(50),in in_senderaddress4 varchar(50),in in_sendercity varchar(50),in in_senderstate varchar(50),in in_senderpostcode varchar(10),in in_sendercountry varchar(15),in in_receivername varchar(50),in in_receiveraddress1 varchar(50),in in_receiveraddress2 varchar(50),in in_receiveraddress3 varchar(50),in in_receiveraddress4 varchar(50),in in_receivercity varchar(50),in in_receiverstate varchar(50),in in_receiverpostcode varchar(10),in in_receivercountry varchar(15),in in_item1_description varchar(80),in in_item2_description varchar(80),in in_item3_description varchar(80),in in_item4_description varchar(80),in in_item5_description varchar(80),in in_item6_description varchar(80),in in_item1_quantity int,in in_item2_quantity int,in in_item3_quantity int,in in_item4_quantity int,in in_item5_quantity int,in in_item6_quantity int,in in_item1_weight double,in in_item2_weight double,in in_item3_weight double,in in_item4_weight double,in in_item5_weight double,in in_item6_weight double,in in_item1_value double,in in_item2_value double,in in_item3_value double,in in_item4_value double,in in_item5_value double,in in_item6_value double,in in_order_status Varchar(10),in in_total_price double,in in_agent_commission double,in in_payment_received Varchar(10), OUT out_awb_ref_id Varchar (10)) BEGIN
INSERT INTO hvp_order_master (agent_id, rate_city, sendername, senderaddress1, senderaddress2, senderaddress3, senderaddress4, sendercity, senderstate, senderpostcode, sendercountry, receivername, receiveraddress1, receiveraddress2, receiveraddress3, receiveraddress4, receivercity, receiverstate, receiverpostcode, receivercountry, item1_description, item2_description, item3_description, item4_description, item5_description, item6_description, item1_quantity, item2_quantity, item3_quantity, item4_quantity, item5_quantity, item6_quantity, item1_weight, item2_weight, item3_weight, item4_weight, item5_weight, item6_weight, item1_value, item2_value, item3_value, item4_value, item5_value, item6_value, order_status, total_price, agent_commission, payment_received)
VALUES
(in_agent_id, in_rate_city, in_sendername, in_senderaddress1, in_senderaddress2, in_senderaddress3, in_senderaddress4, in_sendercity, in_senderstate, in_senderpostcode, in_sendercountry, in_receivername, in_receiveraddress1, in_receiveraddress2, in_receiveraddress3, in_receiveraddress4, in_receivercity, in_receiverstate, in_receiverpostcode, in_receivercountry, in_item1_description, in_item2_description, in_item3_description, in_item4_description, in_item5_description, in_item6_description, in_item1_quantity, in_item2_quantity, in_item3_quantity, in_item4_quantity, in_item5_quantity, in_item6_quantity, in_item1_weight, in_item2_weight, in_item3_weight, in_item4_weight, in_item5_weight, in_item6_weight, in_item1_value, in_item2_value, in_item3_value, in_item4_value, in_item5_value, in_item6_value, in_order_status, in_total_price, in_agent_commission, in_payment_received); END;;
However, I am getting
1064 - Erreur de syntaxe près de '' à la ligne 6 there is no such issue which I can see.
Could someone help?
When you included the DELIMITER wrapper it saves, like below.
In addition I am sure you have a poor schema design.
DROP PROCEDURE IF EXISTS p_order_insert;
DELIMITER $
CREATE PROCEDURE p_order_insert
(in in_agent_id Varchar(10),
in in_rate_city varchar(15),
in in_sendername varchar(50),
in in_senderaddress1 varchar(50),
in in_senderaddress2 varchar(50),
in in_senderaddress3 varchar(50),
in in_senderaddress4 varchar(50),
in in_sendercity varchar(50),
in in_senderstate varchar(50),
in in_senderpostcode varchar(10),
in in_sendercountry varchar(15),
in in_receivername varchar(50),
in in_receiveraddress1 varchar(50),
in in_receiveraddress2 varchar(50),
in in_receiveraddress3 varchar(50),
in in_receiveraddress4 varchar(50),
in in_receivercity varchar(50),
in in_receiverstate varchar(50),
in in_receiverpostcode varchar(10),
in in_receivercountry varchar(15),
in in_item1_description varchar(80),
in in_item2_description varchar(80),
in in_item3_description varchar(80),
in in_item4_description varchar(80),
in in_item5_description varchar(80),
in in_item6_description varchar(80),
in in_item1_quantity int,
in in_item2_quantity int,
in in_item3_quantity int,
in in_item4_quantity int,
in in_item5_quantity int,
in in_item6_quantity int,
in in_item1_weight double,
in in_item2_weight double,
in in_item3_weight double,
in in_item4_weight double,
in in_item5_weight double,
in in_item6_weight double,
in in_item1_value double,
in in_item2_value double,
in in_item3_value double,
in in_item4_value double,
in in_item5_value double,
in in_item6_value double,
in in_order_status Varchar(10),
in in_total_price double,
in in_agent_commission double,
in in_payment_received Varchar(10),
OUT out_awb_ref_id Varchar (10))
BEGIN
INSERT INTO hvp_order_master (agent_id, rate_city, sendername, senderaddress1, senderaddress2,
senderaddress3, senderaddress4, sendercity, senderstate, senderpostcode, sendercountry,
receivername, receiveraddress1, receiveraddress2, receiveraddress3, receiveraddress4,
receivercity, receiverstate, receiverpostcode, receivercountry, item1_description,
item2_description, item3_description, item4_description, item5_description,
item6_description, item1_quantity, item2_quantity, item3_quantity, item4_quantity,
item5_quantity, item6_quantity, item1_weight, item2_weight, item3_weight, item4_weight,
item5_weight, item6_weight, item1_value, item2_value, item3_value, item4_value, item5_value,
item6_value, order_status, total_price, agent_commission, payment_received)
SELECT
in_agent_id, in_rate_city, in_sendername, in_senderaddress1, in_senderaddress2,
in_senderaddress3, in_senderaddress4, in_sendercity, in_senderstate, in_senderpostcode,
in_sendercountry, in_receivername, in_receiveraddress1, in_receiveraddress2, in_receiveraddress3,
in_receiveraddress4, in_receivercity, in_receiverstate, in_receiverpostcode, in_receivercountry,
in_item1_description, in_item2_description, in_item3_description, in_item4_description,
in_item5_description, in_item6_description, in_item1_quantity, in_item2_quantity, in_item3_quantity,
in_item4_quantity, in_item5_quantity, in_item6_quantity, in_item1_weight, in_item2_weight,
in_item3_weight, in_item4_weight, in_item5_weight, in_item6_weight, in_item1_value, in_item2_value,
in_item3_value, in_item4_value, in_item5_value, in_item6_value, in_order_status, in_total_price,
in_agent_commission, in_payment_received;
END$$
DELIMITER ;
The need for a DELIMITER is dependent on which client-side tool you use. For PHPMyAdmin, it is not needed typically if ever.
With MySQL Workbench it is.
Add DELIMITER ## to the start. Also, at the end of your code you have the ; twice. END;; 1 is enough.
DELIMITER ##
CREATE PROCEDURE...
END##
DELIMITER;
I'm new to mysql and I'm trying to create a stored procedure but getting syntax error due to declare a variable.
The version of mysql I'm using is 5.5.43 and my procedure is:
CREATE PROCEDURE spSearch
(
p_ACTION INT,
p_PROJECT_CUSTOMER INT,
p_PROJECT_NAME VARCHAR(50),
p_PROJECT_SALESPERSON INT,
p_PROJECT_MANAGER INT,
p_PROJECT_PMF INT,
p_PROJECT_TYPE INT,
p_PROJECT_DESIGNER INT,
p_PROJECT_AANDD INT,
p_PROJECT_REFD INT,
p_PROJECT_VENDOR INT,
p_PROJECT_GENERALCONTRACTOR INT,
p_PROJECT_PUNCHLIST varchar(1),
p_PROJECT_LOCATION INT,
p_PROJECT_CLIENTTYPE INT,
p_PROJECT_INSTALLDATE VARCHAR(50),
p_PROJECT_INSTALLDATETO VARCHAR(50),
p_PROJECT_ORDERENTRYDATE VARCHAR(50),
p_PROJECT_ORDERENTRYDATETO VARCHAR(50),
p_PROJECT_MOVEINDATE VARCHAR(50),
p_PROJECT_MOVEINDATETO VARCHAR(50),
p_PROJECT_ACTIVE_FLAG VARCHAR(1)
)
BEGIN
DECLARE ABC VARCHAR(1400);
END;
I'm getting this error:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 28
Please help to remove this syntax error.
It seems that you have a problem with your delimiters. try this:
delimiter //
CREATE PROCEDURE spSearch
(
p_ACTION INT,
p_PROJECT_CUSTOMER INT,
p_PROJECT_NAME VARCHAR(50),
p_PROJECT_SALESPERSON INT,
p_PROJECT_MANAGER INT,
p_PROJECT_PMF INT,
p_PROJECT_TYPE INT,
p_PROJECT_DESIGNER INT,
p_PROJECT_AANDD INT,
p_PROJECT_REFD INT,
p_PROJECT_VENDOR INT,
p_PROJECT_GENERALCONTRACTOR INT,
p_PROJECT_PUNCHLIST varchar(1),
p_PROJECT_LOCATION INT,
p_PROJECT_CLIENTTYPE INT,
p_PROJECT_INSTALLDATE VARCHAR(50),
p_PROJECT_INSTALLDATETO VARCHAR(50),
p_PROJECT_ORDERENTRYDATE VARCHAR(50),
p_PROJECT_ORDERENTRYDATETO VARCHAR(50),
p_PROJECT_MOVEINDATE VARCHAR(50),
p_PROJECT_MOVEINDATETO VARCHAR(50),
p_PROJECT_ACTIVE_FLAG VARCHAR(1)
)
BEGIN
DECLARE ABC VARCHAR(1400);
END//
delimiter ;
I'm actually trying to insert value into table using a procedure.This is my table code
create table employeeTable(
employeeId varchar(20),
employeeName varchar(20),
qualification varchar(20),
cadre varchar(15),
age numeric(3),
sex char(1),
occupation varchar(10),
dateOfBirth date,
address varchar(50),
city varchar(15),
employeePhoto blob,
constraint pk_employeeId_employeeTable primary key(employeeId)
);
My insert procedure is
delimiter //
create procedure insertEmployee(in employeeId varchar(20),in employeeName varchar(20),
in qualification varchar(20),in cadre varchar(15),in age numeric(3),in sex char(1),
in occupation varchar(10),in dateOfBirth date,in address varchar(50),in city varchar(15),
in employeePhoto blob)
begin
insert into employeetable values(upper(employeeId),employeeName,qualification,
cadre,age,sex,occupation,
str_to_date(dateOfBirth,'%d-%m-%Y'),address,city,employeePhoto);
end;//
delimiter ;
And I'm trying to call this procedure with following parameters
call insertEmployee('A001','Murugan','Phd','Manager',12,'M','service','30-07-1994',
'30,PNG nagar,pollachi','Coimbatore',null);
But values are not getting inserted and it's showing an error #1048 - Column 'dateOfBirth' cannot be null..
What is the problem here??
delimiter //
create procedure insertEmployee(in employeeId varchar(20),in employeeName varchar(20),
in qualification varchar(20),in cadre varchar(15),in age numeric(3),in sex char(1),
in occupation varchar(10),in dateOfBirth varchar(15),in address varchar(50),in city varchar(15),
in employeePhoto blob)
begin
insert into employeetable values(upper(employeeId),employeeName,qualification,
cadre,age,sex,occupation,
str_to_date(dateOfBirth,'%d-%m-%Y'),address,city,employeePhoto);
end;//
delimiter ;
Try this procedure. You were accpeting the dateOfBirth as a date object in the parameter list. It should have been a VARCHAR as that is how it is passed to the procedure.