Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 28th, 2003, 05:40 AM
herlenrosa herlenrosa is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Location: India
Posts: 22 herlenrosa User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 53 m 46 sec
Reputation Power: 0
Question Vb code for manipulating multiple record data returned from PL/SQL

Hi
I have a oracle stored procedure which returns a
TABLE of NUMBERS(100) ie (defined as OUT) in PL/SQL

can any one help me to call the procedure and store the returned value in visual basic 6 so that i can manipulate the same .
I use ADODB , & ORALCE PROVIDER FOR OLEDB for connection

what are the different ways I can call this stored procedure to return the above data ?

Thanks.

Reply With Quote
  #2  
Old October 28th, 2003, 07:49 AM
Fisherman's Avatar
Fisherman Fisherman is offline
Inherits Programmer.Slacker
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Aug 2003
Location: Between my Id and your Ego
Posts: 2,176 Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Week 1 Day 9 h 42 m 4 sec
Reputation Power: 111
Send a message via ICQ to Fisherman Send a message via AIM to Fisherman
if you'll use the ADODB Command object, then you can dimension parameters to match the ones in your Stored Procedure argument list. That includes a parameter type called adParamOutput.. .here's an example..

Code:
dim cmdSample as ADODB.Command
dim rsSample as ADODB.Command

Set cmdSample = New ADODB.Command
Set cmdSample.ActiveConnection = YOUR ACTIVE CONNECTION
cmdSample.CommandText= "YOUR_STORED_PROCEDURE"
cmdSample.CommandType = adCmdStoredProc
With cmdSample.Parameters
     .Append cmdSample.CreateParameter("@SampleInput", adChar, adParamInput, Size:=15)
     .Append cmdSample.CreateParameter("@SampleOuput", adVarChar, adParamOutput, Size:=100)
end with

with rsSample
        .CursorLocation = adUseClient
        .CursorType = adOpenStatic
        .LockType = adLockOptimistic
        .Open Source:=cmdSample
end with


You'll have to make sure that you're using the right Data Access Provider for Oracle (obviously).. .I"m guessing that SQLOLEDB will work?
__________________
Fisherman

"Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius -- and a lot of courage -- to move in the opposite direction." - A.Einstein

Reply With Quote
  #3  
Old October 28th, 2003, 09:00 AM
cleverpig cleverpig is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2003
Posts: 1,152 cleverpig User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via MSN to cleverpig
What is the "@SampleInput"and "@SampleOuput"??Fisherman,Can u introduce more to me??Thx!!

Reply With Quote
  #4  
Old October 28th, 2003, 11:31 AM
Fisherman's Avatar
Fisherman Fisherman is offline
Inherits Programmer.Slacker
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Aug 2003
Location: Between my Id and your Ego
Posts: 2,176 Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Week 1 Day 9 h 42 m 4 sec
Reputation Power: 111
Send a message via ICQ to Fisherman Send a message via AIM to Fisherman
well, in most cases, when you are dealing with a Stored Procedure (PL-SQL statements) you will have parameters that you pass in (and possibly out), just like passing a parameter to (or from) a function or sub in VB. For example, let's say that I've got a parameterized Stored Procedure in which I am selecting certain records from a table... the SQL syntax for the statement would, of course, look like this
Code:
Select * from tblSomeTable Where [Field] LIKE [value]


well.. with PL-SQL, I can dimension variables for that SQL Statement, like this

Code:

Declare @SampleInput as char 15,
Declare @SampleOutput as varchar 1000

Begin

@SampleOutput= Select * from tblSomeTable Where [Field] Like @SampleInput

return @SampleOutput
Go


Doing this does several things. It lessens the possibility of an injection attack by a hacker, as well as processing time on (what could be) a slower, less powerful client, thus making a "fatter" server app. Also, it makes it easier to loop through values on the client side by just reassigning the corresponding ADODB Command Parameters to new values and reexecuting, and when dealing with SQLServer, it will actually optimize the query and hold it on the machine, waiting for parameters to be passed... this makes statements "faster" because they don't have to be instantiated by SQLServer at every call. Sorry to ramble, CP, but here's your answer. the @SampleInput and @SampleOutput in the VB Code match the parameter declarations inside of the Stored Procedure, thus allowing the application to access the data produced by the SP.

Hope I didn't insult anyone's intelligence... I'm kinda long-winded!

Reply With Quote
  #5  
Old October 28th, 2003, 08:11 PM
cleverpig cleverpig is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2003
Posts: 1,152 cleverpig User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via MSN to cleverpig
THx For your detailed introduce!

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > Vb code for manipulating multiple record data returned from PL/SQL


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway