SQL Stored procedure to insert records from form

I am using CF to enter data from a form.  Can the same be done with a stored procedure?

Here is the coldfusion form

<cfquery name="AddVideo" datasource="#datasource#">
                INSERT INTO VideoList
                (CategoryID, Video_Name, Length, Production_Company, Credits, Availability, NumTests)
                VALUES (<cfqueryparam cfsqltype="CF_SQL_INteger"  value="#FORM.CategoryID#">,
                        <cfqueryparam cfsqltype="CF_SQL_VARCHAR"  value="#FORM.Video_Name#">,
                        <cfqueryparam cfsqltype="CF_SQL_VARCHAR"  value="#FORM.Length#">,
                        <cfqueryparam cfsqltype="CF_SQL_VARCHAR"  value="#FORM.Production_Company#">,
                        <cfqueryparam cfsqltype="CF_SQL_INteger"  value="#FORM.Credits#">,
                        <cfqueryparam cfsqltype="CF_SQL_INteger"  value="#FORM.Availability#">,
                         <cfqueryparam cfsqltype="CF_SQL_INteger"  value="#FORM.NumTests#">)
                       
        </cfquery>
JohnMac328Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

erikTsomikSystem Architect, CF programmer Commented:
Yes it can. You would need to pass the parameters to the stored procedure , You will need to adjust the data types according to your database hierarchy

Call A stored procedure

<cfstoredproc procedure="spINSERT_dbo_VideoList " datasource="#request.datasource#">
	<cfprocparam value="#FORM.CategoryID#" cfsqltype="CF_SQL_INTEGER" type="In">
<cfprocparam value="#FORM.Video_Name#" cfsqltype="CF_SQL_VARCHAR " type="In">

and SO ON  .......


	<cfprocparam variable="isEmployeeReal" cfsqltype="CF_SQL_INTEGER" type="Out">
</cfstoredproc>

Open in new window


CREATE PROCEDURE dbo.spINSERT_dbo_VideoList @CategoryID int, @Video_Name varchar(250), 
@Length INT, @Production_Company varchar(255), @Credits int, @Availability bit,@NumTests INT
AS
SET NOCOUNT ON

INSERT INTO VideoList
           (CategoryID
           ,Video_Name 
           ,Length 
           ,Production_Company 
           ,Credits 
           ,Availability 
       ,NumTests 
)
     VALUES
           (@CategoryID 
           ,@Video_Name
           ,@Length 
           ,@Production_Company 
           ,@Credits 
           ,@Availability ,
           ,@NumTests 
)

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
JohnMac328Author Commented:
Great - that does make sense now.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
SQL

From novice to tech pro — start learning today.