Live ORACLE

if you are Oracle Developer ,than this Blog most likely will make you happy.

About my Blog

This Blog particularized for Oracle Developers ... you will see interesting Codes for SQL , PL/SQL as well as new ideas for Developer Suite and Client Tools that will help you in your professional life ... and I hope I reach for your satisfaction.

About Me

I'm Hany Freedom , 25 years old , I live in EL-Minia City in Egypt , I'm Moderator at ArabOUG.org the best Arabic Forum for ORACLE on the Net. if you interested to know more about me .... just Click Here.

Creating a Table with a Varray Column

DROP TABLE dept_projects CASCADE CONSTRAINTS PURGE;
DROP type projectlist;

-- Each project has a 16-character code name.
-- We will store up to 50 projects at a time in a database column.
CREATE TYPE projectlist AS VARRAY(50) OF VARCHAR2(16);
/

CREATE TABLE dept_projects ( -- create database table
dept_id NUMBER(2),
NAME VARCHAR2(15),
budget NUMBER(11,2),
-- Each department can have up to 50 projects.
projects PROJECTLIST);


Varray Constructor Within a SQL Statement

BEGIN
INSERT INTO dept_projects
VALUES (60,
'Security',
750400,
Projectlist('New Badges','Track Computers','Check Exits'));
END;
/


Share/Save/Bookmark

2 comments:

  1. Unknown said...
     

    nice info ..
    this is the first time that I knew that array can be used in oracle

    but I tried to aplly an insert statement but don't know how it should be


    insert into dept_projects(dept_id,NAME,budget,projects(0)) values ('a1','h1n1',21,'project1');

  2. Unknown said...
     

    Hello HRS123,
    Read this Page to learn more about VARRAY datatype:

    http://www.orafaq.com/wiki/VARRAY

    have a nice day

Post a Comment



Newer Posts Older Posts Home Page
 
http://www.dpriver.com/images/sqlpp-banner-2.png

Thanks for reading my Blog ... you Visitor Number :-