473,386 Members | 1,630 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

I have an error inserting data into table through store procedure??

I have created table like this...

CREATE TABLE INVOICEMASTER(INVOICEID INT IDENTITY(1,1),EXPORTER_REF INT,CONSIGNEE_REF INT,BUYER_REF INT,AGENT_REF INT,INVOICENO VARCHAR(20),INVOICEDATE DATETIME,EXPORTERSBILLREF VARCHAR(20),BUYERORDERNO VARCHAR(200),BUYERORDERDATE DATETIME,OTHER_REFERENCES VARCHAR(30),COUNTRYOFORIGIN VARCHAR(50),COUNTRYOFDESTINATION VARCHAR(50),PRECARRIAGEBY NVARCHAR(100),PLACEOFRECEIPT NVARCHAR(100),VESSEL_FLIGHTNO NVARCHAR(100),PORTOFLOADING NVARCHAR(100),PORTOFDISCHARGE NVARCHAR(100),FINALDESTINATION NVARCHAR(100),TERMSOFDELVIERYNPAYMENT NVARCHAR(400),DISCOUNTLABEL VARCHAR(100),DISCOUNTRATE DECIMAL(4,2),DISCOUNTAMOUNT DECIMAL(10,3),INVOICETOTAL DECIMAL(14,3),AMOUNTINWORDS NVARCHAR(200),LCNO NVARCHAR(200),REMARKS NVARCHAR(400),INVOICELABEL VARCHAR(100),PRIMARY KEY(INVOICEID))

CREATE TABLE INVOICECHILD1 (INVOICEREF INT REFERENCES INVOICEMASTER (INVOICEID), MARKSANDCONTAINERSNO NVARCHAR (200), NUMBEROFPKGS VARCHAR (100), DESCRIPTIONOFGOODS NVARCHAR (400),THICKNESS VARCHAR(100),COLOUR VARCHAR(50),SELECTION VARCHAR(30),SIZE NVARCHAR(300),UOM VARCHAR(10),CURRENCYDESC VARCHAR(30))

and the below is store procedure query..

CREATE PROCEDURE INSERT_INVOICE(@EXPORTER VARCHAR(150),@CONSIGNEE VARCHAR(150),@BUYER VARCHAR(150),@AGENT VARCHAR(150),@INVOICENO VARCHAR(20),@INVOICEDATE DATETIME,@EXPORTERSBILLREF VARCHAR(20),@BUYERORDERNO VARCHAR(200),@BUYERORDERDATE DATETIME,@OTHER_REFERENCES VARCHAR(30),@COUNTRYOFORIGIN VARCHAR(50),@COUNTRYOFDESTINATION VARCHAR(50),@PRECARRIAGEBY NVARCHAR(100),@PLACEOFRECEIPT NVARCHAR(100),@VESSEL_FLIGHTNO NVARCHAR(100),@PORTOFLOADING NVARCHAR(100),@PORTOFDISCHARGE NVARCHAR(100),@FINALDESTINATION NVARCHAR(100),@TERMSOFDELVIERYNPAYMENT NVARCHAR(400),@MARKSANDCONTAINERSNO NVARCHAR (200), @NUMBEROFPKGS VARCHAR (100), @DESCRIPTIONOFGOODS NVARCHAR (400),@THICKNESS VARCHAR(100),@COLOUR VARCHAR(50),@SELECTION VARCHAR(30),@SIZE NVARCHAR(300),@UOM VARCHAR(10),@CURRENCYDESC VARCHAR(30),@DISCOUNTLABEL VARCHAR(100),@DISCOUNTRATE DECIMAL(4,2),@DISCOUNTAMOUNT DECIMAL(10,3),@INVOICETOTAL DECIMAL(14,3),@AMOUNTINWORDS NVARCHAR(200),@LCNO NVARCHAR(200),@REMARKS NVARCHAR(400),@INVOICELABEL VARCHAR(100))
AS
BEGIN TRANSACTION

DECLARE @EXPORTER_REF AS INT
SET @EXPORTER_REF = 0
SELECT @EXPORTER_REF = EXPORTERID FROM EXPORTER WHERE EXPORTERNAME=@EXPORTER

DECLARE @CONSIGNEE_REF AS INT
SET @CONSIGNEE_REF = 0
SELECT @CONSIGNEE_REF = CONSIGNEEID FROM CONSIGNEE WHERE CONSIGNEENAME=@CONSIGNEE

DECLARE @BUYER_REF AS INT
SET @BUYER_REF = 0
SELECT @BUYER_REF = BUYERID FROM BUYER WHERE BUYERNAME=@BUYER

