sqlQuery for create new Item

09/20/2024 14:35 lu><S#1
Hi all,
i try to make a sqlQuery for creating a new row in _RefObjItem and take the generated ID from the column ID and paste in _RefObjCommon a new line and in column Link it paste die column ID from the new line in _RefObjItem ... i try all but all time i get the faildure:

Code:
Msg 109, Level 15, State 1, Line 1
There are more columns in the INSERT statement than values specified in the VALUES clause. The number of values in the VALUES clause must match the number of columns specified in the INSERT statement.

Completion time: 2024-09-20T14:31:15.0465060+02:00
Here is the sqlQuery that i made:
Quote:
INSERT INTO [SILKROAD_R_SHARD].[dbo].[_RefObjItem]
(ID, MaxStack, ReqGender, ReqStr, ReqInt, ItemClass, SetID, Dur_L, Dur_U, PD_L, PD_U, PDInc, ER_L, ER_U, ERInc, PAR_L, PAR_U, PARInc, BR_L, BR_U, MD_L, MD_U, MDInc, MAR_L, MAR_U, MARInc, PDStr_L, PDStr_U, MDInt_L, MDInt_U, Quivered, Ammo1_TID4, Ammo2_TID4, Ammo3_TID4, Ammo4_TID4, Ammo5_TID4, SpeedClass, TwoHanded, [Range], PAttackMin_L, PAttackMin_U, PAttackMax_L, PAttackMax_U, PAttackInc, MAttackMin_L, MAttackMin_U, MAttackMax_L, MAttackMax_U, MAttackInc, PAStrMin_L, PAStrMin_U, PAStrMax_L, PAStrMax_U, MAInt_Min_L, MAInt_Min_U, MAInt_Max_L, MAInt_Max_U, HR_L, HR_U, HRInc, CHR_L, CHR_U, Param1, Desc1_128, Param2, Desc2_128, Param3, Desc3_128, Param4, Desc4_128, Param5, Desc5_128, Param6, Desc6_128, Param7, Desc7_128, Param8, Desc8_128, Param9, Desc9_128, Param10, Desc10_128, Param11, Desc11_128, Param12, Desc12_128, Param13, Desc13_128, Param14, Desc14_128, Param15, Desc15_128, Param16, Desc16_128, Param17, Desc17_128, Param18, Desc18_128, Param19, Desc19_128, Param20, Desc20_128, MaxMagicOptCount, ChildItemCount, [Link])
VALUES
(1, 2, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5000, 1, -1, 'RESURRECT', -1, 'xxx', -1, 'xxx', -1, 'xxx', -1, 'xxx', -1, 'xxx', -1, 'xxx', -1, 'xxx', -1, 'xxx', -1, 'xxx', -1, 'xxx', -1, 'xxx', -1, 'xxx', -1, 'xxx', 0, 0, 0);


DECLARE @NewID INT;
SET @NewID = SCOPE_IDENTITY();


INSERT INTO [SILKROAD_R_SHARD].[dbo].[_RefObjCommon]
(Service, ID, CodeName128, ObjName128, OrgObjCodeName128, NameStrID128, DescStrID128, CashItem, Bionic, TypeID1, TypeID2, TypeID3, TypeID4, DecayTime, Country, Rarity, CanTrade, CanSell, CanBuy, CanBorrow, CanDrop, CanPick, CanRepair, CanRevive, CanUse, CanThrow, Price, CostRepair, CostRevive, CostBorrow, KeepingFee, SellPrice, ReqLevelType1, ReqLevel1, ReqLevelType2, ReqLevel2, ReqLevelType3, ReqLevel3, ReqLevelType4, ReqLevel4, MaxContain, RegionID, Dir, OffsetX, OffsetY, OffsetZ, Speed1, Speed2, Scale, BCHeight, BCRadius, EventID, AssocFileObj128, AssocFileDrop128, AssocFileIcon128, AssocFile1_128, AssocFile2_128, [Link])
VALUES
(1, @NewID, 'ITEM_MALL_NAME', 'NAME', 'xxx', 'SN_ITEM_MALL_NAME', 'SN_ITEM_MALL_NAME_TT_DESC', 0, 0, 3, 3, 3, 1, 180000, 3, 0, 1, 1, 1, 3, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, 0, 0, 0, 0, 0, 0, 100, 0, 0, 0, 'xxx', 'item\etc\drop_mall_scroll.bsr', 'item\kern\name.ddj', 'xxx', 'xxx', @NewID);


SELECT * FROM [SILKROAD_R_SHARD].[dbo].[_RefObjItem] WHERE ID = @NewID;
SELECT * FROM [SILKROAD_R_SHARD].[dbo].[_RefObjCommon] WHERE ID = @NewID;

