473,407 Members | 2,676 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,407 software developers and data experts.

Stored procedure problem

This is probably a very simple question but i am having problems with a
stored procedure syntax.

I want to insert into a Datatable ("Orders") "Name" and "Address" from a
datatable called "customer"
with the parameters customerId = @CustomerId

I also want to insert into the same Datatable ("orders") at the same time
"Name" and "Cost"
from a datatable called "products". The input parameter for this is cartID =
@cartId

I have tried this but it doesnt seem to work. Can anyone tell me where i am
going wrong.

CREATE PROCEDURE SP_CreateOrder
(@CustomerID Varchar (50), @CartID Char (36))

AS

INSERT INTO Orders (Name, Address, Name, Cost)

SELECT customer.Name, customer.Address, products.Name, products.Cost

FROM Customer AND Products Join ShoppingCart ON Products.ProductID =
ShoppingCart.ProductID

WHERE ShoppingCart.CartID = @CartID AND customerId = @CustomerId

--
Message posted via DotNetMonster.com
http://www.dotnetmonster.com/Uwe/For...p-net/200511/1
Nov 28 '05 #1
4 1098
Your FROM clause in invalid. Look up T-SQL syntax for joins in any resource
available to you. It is hard to give a more precise advise without knowing
your tables structure and what exactly you want to achieve.

Eliyahu

"martinharvey via DotNetMonster.com" <u14945@uwe> wrote in message
news:5807489da7800@uwe...
This is probably a very simple question but i am having problems with a
stored procedure syntax.

I want to insert into a Datatable ("Orders") "Name" and "Address" from a
datatable called "customer"
with the parameters customerId = @CustomerId

I also want to insert into the same Datatable ("orders") at the same time
"Name" and "Cost"
from a datatable called "products". The input parameter for this is cartID
=
@cartId

I have tried this but it doesnt seem to work. Can anyone tell me where i
am
going wrong.

CREATE PROCEDURE SP_CreateOrder
(@CustomerID Varchar (50), @CartID Char (36))

AS

INSERT INTO Orders (Name, Address, Name, Cost)

SELECT customer.Name, customer.Address, products.Name, products.Cost

FROM Customer AND Products Join ShoppingCart ON Products.ProductID =
ShoppingCart.ProductID

WHERE ShoppingCart.CartID = @CartID AND customerId = @CustomerId

--
Message posted via DotNetMonster.com
http://www.dotnetmonster.com/Uwe/For...p-net/200511/1

Nov 28 '05 #2
Dear martinharvey,

(via:DotNetMonster.com)

There is no AND if you are working on two tables, it is only ( , ) comma;
With Comma, It works fine:

CREATE PROCEDURE SP_CreateOrder
(@CustomerID Varchar (50), @CartID Char (36))
AS
INSERT INTO Orders (Name,Address,ProductName,Cost)
SELECT customer.Name, customer.Address, products.ProductName,products.Cost
FROM Customer , Products Join ShoppingCart ON Products.ProductID =
ShoppingCart.ProductID WHERE ShoppingCart.CartID = @CartID AND customerId =
@CustomerId

Bye
Venkat_KL
Nov 28 '05 #3
Eliyahu Goldin wrote:
Your FROM clause in invalid. Look up T-SQL syntax for joins in any resource
available to you. It is hard to give a more precise advise without knowing
your tables structure and what exactly you want to achieve.

Eliyahu
This is probably a very simple question but i am having problems with a
stored procedure syntax.

[quoted text clipped - 26 lines]

WHERE ShoppingCart.CartID = @CartID AND customerId = @CustomerId


many thanks for your help again Eliyahu
mart

--
Message posted via DotNetMonster.com
http://www.dotnetmonster.com/Uwe/For...p-net/200511/1
Nov 28 '05 #4
Venkat_KL wrote:
Dear martinharvey,

(via:DotNetMonster.com)

There is no AND if you are working on two tables, it is only ( , ) comma;
With Comma, It works fine:

CREATE PROCEDURE SP_CreateOrder
(@CustomerID Varchar (50), @CartID Char (36))
AS
INSERT INTO Orders (Name,Address,ProductName,Cost)
SELECT customer.Name, customer.Address, products.ProductName,products.Cost
FROM Customer , Products Join ShoppingCart ON Products.ProductID =
ShoppingCart.ProductID WHERE ShoppingCart.CartID = @CartID AND customerId =
@CustomerId

Bye
Venkat_KL


This was very helpful I will give it a try

many thanks

martin

--
Message posted via http://www.dotnetmonster.com
Nov 28 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Michael Trosen | last post by:
Hi Everyone, I hope someone can help, I'm pretty new to pro*c programming. I have the following application setup: a pro*c program calls a stored procedure and recieves a cursor back: the...
3
by: Rhino | last post by:
I've spent the last couple of hours trying to figure out how to debug a Java stored procedure and am just going in circles. The last straw came when I got "Cannot open input stream for default"...
7
by: Jeff Wang | last post by:
Hi all, Can someone help me out? I've been struggling with this for almost a week and still have no clue what's wrong. Basically I want to write a DB2 stored procedure for OS/390 in REXX. In...
8
by: Thomasb | last post by:
With a background in MS SQL Server programming I'm used to temporary tables. Have just started to work with DB2 ver 7 on z/OS and stumbled into the concept of GLOBAL TEMPORARY TABLE. I have...
2
by: Kent Lewandowski | last post by:
hi all, Recently I wrote some stored procedures using java jdbc code (admittedly my first stab) and then tried to implement the same within java packages (for code reuse). I encountered...
6
by: Wojciech Wendrychowicz | last post by:
Hello to All, I'm trying to retrieve records from AS/400 in an VBA application. So, I've made an RPG program, then a stored procedure wchich calls that RPG program, and finally some VBA code to...
2
by: Eli | last post by:
Hi all We currently have a strange problem with calling a Stored Procedure (SQL Database) in our C# Project. The only error I get is "System error" which says a lot :) Background: We have...
7
by: Dabbler | last post by:
I'm using an ObjectDataSource with a stored procedure and am getting the following error when trying to update (ExecuteNonQuery): System.Data.SqlClient.SqlException: Procedure or Function...
4
by: nishi57 | last post by:
I hope I can get some help regarding this issue, which has been going on for a while. I have a desktop user who is having problem running "Stored Procedures". The DB2 Connect application works fine...
9
by: fniles | last post by:
I am using VB.NET 2003 and SQL2000 database. I have a stored procedure called "INSERT_INTO_MYTABLE" that accepts 1 parameter (varchar(10)) and returns the identity column value from that table....
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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...
0
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...
0
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,...

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.