473,800 Members | 2,602 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

quick question on SQL server and object support

Hi folks
I am not at all an SQL server guy (more of an Oracle developer.)
I wanted to know if you guys could tell me if SQL Server supports
objects in the database. If so, could you kindly point me to a
doc or a very quick overview of main object features?

Many thanx!

Jul 23 '05 #1
8 1225

"Menon" <rm*******@gmai l.com> wrote in message
news:11******** **************@ l41g2000cwc.goo glegroups.com.. .
Hi folks
I am not at all an SQL server guy (more of an Oracle developer.)
I wanted to know if you guys could tell me if SQL Server supports
objects in the database. If so, could you kindly point me to a
doc or a very quick overview of main object features?

Many thanx!


That depends on what you mean by 'support' and 'object'. If you mean storing
large binaries, then yes - you can use the image data type to store up to
2GB of binary data in a row. If you mean instantiating an object written in
some particular language from TSQL then you can use the sp_OA% procedures to
manipulate COM objects, although the objects themselves are not in the
database, they're external.

If you mean anything more advanced than that, then you'll probably have to
wait for MSSQL 2005, which includes the .NET CLR, so you can write code
(stored procedures) in C# or VB in addition to TSQL, and use .NET assemblies
to define your own data types, aggregate functions and so on.

Simon
Jul 23 '05 #2
Thanx Simon.
By objects, I meant ability to create objects in your procedural
code (written in T-SQL.)

I can tell you what Oracle provides. In PL/SQL (Oracle's procedural
language), you can create objects (similar to objects in your
language.) You can even store these objects in what
are called object tables. Is this capability
available in SQL Server. Is there public documentation on this
available ?

Jul 23 '05 #3
Menon (rm*******@gmai l.com) writes:
I can tell you what Oracle provides. In PL/SQL (Oracle's procedural
language), you can create objects (similar to objects in your
language.) You can even store these objects in what
are called object tables. Is this capability
available in SQL Server. Is there public documentation on this
available ?


In SQL 2000, no.

In SQL 2005, currently in beta, yes. If you are an MSDN Unviersal
subscriber, you can download the full SQL 2005 from MSDN Subscriber Downloads. Everyone can download the beta of the SQL Express edition
from http://msdn.microsoft.com/SQL/.
I'm not really sure how much of the SQL 2005 Books Online that is
publicly available. In any case, this white paper could be a start:
http://msdn.microsoft.com/sql/2005/2...lrguidance.asp
--
Erland Sommarskog, SQL Server MVP, es****@sommarsk og.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 23 '05 #4
Thanx Erland,
That answers my question - I will also check out the links you pointed
to.

Best Regards
Menon

Jul 23 '05 #5
Folks
Can someone please give a really quick syntax of creating and using
objects
(Say, in T-SQL in 2005)
An example to do this In Oracle (using sql*plus - a command
line utility to execute SQL and PL/SQL (the stored procedure language
of Oracle ) is shown below:

-- first we create the type that represents the object interface:
scott@ORA10G> create or replace type employee as object
2 (
3 name varchar2(50),
4 phone varchar2(20),
5 emp_id number,
6 constructor function employee return self as result,
7 constructor function employee( name in varchar2,
8 phone in varchar2, emp_id in number )
9 return self as result,
10 member function get_name return varchar2,
11 member procedure set_name( p_name in varchar2 ),
12 -- other getters and setters
13 static procedure demo_static_pro c
14 )
15 not final;
16 /

Type created.

-- next we create the type body that implements any methods declared
-- in the type interface we created above:

scott@ORA10G> create or replace type body employee
2 as
3 constructor function employee return self as result
4 is
5 begin
6 self.name := null;
7 self.phone := null;
8 self.emp_id := null;
9 return;
10 end;
11
12 constructor function employee( name in varchar2,
13 phone in varchar2, emp_id in number )
14 return self as result
15 is
16 begin
17 self.name := name;
18 self.phone := phone;
19 self.emp_id := emp_id;
20 return;
21 end;
22
23 member function get_name return varchar2
24 is
25 begin
26 return name;
27 end;
28
29 member procedure set_name( p_name in varchar2 )
30 is
31 begin
32 name := p_name;
33 end;
34 -- define other getters and setters here (deleted for brevity)
35 static procedure demo_static_pro c
36 is
37 begin
38 dbms_output.put _line ( 'This is a simple Oracle object type
that encapsulates a employee.');
39 end;
40 end;
41 /

Type body created.

Following is an example showing initialization of a variable of type
employee
in PL/SQL. Note that we can store employee object directly in tables
as well (not shown)

scott@ORA10G> declare
2 l_employee employee;
3 begin
4 l_employee := employee( 'Joe', '555-666-3345', 1 );
5 dbms_output.put _line( l_employee.name );
6 end;
7 /
Joe

PL/SQL procedure successfully completed.

If some one can show how to do the above (or another euivalent)
in T-SQL in SQL 2005, it would be great.

Many thanx!

Jul 23 '05 #6
Menon (rm*******@gmai l.com) writes:
Can someone please give a really quick syntax of creating and using
objects
(Say, in T-SQL in 2005)


Unfortnately, I don't have any samples to share. There is a sample CLR
type that comes with the SQL 2005 beta, but I don't know of the license
terms permit me to repost the code to public newsgroups, and I am not
taking chances.

Anyway, this is very different from Oracle. Before you start type T-SQL,
you will have write the implementation for your type in a .Net language:
C#, Visual Basic or C++.

Once that is done, you enter the assembly into SQL Server with CREATE
ASSEMBLY and then finally you create the type with CREATE TYPE.

Once you have created the type, you can refer to components of the type
with dot notation:

SELECT @cmplxnumber.x = 1

If you have defined methods on the type you can refer to these with
dot notation as well.
--
Erland Sommarskog, SQL Server MVP, es****@sommarsk og.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 23 '05 #7
Hi Erland.
I guess I was mainly interested in knowing how different these
two features are - and I can see that they are completely different.
Even the SQL to access the code seems to be quite different (From your
one example.)

Many thanx!

Erland Sommarskog wrote:
Unfortnately, I don't have any samples to share. There is a sample CLR type that comes with the SQL 2005 beta, but I don't know of the license terms permit me to repost the code to public newsgroups, and I am not
taking chances.

Anyway, this is very different from Oracle. Before you start type T-SQL, you will have write the implementation for your type in a .Net language: C#, Visual Basic or C++.

Once that is done, you enter the assembly into SQL Server with CREATE
ASSEMBLY and then finally you create the type with CREATE TYPE.

Once you have created the type, you can refer to components of the type with dot notation:

SELECT @cmplxnumber.x = 1

If you have defined methods on the type you can refer to these with
dot notation as well.
--
Erland Sommarskog, SQL Server MVP, es****@sommarsk og.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp


Jul 23 '05 #8
Menon (rm*******@gmai l.com) writes:
Even the SQL to access the code seems to be quite different (From your
one example.)


Huh? You had

self.name := null;

and I had

SELECT @cmplx.x = 1

That is the same as far accessing the components goes. Then it goes
without saying that there are tons of differences between MS SQL Server
and Oracle, and some are reflected in these samples. The @ in my
example signifies that this is a variable and not a column.

If you really want to make any useful comparison specific features, you
first need to learn some basics about T-SQL, before going into the gory
details.

I don't know PL/SQL or Oracle in general, but judging from your example,
it's quite different from T-SQL. As a programming language it also
appears to be a lot cleaner. T-SQL has some quite syntax details in
some places.
--
Erland Sommarskog, SQL Server MVP, es****@sommarsk og.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 23 '05 #9

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

Similar topics

0
9691
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9551
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10507
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10279
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10255
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9092
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7582
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5473
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4150
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.