Add to Favorites    Make Home Page 1628 Online  
 Language Categories  
 Our Services  

Home » ASP Home » SQL Home » call an Oracle Stored Procedure

A D V E R T I S E M E N T

Search Projects & Source Codes:

Title call an Oracle Stored Procedure
Description Folks, contrary to popular belief there are many ways to call stored procedures from an ASP page. I've tried it with Oracle (the only REAL RDBMS ;-) and it works.
Category ASP » SQL
Hits 383085
Code Select and Copy the Code
Assume you have a procedure like this one below, And that it has been already created On the Oracle database. This procedure doesn't return anything, but that doesn't change anything! STEP #1: /******STORED PROCEDURE On ORACLE DATABASE************/ /*====================================================*/ create Or Replace procedure test_me Is w_count integer; begin insert into TEST values ('Surya was here'); --commit it commit; end; /*****End OF STORED PROCEDURE****/ STEP # 2: +++++++++ I assume you have tested it from sql*plus by running the following statements: /************TEST THE STORED PROCEDURE FROM SQL*PLUS******/ SQL> execute test_me PL/SQL procedure successfully completed. SQL> /***************End OF TESTING THE STORED PROC************/ STEP# 3: ++++++++ /*****CALLING A STORED PROCEDURE FROM ASP******************/ 1. USING THE CONNECTION OBJECT You can execute stored procedures which perform Oracle Server side tasks And return you a recordset. You can only use this method If your stored procedure doesn't return any OUTPUT values. <% Set Conn = Server.CreateObject("ADODB.Connection") Conn.execute "test_me",-1,4 %> Note that -1 means no count of total number of records Is required. If you want To Get the count, substitute count With some Integer variable Note that 4 means it Is a stored procedure. By using the actual number -1 And 4, you don't need the server side include ADOVBS.INC ;-) The above would Do the job On the database And return back To you without returning any recordsets. Alternatively, you could: <% Set rs = conn.execute("test_me",w_count,4) %> W_count Is the number of records affected. If your stored procedure were To return a query result, it Is returned within your recordset (rs). This method Is useful With Stored procs which return results of an SQL query 2. USING THE COMMAND OBJECT <% Set Conn = Server.CreateObject("ADODB.Connection") Set Comm = Server.CreateObject("ADODB.Command") Set comm.ActiveConnection = conn comm.commandtype=4 '(or use adCmdStoredProc instead of 4, but then you would have to 'include the ADOVBS.INC. Its upto you comm.commandtext = "test_me" comm.execute 'or Set rs = comm.execute() %> STEP# 4 +++++++++ /************PASSING Input/OUTPUT PARAMETERS**************************/ <% 'If your stored procedure accepts IN parameters and returns OUT parameters 'here's how to go about it Set param = comm.Parameters param.append comm.createparameter("Input",3,1) param.append comm.createparameter("Output",3,2) 'Note that 3 = adInteger for the datatype 'Note that 1=adParamInput and 2=adParamOutput for parameter direction 'Pass the input value comm("Input") = "...." Or Set param = comm.createparameter("InPut",3,1) Set param = comm.createparameter("OutPut",3,2) comm.parameters.append param 'Pass the input value comm("Input") = "...." 'Execute after setting the parameters comm.execute() 'If your stored procedure returns OUT parameters, here's how to get it Out_1 = comm("Output") 'and so on... %> Thats it!

Related Source Codes

Script Name Author
��������������������� VyomWorld
Resistor color code reader A.Chermarajan.
Telephone Directory dhivya
card swapping game (Mini Project) nityanand
simple hangman-pascalsource Seabert
college dirtectory (Mini Project) msridhar
Poll Application John van Meter
ASP Daily Hit Counter. Tejaskumar Gandhi
To avoid null in asp environment using sql Sami
Maklumbalas webmaster
poll John van Meter
EasyASP Template Engine. TjoekBezoer
Basic Calculator using HTML & Javascript. Patrick M. D Souza
What servers support ASP ? VyomWorld
What is ASP? VyomWorld

A D V E R T I S E M E N T




Google Groups Subscribe to SourceCodesWorld - Techies Talk
Email:

Free eBook - Interview Questions: Get over 1,000 Interview Questions in an eBook for free when you join JobsAssist. Just click on the button below to join JobsAssist and you will immediately receive the Free eBook with thousands of Interview Questions in an ebook when you join.

New! Click here to Add your Code!


ASP Home | C Home | C++ Home | COBOL Home | Java Home | Pascal Home
Source Codes Home Page

 Advertisements  

Google Search

Google

Source Codes World.com is a part of Vyom Network.

Vyom Network : Web Hosting | Dedicated Server | Free SMS, GRE, GMAT, MBA | Online Exams | Freshers Jobs | Software Downloads | Interview Questions | Jobs, Discussions | Placement Papers | Free eBooks | Free eBooks | Free Business Info | Interview Questions | Free Tutorials | Arabic, French, German | IAS Preparation | Jokes, Songs, Fun | Free Classifieds | Free Recipes | Free Downloads | Bangalore Info | Tech Solutions | Project Outsourcing, Web Hosting | GATE Preparation | MBA Preparation | SAP Info | Software Testing | Google Logo Maker | Freshers Jobs

Sitemap | Privacy Policy | Terms and Conditions | Important Websites
Copyright ©2003-2024 SourceCodesWorld.com, All Rights Reserved.
Page URL: http://www.sourcecodesworld.com/source/show.asp?ScriptID=224


Download Yahoo Messenger | Placement Papers | Free SMS | C Interview Questions | C++ Interview Questions | Quick2Host Review