473,587 Members | 2,489 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

1 New Member
I have created table like this...

CREATE TABLE INVOICEMASTER(I NVOICEID INT IDENTITY(1,1),E XPORTER_REF INT,CONSIGNEE_R EF INT,BUYER_REF INT,AGENT_REF INT,INVOICENO VARCHAR(20),INV OICEDATE DATETIME,EXPORT ERSBILLREF VARCHAR(20),BUY ERORDERNO VARCHAR(200),BU YERORDERDATE DATETIME,OTHER_ REFERENCES VARCHAR(30),COU NTRYOFORIGIN VARCHAR(50),COU NTRYOFDESTINATI ON VARCHAR(50),PRE CARRIAGEBY NVARCHAR(100),P LACEOFRECEIPT NVARCHAR(100),V ESSEL_FLIGHTNO NVARCHAR(100),P ORTOFLOADING NVARCHAR(100),P ORTOFDISCHARGE NVARCHAR(100),F INALDESTINATION NVARCHAR(100),T ERMSOFDELVIERYN PAYMENT NVARCHAR(400),D ISCOUNTLABEL VARCHAR(100),DI SCOUNTRATE DECIMAL(4,2),DI SCOUNTAMOUNT DECIMAL(10,3),I NVOICETOTAL DECIMAL(14,3),A MOUNTINWORDS NVARCHAR(200),L CNO NVARCHAR(200),R EMARKS NVARCHAR(400),I NVOICELABEL VARCHAR(100),PR IMARY KEY(INVOICEID))

CREATE TABLE INVOICECHILD1 (INVOICEREF INT REFERENCES INVOICEMASTER (INVOICEID), MARKSANDCONTAIN ERSNO NVARCHAR (200), NUMBEROFPKGS VARCHAR (100), DESCRIPTIONOFGO ODS NVARCHAR (400),THICKNESS VARCHAR(100),CO LOUR VARCHAR(50),SEL ECTION VARCHAR(30),SIZ E NVARCHAR(300),U OM VARCHAR(10),CUR RENCYDESC VARCHAR(30))

and the below is store procedure query..

