Click here to Skip to main content
15,906,645 members
Home / Discussions / Database
   

Database

 
Questionstored procedure, LIKE comparison Pin
steve_rm12-Nov-05 18:57
steve_rm12-Nov-05 18:57 
AnswerRe: stored procedure, LIKE comparison Pin
Colin Angus Mackay12-Nov-05 22:33
Colin Angus Mackay12-Nov-05 22:33 
GeneralRe: stored procedure, LIKE comparison Pin
BReddy15-Nov-05 2:48
BReddy15-Nov-05 2:48 
GeneralRe: stored procedure, LIKE comparison Pin
Colin Angus Mackay15-Nov-05 3:04
Colin Angus Mackay15-Nov-05 3:04 
Questionmy problem with ado.net Pin
da vinci coder12-Nov-05 13:07
da vinci coder12-Nov-05 13:07 
AnswerRe: my problem with ado.net Pin
Colin Angus Mackay12-Nov-05 22:38
Colin Angus Mackay12-Nov-05 22:38 
QuestionSQL 2005 & 2000 Pin
Tad McClellan12-Nov-05 3:45
professionalTad McClellan12-Nov-05 3:45 
AnswerRe: SQL 2005 & 2000 Pin
Colin Angus Mackay12-Nov-05 5:18
Colin Angus Mackay12-Nov-05 5:18 
GeneralRe: SQL 2005 & 2000 Pin
Mike Dimmick14-Nov-05 2:26
Mike Dimmick14-Nov-05 2:26 
QuestionWork with two dataBase with different username and password. Pin
goliii12-Nov-05 1:45
goliii12-Nov-05 1:45 
AnswerRe: Work with two dataBase with different username and password. Pin
Colin Angus Mackay12-Nov-05 3:15
Colin Angus Mackay12-Nov-05 3:15 
AnswerRe: Work with two dataBase with different username and password. Pin
Colin Angus Mackay12-Nov-05 3:19
Colin Angus Mackay12-Nov-05 3:19 
QuestionSQL int question (Probably an easy answer too) Pin
Tad McClellan11-Nov-05 15:03
professionalTad McClellan11-Nov-05 15:03 
AnswerRe: SQL int question (Probably an easy answer too) Pin
Colin Angus Mackay11-Nov-05 23:40
Colin Angus Mackay11-Nov-05 23:40 
GeneralRe: SQL int question (Probably an easy answer too) Pin
Tad McClellan12-Nov-05 4:41
professionalTad McClellan12-Nov-05 4:41 
Questionremove a datatable from a dataset Pin
webx1011-Nov-05 10:34
webx1011-Nov-05 10:34 
Questionconnection problem Pin
ashee200011-Nov-05 9:04
ashee200011-Nov-05 9:04 
AnswerRe: connection problem Pin
Colin Angus Mackay11-Nov-05 12:01
Colin Angus Mackay11-Nov-05 12:01 
GeneralRe: connection problem Pin
ashee200014-Nov-05 7:16
ashee200014-Nov-05 7:16 
AnswerRe: connection problem Pin
ricardojb14-Nov-05 17:25
ricardojb14-Nov-05 17:25 
QuestionPassing parameter to Oracle Pin
softty11-Nov-05 8:42
softty11-Nov-05 8:42 
AnswerRe: Passing parameter to Oracle Pin
anandss11-Nov-05 9:18
anandss11-Nov-05 9:18 
You need to use, ODP.Net , Data Provider for Oracle supplied by Oracle. Assuming you have that here is the example from Oracle
/********* Example Start *************/
using System;
using System.Data;
using System.Text;
using System.Reflection;
using Oracle.DataAccess.Client;
using Oracle.DataAccess.Types;

