Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Pro VB Databases
|
Pro VB Databases Advanced-level VB coding questions specific to using VB with databases. Beginning-level questions or issues not specific to database use will be redirected to other forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro VB Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 28th, 2007, 01:59 AM
Authorized User
 
Join Date: Aug 2007
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to zrtv
Default ORACLE AND VB6 CAN ANYBODY HELP ME PLZ

hi All,
I have following "package" and "stored procedure",I want to run this procedure from vb6, can anybody tell me what will be the "vb6 code" for the following procedure

----------------------------------------------
CREATE OR REPLACE PACKAGE BODY pgarage AS

  PROCEDURE prcempmst(empno IN VARCHAR2, empname IN VARCHAR2, basicsal IN INT, POSITION IN VARCHAR2, p_recordset OUT sys_refcursor) AS
  empmast empmst%rowtype;

  BEGIN

    OPEN p_recordset FOR SELECT*FROM EMPMST WHERE empid=empno;
    fetch p_recordset into empmast;

    IF empmast IS NULL THEN
      INSERT
      INTO empmst
      VALUES(empid, empname, basicsal, POSITION);
    ELSE
      UPDATE empmst
      SET empid = empid,
        empname = empname,
        basicsal = basicsal,
        grade = POSITION;
    END IF;


  END prcempmst;
end pgarage
-------------------------------------------------


 
Old August 28th, 2007, 10:22 AM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

To use a stored procedure, you:

    Create and open a connection object
    Create a command object, Setting its type to stored procedure.
    Set the command text to the name of the procedure
    Set the ActiveConnection to the connection that you opened
    Create a parameter for each argument in the stored procedure
    Set the parameter's variable type, whether it is IN or OUT
    Set the parameter's value, if appropriate
    Append it to the command object.
    Repeate that for each parameter

Once everything has been set up, use the command object's .Execute method to actually run the procedure. The OUT parameters of the command object will hold the values put into the OUT parameters of the stored procedure.

Be sure to close everything properly when you're done.
 
Old August 29th, 2007, 04:30 AM
Authorized User
 
Join Date: Aug 2007
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to zrtv
Default

Thank you very much for your reply,

Can u please tell me what is the use of closing the objects like recordset and connection,

rs.close ' ok this line is use full

set rs=nothing ' why we are using this line without this also program will work can please tell me

 
Old August 29th, 2007, 04:08 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

The program will work fine without explicitly closing objects, and releasing all references to them——probably...

But explicitly closing and releasing makes the intent clear when reading the code, and prevents accidentally leaving a global reference to an object messing things up.

Let's say you open a connection, and then mistakenly set a global object to hold a reference to it. The program's refernce count for that connection will = 2. Leaving the sub will eliminate one of them, but the other will still be valid. If you never closed the connection, it will stay open.

Explicitly closing it will at least make it so that it does not stay open. Leaving the routine will reduce the reference count by one, leaving it at 1.

But that is a better situation than having the connection count too high by one [u]and</u> having the connection not be closed.





Similar Threads
Thread Thread Starter Forum Replies Last Post
ado and oracle procedure problem plz help zrtv Pro VB Databases 9 February 28th, 2008 01:00 PM
calling an oracle function from VB6 kalyansarkar108 VB Databases Basics 14 April 3rd, 2007 12:02 PM
Urgent PLZ,Crystal Report With VB6 problem bkhashfeh VB Components 5 December 31st, 2006 03:28 AM
How to call a Oracle Stored Procedure in VB6 krratnesh Pro VB Databases 1 February 19th, 2006 11:56 AM
To call oracle stored procedure in vb6 krratnesh Pro VB 6 0 February 1st, 2006 10:26 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.