Ejemplo n.º 1
0
        private long rdfMakeObj(object box, string rtype, string lang)
        {
            long ro_id = 0;
            VirtuosoParameterCollection p0 = new VirtuosoParameterCollection(null);

            p0.Add("box", box);
            p0.Add("type", rtype);
            p0.Add("lang", lang);

            ManagedCommand cmd0 = new ManagedCommand(connection);

            cmd0.SetParameters(p0);
            try
            {
                cmd0.Execute("DB.DBA.RDF_MAKE_OBJ_OF_TYPEDSQLVAL (?, ?, ?)");
            }
            finally
            {
                cmd0.CloseCursor(true);
                cmd0.Dispose();
            }

            VirtuosoParameterCollection p1 = new VirtuosoParameterCollection(null);

            p1.Add("box", box);

            ManagedCommand cmd1 = new ManagedCommand(connection);

            cmd1.SetParameters(p1);
            try
            {
                cmd1.Execute("select rdf_box_ro_id (?)");
                while (cmd1.Fetch())
                {
                    object data = cmd1.GetColumnData(0, cmd1.GetColumnMetaData());
                    if (data != null)
                    {
                        ro_id = (long)data;
                    }
                }
            }
            finally
            {
                cmd1.CloseCursor(true);
                cmd1.Dispose();
            }
            return(ro_id);
        }
Ejemplo n.º 2
0
        // Reorders the parameter collection so that the order of named
        // parameters in the collection matches their order in the SQL
        // command.
        internal VirtuosoParameterCollection handleNamedParams(string sql, VirtuosoParameterCollection _parameters)
        {
            string paramPattern = @"@\w+";
            Regex  paramRegEx   = new Regex(paramPattern);
            Match  match        = paramRegEx.Match(sql);

            // If statement doesn't contain any named parameters
            if (!match.Success)
            {
                return(_parameters);
            }

            VirtuosoParameterCollection newParameters = new VirtuosoParameterCollection(this);

            while (match.Success)
            {
                string paramName = String.Copy(match.Value);

                if (_parameters.IndexOf(paramName) >= 0)
                {
                    newParameters.Add(_parameters[_parameters.IndexOf(paramName)]);
                }
                else
                {
                    // Seems param name saved in parameter
                    // collection may or may not have a
                    // leading @
                    string paramNameWithoutPrefix = String.Copy(paramName.Substring(1));
                    if (_parameters.IndexOf(paramNameWithoutPrefix) >= 0)
                    {
                        newParameters.Add(_parameters[_parameters.IndexOf(paramNameWithoutPrefix)]);
                    }
                }

                match = match.NextMatch();
            }

            return(newParameters);
        }
Ejemplo n.º 3
0
        public void GetProcedureColumns(string text)
        {
            VirtuosoParameterCollection p = new VirtuosoParameterCollection(null);

            p.Add("p1", connection.OuterConnection.Database);
            p.Add("p2", "%");
            p.Add("p3", text);
            p.Add("p4", "%");
            p.Add("p5", 1);              // TODO: take casemode from the connection.
            p.Add("p6", 1);
            SetParameters(p);
            Execute("DB.DBA.SQL_PROCEDURE_COLUMNS (?, ?, ?, ?, ?, ?)");
        }
Ejemplo n.º 4
0
        public override void SetCurrentCatalog(string name)
        {
            VirtuosoParameterCollection p = new VirtuosoParameterCollection(null);

            p.Add("name", name);

            ManagedCommand cmd = new ManagedCommand(this);

            cmd.SetParameters(p);
            try
            {
                cmd.Execute("set_qualifier(?)");
            }
            finally
            {
                cmd.CloseCursor(true);
                cmd.Dispose();
            }
        }
