Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Database & SysAdmin
  3. Database
  4. oracle & .net

oracle & .net

Scheduled Pinned Locked Moved Database
csharpdatabasesql-serveroraclesysadmin
7 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    amer shammout
    wrote on last edited by
    #1

    hello i used to work with c# and sql server but now i am working with oracle now I want to return data table from procedure i used to create sql proceduer "select * from tablename" and then i use datatable with dataadapter to return the rows of table but it does not work with oracle what can i do???????????????!!!!!!!!!!!!!

    I D S 3 Replies Last reply
    0
    • A amer shammout

      hello i used to work with c# and sql server but now i am working with oracle now I want to return data table from procedure i used to create sql proceduer "select * from tablename" and then i use datatable with dataadapter to return the rows of table but it does not work with oracle what can i do???????????????!!!!!!!!!!!!!

      I Offline
      I Offline
      i j russell
      wrote on last edited by
      #2

      What do you mean by 'it does not work'; do you get an error or no data or what?

      A 1 Reply Last reply
      0
      • I i j russell

        What do you mean by 'it does not work'; do you get an error or no data or what?

        A Offline
        A Offline
        amer shammout
        wrote on last edited by
        #3

        the procedure did not created (syntax error) sum frien told me to use function but it did not work

        1 Reply Last reply
        0
        • A amer shammout

          hello i used to work with c# and sql server but now i am working with oracle now I want to return data table from procedure i used to create sql proceduer "select * from tablename" and then i use datatable with dataadapter to return the rows of table but it does not work with oracle what can i do???????????????!!!!!!!!!!!!!

          D Offline
          D Offline
          Don Burton
          wrote on last edited by
          #4

          Since I'm not quite sure how you're approaching the problem - try reviewing this Oracle article and see if it helps: http://www.oracle.com/technology/pub/articles/cook-vs08.html[^]

          A 1 Reply Last reply
          0
          • D Don Burton

            Since I'm not quite sure how you're approaching the problem - try reviewing this Oracle article and see if it helps: http://www.oracle.com/technology/pub/articles/cook-vs08.html[^]

            A Offline
            A Offline
            amer shammout
            wrote on last edited by
            #5

            thanks very much

            1 Reply Last reply
            0
            • A amer shammout

              hello i used to work with c# and sql server but now i am working with oracle now I want to return data table from procedure i used to create sql proceduer "select * from tablename" and then i use datatable with dataadapter to return the rows of table but it does not work with oracle what can i do???????????????!!!!!!!!!!!!!

              S Offline
              S Offline
              slam Iqbal
              wrote on last edited by
              #6

              You have to use Package insted of procedure.
              Search in oracle or MSDN to get help about package. here is an example of package (Collected from MSDN):

              Drop table Emp;
              drop table DEPT;
              CREATE TABLE DEPT
              (DEPTNO NUMBER(2,0) NOT NULL,
              DNAME VARCHAR2(14) NULL,
              LOC VARCHAR2(13) NULL,
              PRIMARY KEY (DEPTNO)
              );

              INSERT INTO Dept VALUES(11,'Sales','Texas');
              INSERT INTO Dept VALUES(22,'Accounting','Washington');
              INSERT INTO Dept VALUES(33,'Finance','Maine');

              CREATE TABLE EMP
              (EMPNO NUMBER(4,0) NOT NULL,
              ENAME VARCHAR2(10) NULL,
              JOB VARCHAR2(9) NULL,
              MGR NUMBER(4,0) NULL,
              HIREDATE DATE NULL,
              SAL NUMBER(7,2) NULL,
              COMM NUMBER(7,2) NULL,
              DEPTNO NUMBER(2,0) NULL,
              FOREIGN KEY (DEPTNO) REFERENCES DEPT(DEPTNO),
              PRIMARY KEY (EMPNO)
              );

              INSERT INTO Emp VALUES(123,'Bob','Sales',555,'28-JAN-79',35000,12,33);
              INSERT INTO Emp VALUES(321,'Sue','Finance',555,'12-MAY-83',42000,12,11);
              INSERT INTO Emp VALUES(234,'Mary','Account',555,'14-AUG-82',33000,12,22);

              CREATE OR REPLACE PACKAGE curspkg_join AS
              TYPE t_cursor IS REF CURSOR ;
              Procedure open_join_cursor1 (n_EMPNO IN NUMBER, io_cursor IN OUT t_cursor);
              END curspkg_join;
              /

              CREATE OR REPLACE PACKAGE BODY curspkg_join AS
              Procedure open_join_cursor1 (n_EMPNO IN NUMBER, io_cursor IN OUT t_cursor)
              IS
              v_cursor t_cursor;
              BEGIN
              IF n_EMPNO <> 0
              THEN
              OPEN v_cursor FOR
              SELECT EMP.EMPNO, EMP.ENAME, DEPT.DEPTNO, DEPT.DNAME
              FROM EMP, DEPT
              WHERE EMP.DEPTNO = DEPT.DEPTNO
              AND EMP.EMPNO = n_EMPNO;

                  ELSE 
                       OPEN v\_cursor FOR 
                       SELECT EMP.EMPNO, EMP.ENAME, DEPT.DEPTNO, DEPT.DNAME 
                            FROM EMP, DEPT 
                            WHERE EMP.DEPTNO = DEPT.DEPTNO;
              
                  END IF;
                  io\_cursor := v\_cursor; 
              

              END open_join_cursor1;
              END curspkg_join;

              Convert the following VB Code into C# to execute that package:

              Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
              Dim x As Exception
              Dim Ds As New DataSet()
              Dim Oraclecon As New OracleConnection("Server=giit;Uid=scott;Pwd=tiger")

                  Oraclecon.Open()
              
              
                  Dim myCMD As New OracleCommand()
                  myCMD.Connection = Oraclecon
                  myCMD.CommandText = "curspkg\_join.open\_join\_cursor1"
                  myCMD.Co
              
              A 1 Reply Last reply
              0
              • S slam Iqbal

                You have to use Package insted of procedure.
                Search in oracle or MSDN to get help about package. here is an example of package (Collected from MSDN):

                Drop table Emp;
                drop table DEPT;
                CREATE TABLE DEPT
                (DEPTNO NUMBER(2,0) NOT NULL,
                DNAME VARCHAR2(14) NULL,
                LOC VARCHAR2(13) NULL,
                PRIMARY KEY (DEPTNO)
                );

                INSERT INTO Dept VALUES(11,'Sales','Texas');
                INSERT INTO Dept VALUES(22,'Accounting','Washington');
                INSERT INTO Dept VALUES(33,'Finance','Maine');

                CREATE TABLE EMP
                (EMPNO NUMBER(4,0) NOT NULL,
                ENAME VARCHAR2(10) NULL,
                JOB VARCHAR2(9) NULL,
                MGR NUMBER(4,0) NULL,
                HIREDATE DATE NULL,
                SAL NUMBER(7,2) NULL,
                COMM NUMBER(7,2) NULL,
                DEPTNO NUMBER(2,0) NULL,
                FOREIGN KEY (DEPTNO) REFERENCES DEPT(DEPTNO),
                PRIMARY KEY (EMPNO)
                );

                INSERT INTO Emp VALUES(123,'Bob','Sales',555,'28-JAN-79',35000,12,33);
                INSERT INTO Emp VALUES(321,'Sue','Finance',555,'12-MAY-83',42000,12,11);
                INSERT INTO Emp VALUES(234,'Mary','Account',555,'14-AUG-82',33000,12,22);

                CREATE OR REPLACE PACKAGE curspkg_join AS
                TYPE t_cursor IS REF CURSOR ;
                Procedure open_join_cursor1 (n_EMPNO IN NUMBER, io_cursor IN OUT t_cursor);
                END curspkg_join;
                /

                CREATE OR REPLACE PACKAGE BODY curspkg_join AS
                Procedure open_join_cursor1 (n_EMPNO IN NUMBER, io_cursor IN OUT t_cursor)
                IS
                v_cursor t_cursor;
                BEGIN
                IF n_EMPNO <> 0
                THEN
                OPEN v_cursor FOR
                SELECT EMP.EMPNO, EMP.ENAME, DEPT.DEPTNO, DEPT.DNAME
                FROM EMP, DEPT
                WHERE EMP.DEPTNO = DEPT.DEPTNO
                AND EMP.EMPNO = n_EMPNO;

                    ELSE 
                         OPEN v\_cursor FOR 
                         SELECT EMP.EMPNO, EMP.ENAME, DEPT.DEPTNO, DEPT.DNAME 
                              FROM EMP, DEPT 
                              WHERE EMP.DEPTNO = DEPT.DEPTNO;
                
                    END IF;
                    io\_cursor := v\_cursor; 
                

                END open_join_cursor1;
                END curspkg_join;

                Convert the following VB Code into C# to execute that package:

                Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
                Dim x As Exception
                Dim Ds As New DataSet()
                Dim Oraclecon As New OracleConnection("Server=giit;Uid=scott;Pwd=tiger")

                    Oraclecon.Open()
                
                
                    Dim myCMD As New OracleCommand()
                    myCMD.Connection = Oraclecon
                    myCMD.CommandText = "curspkg\_join.open\_join\_cursor1"
                    myCMD.Co
                
                A Offline
                A Offline
                amer shammout
                wrote on last edited by
                #7

                thanks that is exactly what i want

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups