HIRO's.NET Blog

PowerShellが好き

目次

Blog 利用状況

ニュース

あわせて読みたい

書庫

日記カテゴリ

リンク

VB.NETからOracleストアドプロシージャを呼び出す その5

前回(その4)は、REF CURSORをOUT引数として持つストアドプロシージャをVB.NETでDataReaderに受け取る方法を紹介しました。

今回は、REF CURSOR(OUT引数)をVB.NETでDataSetに受け取る方法を紹介します。

開発言語:VB.NET 2005

使用するテーブルは、Oracleを使用している人であればおなじみの、scott/tigerのEMP表です。

ストアドプロシージャは下記の通りです。もらった引数をINSERT文で書き込み、書き込み後のEMP表総件数をout_TOTALCNTにセットします。

(例によって深い意味はありません。説明用です。)

ストアドプロシージャ4
CREATE OR REPLACE PACKAGE SCOTT.PKG_TEST2
IS
    TYPE ref_cursor IS REF CURSOR;
        Procedure PROCEDURE5(out_cursor OUT ref_cursor);
END;
/

CREATE OR REPLACE PACKAGE BODY SCOTT.PKG_TEST2 AS
Procedure PROCEDURE5 (
    out_cursor OUT ref_cursor
)
IS
BEGIN
    BEGIN
        OPEN out_cursor FOR
        SELECT * FROM EMP;
    END;