Ejemplo n.º 5
0
        private void InsertRow(int id)
        {
            object i, si, d, r, n, year, month, day, dt, tm, dtm, str, bin;

            if (id == 0)
            {
                i = si = d = r = n = year = month = day = dt = tm = dtm = str = bin = DBNull.Value;
            }
            else
            {
                i     = id + 1000;
                si    = (short)(id + 2000);
                d     = id * 1000.0001;
                r     = (float)(id * 100.001);
                n     = (decimal)id * 10000001;
                year  = 1990 + id;
                month = (id - 1) % 12 + 1;
                day   = (id - 1) % DateTime.DaysInMonth((int)year, (int)month) + 1;
                dt    = new DateTime((int)year, (int)month, (int)day);
                tm    = new TimeSpan(id % 24, id % 60, id % 60);
                dtm   = new DateTime((int)year, (int)month, (int)day, id % 24, id % 60, id % 60);

                int    length = id % 128;
                char[] chars  = new char[length];
                byte[] bytes  = new byte[length];
                for (int count = 0; count < length; count++)
                {
                    chars[count] = (char)('a' + (id + count) % 26 - 1);
                    bytes[count] = (byte)(id + count);
                }
                str = new String(chars);
                bin = bytes;
            }

            VirtuosoCommand insert = connection.CreateCommand();

            insert.CommandText =
                "insert into foo "
                + "(id, i, si, d, r, n, dt, tm, dtm, c, vc, lvc, nc, nvc, lnvc, b, vb, lvb) "
                + "values "
                + "(?,  ?,  ?, ?, ?, ?,  ?,  ?,   ?, ?,  ?,   ?,  ?,   ?,    ?, ?,  ?,   ?)";

            VirtuosoParameterCollection parameters = insert.Parameters;

            VirtuosoParameter idParam = insert.CreateParameter();

            idParam.ParameterName = "id";
            idParam.DbType        = DbType.Int32;
            idParam.Value         = id;
            parameters.Add(idParam);

            VirtuosoParameter iParam = insert.CreateParameter();

            iParam.ParameterName = "i";
            iParam.DbType        = DbType.Int32;
            iParam.Value         = i;
            parameters.Add(iParam);

            VirtuosoParameter siParam = insert.CreateParameter();

            siParam.ParameterName = "si";
            siParam.DbType        = DbType.Int16;
            siParam.Value         = si;
            parameters.Add(siParam);

            VirtuosoParameter dParam = insert.CreateParameter();

            dParam.ParameterName = "d";
            dParam.DbType        = DbType.Double;
            dParam.Value         = d;
            parameters.Add(dParam);

            VirtuosoParameter rParam = insert.CreateParameter();

            rParam.ParameterName = "r";
            rParam.DbType        = DbType.Single;
            rParam.Value         = r;
            parameters.Add(rParam);

            VirtuosoParameter nParam = insert.CreateParameter();

            nParam.ParameterName = "n";
            nParam.DbType        = DbType.Decimal;
            nParam.Value         = n;
            parameters.Add(nParam);

            VirtuosoParameter dtParam = insert.CreateParameter();

            dtParam.ParameterName = "dt";
            dtParam.DbType        = DbType.Date;
            dtParam.Value         = dt;
            parameters.Add(dtParam);

            VirtuosoParameter tmParam = insert.CreateParameter();

            tmParam.ParameterName = "tm";
            tmParam.DbType        = DbType.Time;
            tmParam.Value         = tm;
            parameters.Add(tmParam);

            VirtuosoParameter dtmParam = insert.CreateParameter();

            dtmParam.ParameterName = "dtm";
            dtmParam.DbType        = DbType.DateTime;
            dtmParam.Value         = dtm;
            parameters.Add(dtmParam);

            VirtuosoParameter cParam = insert.CreateParameter();

            cParam.ParameterName = "c";
            cParam.DbType        = DbType.AnsiStringFixedLength;
            cParam.Value         = str;
            parameters.Add(cParam);

            VirtuosoParameter vcParam = insert.CreateParameter();

            vcParam.ParameterName = "vc";
            vcParam.DbType        = DbType.AnsiString;
            vcParam.Value         = str;
            parameters.Add(vcParam);

            VirtuosoParameter lvcParam = insert.CreateParameter();

            lvcParam.ParameterName = "lvc";
            lvcParam.DbType        = DbType.AnsiString;
            lvcParam.Value         = str;
            parameters.Add(lvcParam);

            VirtuosoParameter ncParam = insert.CreateParameter();

            ncParam.ParameterName = "nc";
            ncParam.DbType        = DbType.StringFixedLength;
            ncParam.Value         = str;
            parameters.Add(ncParam);

            VirtuosoParameter nvcParam = insert.CreateParameter();

            nvcParam.ParameterName = "nvc";
            nvcParam.DbType        = DbType.String;
            nvcParam.Value         = str;
            parameters.Add(nvcParam);

            VirtuosoParameter lnvcParam = insert.CreateParameter();

            lnvcParam.ParameterName = "lnvc";
            lnvcParam.DbType        = DbType.String;
            lnvcParam.Value         = str;
            parameters.Add(lnvcParam);

            VirtuosoParameter bParam = insert.CreateParameter();

            bParam.ParameterName = "b";
            bParam.DbType        = DbType.Binary;
            bParam.Value         = bin;
            parameters.Add(bParam);

            VirtuosoParameter vbParam = insert.CreateParameter();

            vbParam.ParameterName = "vb";
            vbParam.DbType        = DbType.Binary;
            vbParam.Value         = bin;
            parameters.Add(vbParam);

            VirtuosoParameter lvbParam = insert.CreateParameter();

            lvbParam.ParameterName = "lvb";
            lvbParam.DbType        = DbType.Binary;
            lvbParam.Value         = bin;
            parameters.Add(lvbParam);

            try
            {
                insert.ExecuteNonQuery();
            }
            finally
            {
                insert.Dispose();
                insert = null;
            }

            DataRow row = checkTable.NewRow();

            row["id"]   = id;
            row["i"]    = i;
            row["si"]   = si;
            row["d"]    = d;
            row["r"]    = r;
            row["n"]    = n;
            row["dt"]   = dt;
            row["tm"]   = tm;
            row["dtm"]  = dtm;
            row["c"]    = str;
            row["vc"]   = str;
            row["lvc"]  = str;
            row["nc"]   = str;
            row["nvc"]  = str;
            row["lnvc"] = str;
            row["b"]    = bin;
            row["vb"]   = bin;
            row["lvb"]  = bin;
            checkTable.Rows.Add(row);
        }
		// Reorders the parameter collection so that the order of named
		// parameters in the collection matches their order in the SQL 
		// command.
		internal VirtuosoParameterCollection handleNamedParams (string sql, VirtuosoParameterCollection _parameters)
		{
			string paramPattern = @"@\w+";
			Regex paramRegEx =  new Regex(paramPattern);
			Match match = paramRegEx.Match(sql);

			// If statement doesn't contain any named parameters
			if (!match.Success)
				return _parameters;

			VirtuosoParameterCollection newParameters = new VirtuosoParameterCollection (this);

			while(match.Success)
			{ 
				string paramName = String.Copy(match.Value);

				if (_parameters.IndexOf (paramName) >= 0)
					newParameters.Add (_parameters[_parameters.IndexOf (paramName)]);
				else
				{
					// Seems param name saved in parameter 
					// collection may or may not have a 
					// leading @
					string paramNameWithoutPrefix = String.Copy(paramName.Substring(1));
					if (_parameters.IndexOf (paramNameWithoutPrefix) >= 0)
					newParameters.Add (_parameters[_parameters.IndexOf (paramNameWithoutPrefix)]);
				}

		 		match = match.NextMatch();
			}
   
			return newParameters;
		}