Anybody has a idea or could help me to fix it?
I know i can put the lines manuel but i want to make it over sqlQuery it has some reasons...

it would be really really nice if someone could help me

now i just try to create only in _RefObjItem a new line with this Query but it also failed and i get this error:
Code:
Msg 109, Level 15, State 1, Line 1
There are more columns in the INSERT statement than values specified in the VALUES clause. The number of values in the VALUES clause must match the number of columns specified in the INSERT statement.
Quote:
INSERT INTO _RefObjItem (
MaxStack, ReqGender, ReqStr, ReqInt, ItemClass, SetID, Dur_L, Dur_U, PD_L, PD_U, PDInc,
ER_L, ER_U, ERInc, PAR_L, PAR_U, PARInc, BR_L, BR_U, MD_L, MD_U, MDInc, MAR_L, MAR_U, MARInc,
PDStr_L, PDStr_U, MDInt_L, MDInt_U, Quivered, Ammo1_TID4, Ammo2_TID4, Ammo3_TID4, Ammo4_TID4,
Ammo5_TID4, SpeedClass, TwoHanded, Range, PAttackMin_L, PAttackMin_U, PAttackMax_L, PAttackMax_U,
PAttackInc, MAttackMin_L, MAttackMin_U, MAttackMax_L, MAttackMax_U, MAttackInc, PAStrMin_L, PAStrMin_U,
PAStrMax_L, PAStrMax_U, MAInt_Min_L, MAInt_Min_U, MAInt_Max_L, MAInt_Max_U, HR_L, HR_U, HRInc, CHR_L, CHR_U,
Param1, Desc1_128, Param2, Desc2_128, Param3, Desc3_128, Param4, Desc4_128, Param5, Desc5_128, Param6, Desc6_128,
Param7, Desc7_128, Param8, Desc8_128, Param9, Desc9_128, Param10, Desc10_128, Param11, Desc11_128, Param12, Desc12_128,
Param13, Desc13_128, Param14, Desc14_128, Param15, Desc15_128, Param16, Desc16_128, Param17, Desc17_128,
Param18, Desc18_128, Param19, Desc19_128, Param20, Desc20_128, MaxMagicOptCount, ChildItemCount, Link
) VALUES (
1000, 2, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 820, 'HP회복양', 0, 'HP회복양(%)', 820, 'MP회복양',
0, 'MP회복양(%)', -1, 'xxx', -1, 'xxx', -1, 'xxx', -1, 'xxx', -1, 'xxx', -1, 'xxx', -1, 'xxx', -1,
'xxx', -1, 'xxx', -1, 'xxx', -1, 'xxx', -1, 'xxx', -1, 'xxx', -1, 'xxx', -1, 'xxx', -1, 'xxx', 0, 0, 0
);
09/25/2024 01:04 Devsome#2
#moved
09/25/2024 06:50 JellyBitz#3
This query creates an instant return scroll.
You may learn something out from it.

Quicknote: I prefer to use IDENT_CURRENT since it doesn't really matter at our case.

PHP Code:
USE [SRO_VT_SHARD]

-- 
Basic Setup
DECLARE @@CodeName128 VARCHAR(129) = 'ITEM_RETURN_SCROLL_SYSTEM_01'
DECLARE @@IconDDJ VARCHAR(129) = 'item\etc\mall_return_scroll.ddj'
DECLARE @@DropBSR VARCHAR(129) = 'item\etc\drop_mall_scroll.bsr'

-- Add Item
DECLARE @@RefObjItem_ID INTEGER IDENT_CURRENT('_RefObjItem')
INSERT INTO [_RefObjItem]
    ([
MaxStack],[ReqGender],[ReqStr],[ReqInt],[ItemClass],[SetID],[Dur_L],[Dur_U],[PD_L],[PD_U],[PDInc],[ER_L],[ER_U],[ERInc],[PAR_L],[PAR_U],[PARInc],[BR_L],[BR_U],[MD_L],[MD_U],[MDInc],[MAR_L],[MAR_U],[MARInc],[PDStr_L],[PDStr_U],[MDInt_L],[MDInt_U],[Quivered],[Ammo1_TID4],[Ammo2_TID4],[Ammo3_TID4],[Ammo4_TID4],[Ammo5_TID4],[SpeedClass],[TwoHanded],[Range],[PAttackMin_L],[PAttackMin_U],[PAttackMax_L],[PAttackMax_U],[PAttackInc],[MAttackMin_L],[MAttackMin_U],[MAttackMax_L],[MAttackMax_U],[MAttackInc],[PAStrMin_L],[PAStrMin_U],[PAStrMax_L],[PAStrMax_U],[MAInt_Min_L],[MAInt_Min_U],[MAInt_Max_L],[MAInt_Max_U],[HR_L],[HR_U],[HRInc],[CHR_L],[CHR_U],[Param1],[Desc1_128],[Param2],[Desc2_128],[Param3],[Desc3_128],[Param4],[Desc4_128],[Param5],[Desc5_128],[Param6],[Desc6_128],[Param7],[Desc7_128],[Param8],[Desc8_128],[Param9],[Desc9_128],[Param10],[Desc10_128],[Param11],[Desc11_128],[Param12],[Desc12_128],[Param13],[Desc13_128],[Param14],[Desc14_128],[Param15],[Desc15_128],[Param16],[Desc16_128],[Param17],[Desc17_128],[Param18],[Desc18_128],[Param19],[Desc19_128],[Param20],[Desc20_128],[MaxMagicOptCount],[ChildItemCount],[Link])
VALUES
    
(9999,2,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'????',1,'??????',-1,'RESURRECT',-1,'xxx',-1,'xxx',-1,'xxx',-1,'xxx',-1,'xxx',-1,'xxx',-1,'xxx',-1,'xxx',-1,'xxx',-1,'xxx',-1,'xxx',-1,'xxx',-1,'xxx',-1,'xxx',-1,'xxx',-1,'xxx',-1,'xxx',0,0,0)

INSERT INTO [_RefObjCommon]
    ([
Service],[CodeName128],[ObjName128],[OrgObjCodeName128],[NameStrID128],[DescStrID128],[CashItem],[Bionic],[TypeID1],[TypeID2],[TypeID3],[TypeID4],[DecayTime],[Country],[Rarity],[CanTrade],[CanSell],[CanBuy],[CanBorrow],[CanDrop],[CanPick],[CanRepair],[CanRevive],[CanUse],[CanThrow],[Price],[CostRepair],[CostRevive],[CostBorrow],[KeepingFee],[SellPrice],[ReqLevelType1],[ReqLevel1],[ReqLevelType2],[ReqLevel2],[ReqLevelType3],[ReqLevel3],[ReqLevelType4],[ReqLevel4],[MaxContain],[RegionID],[Dir],[OffsetX],[OffsetY],[OffsetZ],[Speed1],[Speed2],[Scale],[BCHeight],[BCRadius],[EventID],[AssocFileObj128],[AssocFileDrop128],[AssocFileIcon128],[AssocFile1_128],[AssocFile2_128],[Link])
VALUES
    
(1,@@CodeName128,'Scroll for New Systems','xxx',CONCAT('SN_',@@CodeName128),CONCAT('SN_',@@CodeName128,'_TT_DESC'),1,0,3,3,3,1,180000,3,0,1,1,1,255,0,1,0,0,1,0,0,0,0,0,0,0,-1,0,-1,0,-1,0,-1,0,-1,0,0,0,0,0,0,0,100,0,0,0,'xxx',@@DropBSR,@@IconDDJ,'xxx','xxx',@@RefObjItem_ID+1
10/22/2024 19:46 romio100#4
Quote:
BEGIN TRY
INSERT INTO [SILKROAD_R_SHARD].[dbo].[_RefObjItem] (ID, MaxStack, ReqGender, ReqStr, ReqInt, ItemClass, SetID, Dur_L, Dur_U, PD_L, PD_U, PDInc, ER_L, ER_U, ERInc, PAR_L, PAR_U, PARInc, BR_L, BR_U, MD_L, MD_U, MDInc, MAR_L, MAR_U, MARInc, PDStr_L, PDStr_U, MDInt_L, MDInt_U, Quivered, Ammo1_TID4, Ammo2_TID4, Ammo3_TID4, Ammo4_TID4, Ammo5_TID4, SpeedClass, TwoHanded, [Range], PAttackMin_L, PAttackMin_U, PAttackMax_L, PAttackMax_U, PAttackInc, MAttackMin_L, MAttackMin_U, MAttackMax_L, MAttackMax_U, MAttackInc, PAStrMin_L, PAStrMin_U, PAStrMax_L, PAStrMax_U, MAInt_Min_L, MAInt_Min_U, MAInt_Max_L, MAInt_Max_U, HR_L, HR_U, HRInc, CHR_L, CHR_U, Param1, Desc1_128, Param2, Desc2_128, Param3, Desc3_128, Param4, Desc4_128, Param5, Desc5_128, Param6, Desc6_128, Param7, Desc7_128, Param8, Desc8_128, Param9, Desc9_128, Param10, Desc10_128, Param11, Desc11_128, Param12, Desc12_128, Param13, Desc13_128, Param14, Desc14_128, Param15, Desc15_128, Param16, Desc16_128, Param17, Desc17_128, Param18, Desc18_128, Param19, Desc19_128, Param20, Desc20_128, MaxMagicOptCount, ChildItemCount, [Link])
VALUES
(1, 2, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5000, 1, -1, 'RESURRECT', -1, 'xxx', -1, 'xxx', -1, 'xxx', -1, 'xxx', -1, 'xxx', -1, 'xxx', -1, 'xxx', -1, 'xxx', -1, 'xxx', -1, 'xxx', -1, 'xxx', -1, 'xxx', -1, 'xxx', 0, 0, 0);

DECLARE @NewID INT;
SET @NewID = SCOPE_IDENTITY();

INSERT INTO [SILKROAD_R_SHARD].[dbo].[_RefObjCommon]
(Service, ID, CodeName128, ObjName128, OrgObjCodeName128, NameStrID128, DescStrID128, CashItem, Bionic, TypeID1, TypeID2, TypeID3, TypeID4, DecayTime, Country, Rarity, CanTrade, CanSell, CanBuy, CanBorrow, CanDrop, CanPick, CanRepair, CanRevive, CanUse, CanThrow, Price, CostRepair, CostRevive, CostBorrow, KeepingFee, SellPrice, ReqLevelType1, ReqLevel1, ReqLevelType2, ReqLevel2, ReqLevelType3, ReqLevel3, ReqLevelType4, ReqLevel4, MaxContain, RegionID, Dir, OffsetX, OffsetY, OffsetZ, Speed1, Speed2, Scale, BCHeight, BCRadius, EventID, AssocFileObj128, AssocFileDrop128, AssocFileIcon128, AssocFile1_128, AssocFile2_128, [Link])
VALUES
(1, @NewID, 'ITEM_MALL_NAME', 'NAME', 'xxx', 'SN_ITEM_MALL_NAME', 'SN_ITEM_MALL_NAME_TT_DESC', 0, 0, 3, 3, 3, 1, 180000, 3, 0, 1, 1, 1, 3, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, 0, 0, 0, 0, 0, 0, 100, 0, 0, 0, 'xxx', 'item\etc\drop_mall_scroll.bsr', 'item\kern\name.ddj', 'xxx', 'xxx', @NewID);

SELECT * FROM [SILKROAD_R_SHARD].[dbo].[_RefObjItem] WHERE ID = @NewID;
SELECT * FROM [SILKROAD_R_SHARD].[dbo].[_RefObjCommon] WHERE ID = @NewID;
END TRY
BEGIN CATCH
SELECT ERROR_MESSAGE() AS ErrorMessage;
END CATCH;
The error has been corrected. The code works with you.

BEGIN TRY
INSERT INTO _RefObjItem (
MaxStack, ReqGender, ReqStr, ReqInt, ItemClass, SetID,
Dur_L, Dur_U, PD_L, PD_U, PDInc, ER_L, ER_U, ERInc,
PAR_L, PAR_U, PARInc, BR_L, BR_U, MD_L, MD_U, MDInc,
MAR_L, MAR_U, MARInc, PDStr_L, PDStr_U, MDInt_L,
MDInt_U, Quivered, Ammo1_TID4, Ammo2_TID4, Ammo3_TID4,
Ammo4_TID4, Ammo5_TID4, SpeedClass, TwoHanded,
[Range], PAttackMin_L, PAttackMin_U, PAttackMax_L,
PAttackMax_U, PAttackInc, MAttackMin_L, MAttackMin_U,
MAttackMax_L, MAttackMax_U, MAttackInc, PAStrMin_L,
PAStrMin_U, PAStrMax_L, PAStrMax_U, MAInt_Min_L,
MAInt_Min_U, MAInt_Max_L, MAInt_Max_U, HR_L, HR_U,
HRInc, CHR_L, CHR_U, Param1, Desc1_128, Param2,
Desc2_128, Param3, Desc3_128, Param4, Desc4_128,
Param5, Desc5_128, Param6, Desc6_128, Param7,
Desc7_128, Param8, Desc8_128, Param9, Desc9_128,
Param10, Desc10_128, Param11, Desc11_128, Param12,
Desc12_128, Param13, Desc13_128, Param14, Desc14_128,
Param15, Desc15_128, Param16, Desc16_128, Param17,
Desc17_128, Param18, Desc18_128, Param19, Desc19_128,
Param20, Desc20_128, MaxMagicOptCount, ChildItemCount,
[Link]
) VALUES (
1000, 2, 0, 0, 5, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
820, 'HP회복양', 0, 'HP회복양(%)', 820,
'MP회복양', 0, 'MP회복양(%)', -1, 'xxx',
-1, 'xxx', -1, 'xxx', -1, 'xxx',
-1, 'xxx', -1, 'xxx', -1, 'xxx',
-1, 'xxx', -1, 'xxx', -1, 'xxx',
-1, 'xxx', -1, 'xxx', -1, 'xxx',
-1, 'xxx', -1, 'xxx', 0, 0, 0
);