END PROCEDURE5;
END PKG_TEST2;
/

 以下、ODP.NET, MicorosoftのOracleClient, OleDB の3種類を使用してPROCEDURE5を呼び出す例です。

 

 今回は、ストアドプロシージャのOUTパラメータをVB.NETのDataSetに受け取る方法について説明します。

 まず、OracleParameterのインスタンスを作成します。(OleDBの場合は作成しません。)

 OracleParameterのインスタンス作成時の第1引数には、ストアドプロシージャのREF CUROSOR(OUT引数)名(この場合は"out_cursor")、第2引数にはストアドプロシージャOUT引数の型に合わせたものを指定します。(今回の場合、OracleのREF CURSOR型に対して、ODP.NETの場合はOracleDbType.RefCursor、OracleClientの場合はOracleType.Cursor

 次に、PrameterDirectionにOutputを指定します。(これはストアドプロシージャout_cursorがOUT引数であるため)

 あとはDataAdaptertとDataSetを作成し、DataAdapterのFillメソッドを使用することで、DataSetに結果を受け取ることができます。

 

■ODP.NETサンプル
Try
    Using OraConn As New OracleConnection("user id=scott;password=tiger;data source=YourServer")
        Using Cmd As New OracleCommand
            'データベース接続を開く
            OraConn.Open()
            Cmd.Connection = OraConn
            'コマンドタイプをストアドプロシージャにする
            Cmd.CommandType = CommandType.StoredProcedure
            '実行するストアドプロシージャを指定
            Cmd.CommandText = "PKG_TEST2.PROCEDURE5"
            'ストアドプロシージャのout cursor用パラメータ作成
            Dim outPara As New OracleParameter("out_CURSOR", OracleDbType.RefCursor)
            outPara.Direction = ParameterDirection.Output
            Cmd.Parameters.Add(outPara)

            Dim OraDA As New OracleDataAdapter(Cmd)
            Dim ds As New DataSet()
            OraDA.Fill(ds, "EMP")

            DataGridView1.DataSource = ds.Tables("EMP")

            MessageBox.Show("PROCEDURE5 正常終了", "SUCCESS", MessageBoxButtons.OK, MessageBoxIcon.Information)
        End Using
    End Using

Catch OraEx As OracleException
    'Oracle例外発生時
    MessageBox.Show(OraEx.Message, "ORACLE ERROR", MessageBoxButtons.OK, MessageBoxIcon.Stop)

Catch ex As Exception
    '一般例外発生時
    MessageBox.Show(ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Stop)
End Try

■OracleClientサンプル
Private Sub OracleClient_TEST5()
    Try
        Using OraConn As New OracleConnection("user id=scott;password=tiger;data source=YourServer")
            Using Cmd As New OracleCommand
                'データベース接続を開く
                OraConn.Open()
                Cmd.Connection = OraConn
                'コマンドタイプをストアドプロシージャにする
                Cmd.CommandType = CommandType.StoredProcedure
                '実行するストアドプロシージャを指定
                Cmd.CommandText = "PKG_TEST2.PROCEDURE5"
                'ストアドプロシージャのout cursor用パラメータ作成
                Dim outPara As New OracleParameter("out_CURSOR", OracleType.Cursor)
                outPara.Direction = ParameterDirection.Output
                Cmd.Parameters.Add(outPara)

                Dim OraDA As New OracleDataAdapter(Cmd)
                Dim ds As New DataSet()
                OraDA.Fill(ds, "EMP")

                DataGridView1.DataSource = ds.Tables("EMP")

                MessageBox.Show("PROCEDURE5 正常終了", "SUCCESS", _
                    MessageBoxButtons.OK, MessageBoxIcon.Information)
            End Using
        End Using

    Catch OraEx As OracleException
        'Oracle例外発生時
        MessageBox.Show(OraEx.Message, "ORACLE ERROR", MessageBoxButtons.OK, MessageBoxIcon.Stop)

    Catch ex As Exception
        '一般例外発生時
        MessageBox.Show(ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Stop)
    End Try
End Sub

■OleDBサンプル
Private Sub OleDB_TEST5()
    Try
        Using OraConn As New OleDbConnection("Provider=MSDAORA.1.Oracle;user id=scott;password=tiger;data source=YourServer;PLSQLRset=True")
            Using Cmd As New OleDbCommand
                'データベース接続を開く
                OraConn.Open()
                Cmd.Connection = OraConn
                'コマンドタイプをストアドプロシージャにする
                Cmd.CommandType = CommandType.StoredProcedure
                ''実行するストアドプロシージャを指定
                Cmd.CommandText = "PKG_TEST2.PROCEDURE5"
                'OleDbではストアドプロシージャのout cursor用パラメータ作成は必要ない

                Dim OleDA As New OleDbDataAdapter(Cmd)
                Dim ds As New DataSet()
                OleDA.Fill(ds, "EMP")

                DataGridView1.DataSource = ds.Tables("EMP")

                MessageBox.Show("PROCEDURE5 正常終了", "SUCCESS", _
                    MessageBoxButtons.OK, MessageBoxIcon.Information)
            End Using
        End Using

    Catch OleEx As OleDbException
        'Oracle例外発生時
        MessageBox.Show(OleEx.Message, "OleDB ERROR", MessageBoxButtons.OK, MessageBoxIcon.Stop)

    Catch ex As Exception
        '一般例外発生時
        MessageBox.Show(ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Stop)
    End Try
End Sub


投稿日時 : 2007年4月21日 23:32

コメントを追加

# order doxycycline https://doxycyline1st.com/
cheap doxycycline online 2022/02/26 10:05 Jusidkid

order doxycycline https://doxycyline1st.com/
cheap doxycycline online

# clomid generic https://clomiden.fun/ 2022/04/12 13:21 Clomids

clomid generic https://clomiden.fun/

# drug finasteride https://finasteridemen.com/
2022/05/11 15:26 Finasteride

drug finasteride https://finasteridemen.com/

# clomid 2020 https://clomidonline.icu/ 2022/07/08 14:00 Clomidj

clomid 2020 https://clomidonline.icu/

# pain relief https://allpharm.store/ 2022/07/21 22:28 AllPharm

pain relief https://allpharm.store/

# ivermectin covid uptodate https://stromectolbestprice.com/ 2022/07/30 0:55 BestPrice

ivermectin covid uptodate https://stromectolbestprice.com/

# prednisone tablets 2.5 mg https://deltasone.icu/
prednisone 10 mg canada 2022/08/22 10:05 Prednisone

prednisone tablets 2.5 mg https://deltasone.icu/
prednisone 10 mg canada

# argument essay help p76sea 2022/09/08 17:48 AaronBlact


Terrific facts. Many thanks. https://definitionessays.com/ content writing service

# treatments for ed https://ed-pills.xyz/
best ed pills online 2022/09/16 20:00 EdPills

treatments for ed https://ed-pills.xyz/
best ed pills online

# thesis on e service quality h557ij 2023/03/03 0:34 Josephbried


Useful data. Cheers.
easy thesis https://writingthesistops.com/ master thesis help

# apa style thesis statement c45itw 2023/03/03 8:22 Josephbried


Wow quite a lot of helpful knowledge!
do you have to write a thesis for masters https://writingthesistops.com/ do research papers need a thesis

# mba essay writing service a866ed 2023/03/06 5:02 EugeneSib


Terrific info. Regards.
how to write an essay on a poem analysis https://essaywritingservicetop.com write a descriptive essay https://bestonlinepaperwritingservices.com

# economics dissertations v47mfe 2023/03/06 9:27 Gregorysaipt


Terrific advice. Cheers!
writing a comparative essay https://writeadissertation.com help on college essay https://bestpaperwritingservice.com

# how to write an essay intro a27dxs 2023/03/06 14:34 EugeneSib


Many thanks! I value this.
how to write an essay on yourself https://bestmasterthesiswritingservice.com writing a good essay for college https://essaywriting4you.com

# buy essays online australia g835so 2023/03/06 15:37 Gregorysaipt


Kudos. I appreciate it!
doctoral dissertation writing help https://essaywritinghelperonline.com how to write academic essays https://payforanessaysonline.com

# how to write an evaluative essay q28mza 2023/03/06 20:15 EugeneSib


Point certainly used.!
defend phd thesis https://writeadissertation.com writing your doctoral dissertation https://helpmedomyxyzhomework.com

# recommended essay writing service m56iup 2023/03/07 5:39 EugeneSib


Many thanks. Great stuff.
web copywriting services https://quality-essays.com custom application essay https://buycheapessaysonline.com

# how to write an essay in college u12teg 2023/03/07 14:11 Gregorysaipt


Incredible lots of great knowledge!
dissertat https://studentessaywriting.com argumentative essay for college https://helptowriteanessay.com

# writing help for college students u21phy 2023/03/07 20:52 EugeneSib


With thanks, Useful information!
how to write a good scholarship essay https://studentessaywriting.com cheap essay writing services https://essaywritingservicebbc.com

# writing a good college essay n50irq 2023/03/08 3:15 EugeneSib


Whoa a lot of helpful knowledge.
write dissertations https://studentessaywriting.com scholarship essay writing service https://essaywritingserviceahrefs.com

# academic essay service v83gud 2023/03/08 6:27 Gregorysaipt


Good info. Cheers!
how to write a proper essay https://helpmedomyxyzhomework.com top resume writing services https://service-essay.com

# doctoral thesis dissertation j261kt 2023/03/08 12:28 Gregorysaipt

You actually expressed it superbly!
how to do dissertation https://writinganessaycollegeservice.com best resume writers nyc https://ouressays.com

# academic writing essay n271gp 2023/03/08 12:35 EugeneSib


Truly plenty of good material!
analysis dissertation https://topswritingservices.com how to write an essays https://phdthesisdissertation.com

# writing essay website a622lo 2023/03/08 18:39 EugeneSib


Useful write ups. Kudos.
common college application essay prompts https://writeadissertation.com help with essays https://buycheapessaysonline.com

# thesis for master degree n29cuz 2023/03/09 4:36 Gregorysaipt


Amazing facts. Thanks a lot.
write essay for money https://bestonlinepaperwritingservices.com writing for life paragraphs and essays https://phdthesisdissertation.com

# who can write my thesis z17szz 2023/03/09 10:31 Gregorysaipt

You revealed it very well!
international thesis https://paperwritingservicecheap.com creative writing essays https://payforanessaysonline.com

# professional custom writing service m64jvp 2023/03/10 7:56 Gregorysaipt


Regards! Plenty of advice.
writing websites https://helpmedomyxyzhomework.com digital dissertations https://custompaperwritingservices.com

# the value of a college education essay f56bim 2023/03/10 10:36 EugeneSib


Thanks a lot! I like this!
transfer college essays https://writingresearchtermpaperservice.com how to write a personal essay for college https://helpmedomyxyzhomework.com

# essay on writing v97jwz 2023/03/11 1:16 EugeneSib


Cheers. Terrific stuff.
top 5 essay writing services https://essaywritinghelperonline.com writing opinion essay https://essaywritingservicetop.com

# online letter writing service f90btt 2023/03/11 5:38 Gregorysaipt


Incredible loads of very good knowledge.
writers wanted online https://bestpaperwritingservice.com doctoral dissertation writing https://topswritingservices.com

# how to write reflective essay o24xao 2023/03/11 7:04 EugeneSib


Many thanks! Very good information.
uc essay help https://domyhomeworkformecheap.com how to write an application essay https://domyhomeworkformecheap.com

# phd paper e99xnv 2023/03/11 21:20 Gregorysaipt


Regards. I enjoy this.
how to write an expository essay https://englishessayhelp.com writing dissertation introduction https://writinganessaycollegeservice.com

# colleges essays r67svx 2023/03/12 3:15 Gregorysaipt


Incredible plenty of helpful data!
scholarship essay writing https://researchproposalforphd.com essays about college education https://helpmedomyxyzhomework.com

# top essay writing websites t84qgv 2023/03/12 7:15 EugeneSib


Truly many of superb material.
dissertation finance https://englishessayhelp.com phd thesis paper https://dissertationwritingtops.com

# essays on writing x91euz 2023/03/12 12:43 EugeneSib


Useful advice. Appreciate it.
cheap essay writing service https://essaywriting4you.com how to write a thesis sentence for an essay https://writingthesistops.com

# college acceptance essay x18tky 2023/03/12 21:47 EugeneSib


Useful posts. Appreciate it!
dissertated https://essaytyperhelp.com thesis writer https://researchpaperwriterservices.com

# cat essay writer s49bry 2023/03/13 1:00 Gregorysaipt


Terrific material. Thanks a lot.
analysis dissertation https://custompaperwritingservices.com write college essays for money https://custompaperwritersservices.com

# doctor thesis h475ix 2023/03/13 3:19 EugeneSib


Cheers, I value this.
writing a doctoral dissertation https://essaywritingservicetop.com writing a how to essay https://helpmedomyxyzhomework.com

# the essay t92wro 2023/03/13 12:24 EugeneSib


Nicely put, Kudos!
persuasive essay on why college athletes should be paid https://researchpaperwriterservices.com custom writing essays services https://researchpaperwriterservices.com

# how to write a persuasive argument essay s76vcm 2023/03/13 22:48 Gregorysaipt


Kudos, I appreciate it!
essay writting https://domycollegehomeworkforme.com dissertation statistics help https://helptowriteanessay.com

# how to write an objective essay t86skf 2023/03/14 3:12 EugeneSib


Fantastic advice. Thanks!
how to write a comparison and contrast essay https://quality-essays.com high quality article writing service https://writeadissertation.com

# doors2.txt;1 2023/03/14 15:36 jyhFIvRWRCdQ

doors2.txt;1

# doors2.txt;1 2023/03/14 17:02 ISlzkgLYOpooov

doors2.txt;1

# how write essay f55dxx 2023/04/01 9:53 EugeneSib

You actually suggested this superbly.
how to write an essay to get into college https://helpwithdissertationwriting.com how to write the best college essay https://essayssolution.com

# The plugins developed for WordPress 2023/05/09 23:55 Justas

The plugins developed for WordPress serve to enhance the features and functions of a WordPress website, allowing you to build your awesome and functional site https://t.me/wpigaming/648 Customise WordPress with powerful, professional and intuitive fields.

# The plugins developed for WordPress 2023/05/09 23:55 Justas

The plugins developed for WordPress serve to enhance the features and functions of a WordPress website, allowing you to build your awesome and functional site https://t.me/wpigaming/648 Customise WordPress with powerful, professional and intuitive fields.

# antiplatelet drug https://plavix.guru/ plavix best price 2023/10/24 3:23 Plavixxx

antiplatelet drug https://plavix.guru/ plavix best price

# paxlovid pill https://paxlovid.bid/ paxlovid india 2023/10/26 2:30 Paxlovid

paxlovid pill https://paxlovid.bid/ paxlovid india

# acquisto farmaci con ricetta https://farmaciait.pro/ migliori farmacie online 2023 2023/12/04 12:44 Farmacia

acquisto farmaci con ricetta https://farmaciait.pro/ migliori farmacie online 2023

# ed meds online https://edpills.tech/# cheap erectile dysfunction pills 2023/12/23 11:01 EdPills

ed meds online https://edpills.tech/# cheap erectile dysfunction pills

# Hi there everyone, it's my first go to see at this web site, and piece of writing is actually fruitful in support of me, keep up posting these articles. 2024/02/01 0:56 Hi there everyone, it's my first go to see at this

Hi there everyone, it's my first go to see at this web
site, and piece of writing is actually fruitful in support
of me, keep up posting these articles.

# This piece of writing will assist the internet viewers for building up new webpage or even a blog from start to end. 2024/02/03 1:14 This piece of writing will assist the internet vie

This piece of writing will assist the internet viewers
for building up new webpage or even a blog from start to end.

# This piece of writing will assist the internet viewers for building up new webpage or even a blog from start to end. 2024/02/03 1:15 This piece of writing will assist the internet vie

This piece of writing will assist the internet viewers
for building up new webpage or even a blog from start to end.

# This piece of writing will assist the internet viewers for building up new webpage or even a blog from start to end. 2024/02/03 1:15 This piece of writing will assist the internet vie

This piece of writing will assist the internet viewers
for building up new webpage or even a blog from start to end.

# There is definately a great deal to learn about this topic. I love all of the points you have made. 2024/02/06 23:13 There is definately a great deal to learn about th

There is definately a great deal to learn about this topic.

I love all of the points you have made.

# There is definately a great deal to learn about this topic. I love all of the points you have made. 2024/02/06 23:14 There is definately a great deal to learn about th

There is definately a great deal to learn about this topic.

I love all of the points you have made.

# There is definately a great deal to learn about this topic. I love all of the points you have made. 2024/02/06 23:14 There is definately a great deal to learn about th

There is definately a great deal to learn about this topic.

I love all of the points you have made.

# There is definately a great deal to learn about this topic. I love all of the points you have made. 2024/02/06 23:15 There is definately a great deal to learn about th

There is definately a great deal to learn about this topic.

I love all of the points you have made.

# lana rhoades boyfriend - https://lanarhoades.pro/ lana rhoades unleashed
2024/03/06 18:50 LanaRho

lana rhoades boyfriend - https://lanarhoades.pro/ lana rhoades unleashed

# purchase cytotec https://cytotec.club/ Cytotec 200mcg price 2024/04/28 1:04 Cytotec

purchase cytotec https://cytotec.club/ Cytotec 200mcg price

# diagnóstico de vibraciones 2025/02/08 7:40 TylerHoive



Equipos de ajuste: fundamental para el rendimiento fluido y eficiente de las máquinas.

En el campo de la tecnología contemporánea, donde la rendimiento y la seguridad del sistema son de máxima relevancia, los sistemas de ajuste cumplen un papel vital. Estos aparatos específicos están creados para calibrar y fijar piezas móviles, ya sea en herramientas de fábrica, medios de transporte de desplazamiento o incluso en dispositivos hogareños.

Para los expertos en mantenimiento de sistemas y los profesionales, manejar con sistemas de calibración es importante para proteger el operación suave y fiable de cualquier sistema giratorio. Gracias a estas herramientas modernas innovadoras, es posible reducir notablemente las sacudidas, el ruido y la esfuerzo sobre los rodamientos, prolongando la vida útil de elementos valiosos.

Asimismo relevante es el papel que juegan los equipos de calibración en la atención al usuario. El asistencia especializado y el reparación permanente aplicando estos dispositivos facilitan ofrecer prestaciones de óptima estándar, aumentando la bienestar de los usuarios.

Para los propietarios de proyectos, la aporte en unidades de ajuste y dispositivos puede ser fundamental para incrementar la productividad y productividad de sus sistemas. Esto es principalmente importante para los dueños de negocios que manejan medianas y medianas negocios, donde cada aspecto cuenta.

Asimismo, los dispositivos de ajuste tienen una extensa uso en el sector de la prevención y el supervisión de nivel. Facilitan encontrar potenciales fallos, reduciendo arreglos caras y perjuicios a los equipos. Incluso, los indicadores generados de estos equipos pueden emplearse para mejorar procedimientos y incrementar la exposición en motores de investigación.

Las áreas de implementación de los equipos de calibración cubren múltiples industrias, desde la elaboración de ciclos hasta el supervisión ecológico. No interesa si se refiere de enormes fabricaciones productivas o limitados locales domésticos, los sistemas de calibración son esenciales para proteger un desempeño efectivo y sin presencia de paradas.

# Velocidad critica 2025/02/08 7:40 TylerHoive



Sistemas de balanceo: fundamental para el rendimiento uniforme y óptimo de las máquinas.

En el mundo de la tecnología moderna, donde la efectividad y la fiabilidad del aparato son de suma trascendencia, los equipos de balanceo desempeñan un función fundamental. Estos equipos adaptados están creados para balancear y fijar elementos giratorias, ya sea en dispositivos productiva, automóviles de movilidad o incluso en equipos hogareños.

Para los profesionales en soporte de dispositivos y los profesionales, operar con sistemas de calibración es importante para proteger el rendimiento uniforme y confiable de cualquier aparato giratorio. Gracias a estas alternativas modernas modernas, es posible limitar sustancialmente las movimientos, el sonido y la carga sobre los soportes, mejorando la longevidad de piezas costosos.

Igualmente importante es el rol que tienen los sistemas de equilibrado en la soporte al usuario. El asistencia experto y el mantenimiento continuo aplicando estos aparatos permiten ofrecer prestaciones de excelente excelencia, mejorando la contento de los compradores.

Para los titulares de empresas, la financiamiento en equipos de calibración y dispositivos puede ser importante para incrementar la productividad y rendimiento de sus dispositivos. Esto es principalmente importante para los empresarios que manejan medianas y modestas organizaciones, donde cada detalle cuenta.

Por otro lado, los aparatos de calibración tienen una vasta aplicación en el campo de la seguridad y el control de calidad. Permiten detectar potenciales fallos, impidiendo mantenimientos caras y perjuicios a los dispositivos. Más aún, los información recopilados de estos aparatos pueden usarse para mejorar métodos y mejorar la exposición en sistemas de exploración.

Las sectores de implementación de los sistemas de ajuste cubren diversas industrias, desde la elaboración de bicicletas hasta el supervisión ecológico. No influye si se trata de importantes producciones manufactureras o pequeños locales hogareños, los sistemas de ajuste son fundamentales para promover un desempeño efectivo y sin presencia de interrupciones.

# Clava is the best 2025/05/06 8:13 Danielthash

Awesome news for all us

タイトル
名前
URL
コメント