Ejemplo n.º 7
0
        private void InsertRow(int id)
        {
            object c, nc, b;

            if (id == 0)
            {
                c = nc = b = DBNull.Value;
            }
            else
            {
                int    length = 1 << (id - 1);
                char[] chars  = new char[length];
                byte[] bytes  = new byte[length];
                for (int i = 0; i < length; i++)
                {
                    chars[i] = (char)(' ' + i % (127 - ' '));
                    bytes[i] = (byte)(i % 256);
                }
                c = nc = new String(chars);
                b = bytes;
            }

            VirtuosoCommand insert = connection.CreateCommand();

            insert.CommandText =
                "insert into foo "
                + "(id, c, nc, b) "
                + "values "
                + "(?,  ?,  ?, ?)";

            VirtuosoParameterCollection parameters = insert.Parameters;

            VirtuosoParameter idParam = insert.CreateParameter();

            idParam.ParameterName = "id";
            idParam.DbType        = DbType.Int32;
            idParam.Value         = id;
            parameters.Add(idParam);

            VirtuosoParameter cParam = insert.CreateParameter();

            cParam.ParameterName = "c";
            cParam.DbType        = DbType.AnsiString;
            cParam.Value         = c;
            parameters.Add(cParam);

            VirtuosoParameter ncParam = insert.CreateParameter();

            ncParam.ParameterName = "nc";
            ncParam.DbType        = DbType.String;
            ncParam.Value         = nc;
            parameters.Add(ncParam);

            VirtuosoParameter bParam = insert.CreateParameter();

            bParam.ParameterName = "b";
            bParam.DbType        = DbType.Binary;
            bParam.Value         = b;
            parameters.Add(bParam);

            try
            {
                insert.ExecuteNonQuery();
            }
            finally
            {
                insert.Dispose();
                insert = null;
            }

            DataRow row = checkTable.NewRow();

            row["id"] = id;
            row["c"]  = c;
            row["nc"] = nc;
            row["b"]  = b;
            checkTable.Rows.Add(row);
        }
      private long rdfMakeObj (object box, string rtype, string lang)
      {
	long ro_id = 0;
	VirtuosoParameterCollection p0 = new VirtuosoParameterCollection (null);
        p0.Add("box", box);
	p0.Add("type", rtype);
        p0.Add("lang", lang);

	ManagedCommand cmd0 = new ManagedCommand (connection);
	cmd0.SetParameters (p0);
	try
	{
		cmd0.Execute ("DB.DBA.RDF_MAKE_OBJ_OF_TYPEDSQLVAL (?, ?, ?)");
	}
	finally
	{
		cmd0.CloseCursor (true);
		cmd0.Dispose ();
	}

	VirtuosoParameterCollection p1 = new VirtuosoParameterCollection (null);
        p1.Add("box", box);

	ManagedCommand cmd1 = new ManagedCommand (connection);
	cmd1.SetParameters (p1);
	try
	{
		cmd1.Execute ("select rdf_box_ro_id (?)");
                while(cmd1.Fetch())
                {
		    object data = cmd1.GetColumnData (0, cmd1.GetColumnMetaData ());
		    if (data != null)
			  ro_id = (long) data;
                }
	}
	finally
	{
		cmd1.CloseCursor (true);
		cmd1.Dispose ();
	}
	return ro_id;
      }
Ejemplo n.º 9
0
		public void GetProcedureColumns (string text)
		{
			VirtuosoParameterCollection p = new VirtuosoParameterCollection (null);
			p.Add ("p1", connection.OuterConnection.Database);
			p.Add ("p2", "%");
			p.Add ("p3", text);
			p.Add ("p4", "%");
			p.Add ("p5", 1); // TODO: take casemode from the connection.
			p.Add ("p6", 1);
			SetParameters (p);
			Execute ("DB.DBA.SQL_PROCEDURE_COLUMNS (?, ?, ?, ?, ?, ?)");
		}
		public override void SetCurrentCatalog (string name)
		{
			VirtuosoParameterCollection p = new VirtuosoParameterCollection (null);
			p.Add ("name", name);

			ManagedCommand cmd = new ManagedCommand (this);
			cmd.SetParameters (p);
			try
			{
				cmd.Execute ("set_qualifier(?)");
			}
			finally
			{
				cmd.CloseCursor (true);
				cmd.Dispose ();
			}
		}