CREATE PROCEDURE INSERT_INVOICE( @EXPORTER VARCHAR(150),@C ONSIGNEE VARCHAR(150),@B UYER VARCHAR(150),@A GENT VARCHAR(150),@I NVOICENO VARCHAR(20),@IN VOICEDATE DATETIME,@EXPOR TERSBILLREF VARCHAR(20),@BU YERORDERNO VARCHAR(200),@B UYERORDERDATE DATETIME,@OTHER _REFERENCES VARCHAR(30),@CO UNTRYOFORIGIN VARCHAR(50),@CO UNTRYOFDESTINAT ION VARCHAR(50),@PR ECARRIAGEBY NVARCHAR(100),@ PLACEOFRECEIPT NVARCHAR(100),@ VESSEL_FLIGHTNO NVARCHAR(100),@ PORTOFLOADING NVARCHAR(100),@ PORTOFDISCHARGE NVARCHAR(100),@ FINALDESTINATIO N NVARCHAR(100),@ TERMSOFDELVIERY NPAYMENT NVARCHAR(400),@ MARKSANDCONTAIN ERSNO NVARCHAR (200), @NUMBEROFPKGS VARCHAR (100), @DESCRIPTIONOFG OODS NVARCHAR (400),@THICKNES S VARCHAR(100),@C OLOUR VARCHAR(50),@SE LECTION VARCHAR(30),@SI ZE NVARCHAR(300),@ UOM VARCHAR(10),@CU RRENCYDESC VARCHAR(30),@DI SCOUNTLABEL VARCHAR(100),@D ISCOUNTRATE DECIMAL(4,2),@D ISCOUNTAMOUNT 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=@E XPORTER

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=@BUYE R

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

INSERT INTO INVOICEMASTER(E XPORTER_REF,CON SIGNEE_REF,BUYE R_REF,AGENT_REF ,INVOICENO,INVO ICEDATE,EXPORTE RSBILLREF,BUYER ORDERNO,BUYEROR DERDATE,OTHER_R EFERENCES,COUNT RYOFORIGIN,COUN TRYOFDESTINATIO N,PRECARRIAGEBY ,PLACEOFRECEIPT ,VESSEL_FLIGHTN O,PORTOFLOADING ,PORTOFDISCHARG E,FINALDESTINAT ION,TERMSOFDELV IERYNPAYMENT,DI SCOUNTLABEL,DIS COUNTRATE,DISCO UNTAMOUNT,INVOI CETOTAL,AMOUNTI NWORDS,LCNO,REM ARKS,INVOICELAB EL) VALUES (@EXPORTER_REF, @CONSIGNEE_REF, @BUYER_REF,@AGE NT_REF,@INVOICE NO,@INVOICEDATE ,@EXPORTERSBILL REF,@BUYERORDER NO,@BUYERORDERD ATE,@OTHER_REFE RENCES,@COUNTRY OFORIGIN,@COUNT RYOFDESTINATION ,@PRECARRIAGEBY ,@PLACEOFRECEIP T,@VESSEL_FLIGH TNO,@PORTOFLOAD ING,@PORTOFDISC HARGE,@FINALDES TINATION,@TERMS OFDELVIERYNPAYM ENT,@DISCOUNTLA BEL,@DISCOUNTRA TE,@DISCOUNTAMO UNT,@INVOICETOT AL,@AMOUNTINWOR DS,@LCNO,@REMAR KS,@INVOICELABE L)

DECLARE @INVOICEID CHAR(6)
SELECT @INVOICEID = MAX(INVOICEID) FROM INVOICEMASTER
/*@INVOICEID = (SELECT * FROM INVOICERETURN WHERE INVDATE=@INVOIC EDATE AND INVNO=@INVOICEN O AND INVTOTAL=@INVOI CETOTAL)*/



INSERT INTO INVOICECHILD1(I NVOICEREF,MARKS ANDCONTAINERSNO ,NUMBEROFPKGS,D ESCRIPTIONOFGOO DS,THICKNESS,CO LOUR,SELECTION, SIZE,UOM,CURREN CYDESC)
VALUES (@INVOICEID,@MA RKSANDCONTAINER SNO,@NUMBEROFPK GS,@DESCRIPTION OFGOODS,@THICKN ESS,@COLOUR,@SE LECTION,@SIZE,@ UOM,@CURRENCYDE SC)
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 1149

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

Similar topics

2
12902
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 once per iteration. I'd had it working previous, but now I have changed one of the SPs and the order that they all run in... Structure of Code:...
2
4235
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 table the expected result value(s) are entered when executed against a sample database containing manually entered and verified data. My...
17
5610
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 constantly running tests on imperfect code. On of the cumbersome jobs encountered is reassigning global vars their values after a close encounter with...
7
1654
by: Leon Shaw | last post by:
Need help understanding? Server Error in '/solo' Application. ---------------------------------------------------------------------------- ---- Object must implement IConvertible. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the...
3
2428
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 object :(((( Anyone pls help me to solve this problem!!! thanks in advance,
6
8174
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 files imported then there was a data problem and they want to re-import after fixing the problem), I can't get the Error handling to fire if the user...
1
3709
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 CREATE TABLE dbo.aTable ( INT NOT NULL
1
2429
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 another stored procedure and use the outcome of that stored procedure to update the record in table Y. I have this stored procedure (stA) CREATE...
2
19443
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 will be writing this article intended for those who are in the same level, or maybe lower, of my technical knowledge. I would be using layman's...
0
2897
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 will be writing this article intended for those who are in the same level, or maybe lower, of my technical knowledge. I would be using layman's...
0
7923
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8216
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8349
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7974
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8221
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6629
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3882
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2364
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1455
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.