DECLARE @AGENT_REF AS INT
SET @AGENT_REF = 0
SELECT @AGENT_REF = AGENTID FROM AGENT WHERE AGENTNAME=@AGENT

INSERT INTO INVOICEMASTER(EXPORTER_REF,CONSIGNEE_REF,BUYER_REF ,AGENT_REF,INVOICENO,INVOICEDATE,EXPORTERSBILLREF, BUYERORDERNO,BUYERORDERDATE,OTHER_REFERENCES,COUNT RYOFORIGIN,COUNTRYOFDESTINATION,PRECARRIAGEBY,PLAC EOFRECEIPT,VESSEL_FLIGHTNO,PORTOFLOADING,PORTOFDIS CHARGE,FINALDESTINATION,TERMSOFDELVIERYNPAYMENT,DI SCOUNTLABEL,DISCOUNTRATE,DISCOUNTAMOUNT,INVOICETOT AL,AMOUNTINWORDS,LCNO,REMARKS,INVOICELABEL) VALUES (@EXPORTER_REF,@CONSIGNEE_REF,@BUYER_REF,@AGENT_RE F,@INVOICENO,@INVOICEDATE,@EXPORTERSBILLREF,@BUYER ORDERNO,@BUYERORDERDATE,@OTHER_REFERENCES,@COUNTRY OFORIGIN,@COUNTRYOFDESTINATION,@PRECARRIAGEBY,@PLA CEOFRECEIPT,@VESSEL_FLIGHTNO,@PORTOFLOADING,@PORTO FDISCHARGE,@FINALDESTINATION,@TERMSOFDELVIERYNPAYM ENT,@DISCOUNTLABEL,@DISCOUNTRATE,@DISCOUNTAMOUNT,@ INVOICETOTAL,@AMOUNTINWORDS,@LCNO,@REMARKS,@INVOIC ELABEL)

DECLARE @INVOICEID CHAR(6)
SELECT @INVOICEID = MAX(INVOICEID) FROM INVOICEMASTER
/*@INVOICEID = (SELECT * FROM INVOICERETURN WHERE INVDATE=@INVOICEDATE AND INVNO=@INVOICENO AND INVTOTAL=@INVOICETOTAL)*/



INSERT INTO INVOICECHILD1(INVOICEREF,MARKSANDCONTAINERSNO,NUMB EROFPKGS,DESCRIPTIONOFGOODS,THICKNESS,COLOUR,SELEC TION,SIZE,UOM,CURRENCYDESC)
VALUES (@INVOICEID,@MARKSANDCONTAINERSNO,@NUMBEROFPKGS,@D ESCRIPTIONOFGOODS,@THICKNESS,@COLOUR,@SELECTION,@S IZE,@UOM,@CURRENCYDESC)
COMMIT TRANSACTION
GO

The problem with above query is some data type conversion exist.. what exactly is that,i cant find out??

Any help would ease my development work!!!

Thanks in Advance..
Apr 27 '10 #1
0 1141

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: CJM | last post by:
I have page that starts a transaction and runs several StoredProcs before committing or rollingback. An initial SP create a header records, and then the code goes into a loop and runs 4 other SP's...
2
by: serge | last post by:
My project is to automate testing of Stored Procedures of type SELECT (at least for now). I want to create a table where each stored procedure's input parameter values are entered and in another...
17
by: MLH | last post by:
A97 Topic: If there is a way to preserve the values assigned to global variables when an untrapped runtime error occurs? I don't think there is, but I thought I'd ask. During development, I'm...
7
by: Leon Shaw | last post by:
Need help understanding? Server Error in '/solo' Application. ---------------------------------------------------------------------------- ---- Object must implement IConvertible....
3
by: Adriano | last post by:
Hello, when I try to print something, either DataGrid or from Crystal Report viever the folowing error message appears and cancels printing: Object reference not set to an instance of an...
6
by: sara | last post by:
I have a procedure to automate bringing several Excel files into our Access tables, on a daily basis. The problem is that if the user has a problem, and tries to run the import again (maybe 3...
1
by: ing42 | last post by:
I have a problem with inserting records into table when an indexed view is based on it. Table has text field (without it there is no problem, but I need it). Here is a sample code: USE test GO...
1
by: ILCSP | last post by:
Hello, I'm trying to accomplish 3 things with one stored procedure. I'm trying to search for a record in table X, use the outcome of that search to insert another record in table Y and then exec...
2
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
0
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.