namespace ODPSample
{
class AssocArray
{
static void Main(string[] args)
{
Console.WriteLine("Demo: PL/SQL Associative Array");

// Connect
string connectStr = "User Id=scott;Password=tiger;Data Source=oracle";

// Setup the Tables for sample
Setup(connectStr);

OracleConnection connection = new OracleConnection(connectStr);
OracleCommand cmd = new OracleCommand("begin MyPack.TestVarchar2(:1, :2, :3);end;",
connection);

OracleParameter param1 = cmd.Parameters.Add("param1", OracleDbType.Varchar2);
OracleParameter param2 = cmd.Parameters.Add("param2", OracleDbType.Varchar2);
OracleParameter param3 = cmd.Parameters.Add("param3", OracleDbType.Varchar2);

// Setup the direction
param1.Direction = ParameterDirection.Input;
param2.Direction = ParameterDirection.InputOutput;
param3.Direction = ParameterDirection.Output;

// Specify that we are binding PL/SQL Associative Array
param1.CollectionType = OracleCollectionType.PLSQLAssociativeArray;
param2.CollectionType = OracleCollectionType.PLSQLAssociativeArray;
param3.CollectionType = OracleCollectionType.PLSQLAssociativeArray;

param1.Value = new string[3]{"Input1",
"Input2",
"Input3"};
param2.Value = new string[3]{"Inout1",
"Inout2",
"Inout3"};
param3.Value = null;

// Specify the maximum number of elements in the PL/SQL Associative
// Array
param1.Size = 3;
param2.Size = 3;
param3.Size = 3;

// Setup the ArrayBind Size for param1
param1.ArrayBindSize = new int[3]{13,14,13};

// Setup the ArrayBind Status for param1
param1.ArrayBindStatus = new OracleParameterStatus[3]{
OracleParameterStatus.Success,
OracleParameterStatus.Success,
OracleParameterStatus.Success};

// Setup the ArrayBind Size for param2
param2.ArrayBindSize = new int[3]{20,20,20};

// Setup the ArrayBind Size for param3
param3.ArrayBindSize = new int[3]{20,20,20};

try
{
connection.Open();
cmd.ExecuteNonQuery();
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}

Console.WriteLine("Results:");
Display(cmd.Parameters);
}

public static void Setup(string connectStr)
{
OracleConnection connection = new OracleConnection(connectStr);
OracleCommand command = new OracleCommand("", connection);

try
{
connection.Open();

command.CommandText = "drop table T1";
try
{
command.ExecuteNonQuery();
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}

command.CommandText = "CREATE TABLE T1(COL1 number, COL2 varchar2(20))";
command.ExecuteNonQuery();

StringBuilder hdr = new StringBuilder();
hdr.Append("CREATE or replace PACKAGE MYPACK AS ");
hdr.Append("TYPE AssocArrayVarchar2_t is table of VARCHAR(20) index by BINARY_INTEGER;");
hdr.Append(" PROCEDURE TestVarchar2(");
hdr.Append(" Param1 IN AssocArrayVarchar2_t,");
hdr.Append(" Param2 IN OUT AssocArrayVarchar2_t,");
hdr.Append(" Param3 OUT AssocArrayVarchar2_t);");
hdr.Append(" END MYPACK;");
command.CommandText = hdr.ToString();
command.ExecuteNonQuery();

StringBuilder body = new StringBuilder();
body.Append("CREATE or REPLACE package body MYPACK as ");
body.Append(" PROCEDURE TestVarchar2(");
body.Append(" Param1 IN AssocArrayVarchar2_t,");
body.Append(" Param2 IN OUT AssocArrayVarchar2_t,");
body.Append(" Param3 OUT AssocArrayVarchar2_t)");
body.Append(" IS");
body.Append(" i integer;");
body.Append(" BEGIN");
body.Append(" -- copy a few elements from Param2 to Param1\n");
body.Append(" Param3(1) := Param2(1);");
body.Append(" Param3(2) := NULL;");
body.Append(" Param3(3) := Param2(3);");
body.Append(" -- copy all elements from Param1 to Param2\n");
body.Append(" Param2(1) := Param1(1);");
body.Append(" Param2(2) := Param1(2);");
body.Append(" Param2(3) := Param1(3);");
body.Append(" -- insert some values to db\n");
body.Append(" FOR i IN 1..3 LOOP");
body.Append(" insert into T1 values(i,Param2(i));");
body.Append(" END LOOP;");
body.Append(" END TestVarchar2;");
body.Append("END MYPACK;");


command.CommandText = body.ToString();
command.ExecuteNonQuery();

command.CommandText="Commit";
command.ExecuteNonQuery();
}
catch (Exception e)
{
Console.WriteLine(command.CommandText + ":" + e.Message);
}

}

public static void Display(OracleParameterCollection collection)
{
foreach(OracleParameter p in collection)
{
Console.Write(p.ParameterName + ": ");
for(int i=0;i<3;i++)
{
if (p.Value is OracleString[])
Console.Write((p.Value as OracleString[])[i]);
else
Console.Write((p.Value as string[])[i]);
Console.Write(" ");
}
Console.WriteLine();
}
}
}
}
/********* Example End *************/



Regards
QuestionSQL SPLIT INSERT AND JOIN.... Pin
ModuleKev11-Nov-05 2:13
ModuleKev11-Nov-05 2:13 
QuestionHow to get RelationShip Between SQL Functions? Pin
pubududilena11-Nov-05 1:56
pubududilena11-Nov-05 1:56 
AnswerRe: How to get RelationShip Between SQL Functions? Pin
Colin Angus Mackay11-Nov-05 4:37
Colin Angus Mackay11-Nov-05 4:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.