Selecting based on GUID oracle server - oracle

I'm having some issues selecting data from my tables based on their GUID after reading the values into variables in visual basic.
In my database the GUID is stored as a byte array.
I read the GUID from my database using
dim g as guid
g = New Guid(CType(recData(0).Item(0), Byte()))
The issue I'm having it re-formatting it to select a row based on it.
Essentially, I'm not quite sure how to do the reverse of what I have done here. I've decoded the data to be used in visual basic, but now I'm not sure how to re-encode it to select based on the guid in my oracle database.
I have tried using g.toByteArray() but it does not appear to be correct.

Related

Create random string in ABAP CDS view

I would like to replace some ABAP logic with ABAP-CDS views. We don't have a HANA DB ( yet ) - so no SQL Script. Is there a way to create a random String with a defined length in ABAP-CDS?
This is a preparation for our HANA DB migration and should replace the function module "GENERAL_GET_RANDOM_STRING".
I want to "push down" as much logic as possible to the database, because we have about 16.000.000 entries where we need to enter a random string. And if this is created via Database this would be much faster.
Some ideas:
Generate a GUID and truncate it to the length of your random string requirements.
Alternatively if your string is not entirely random and you have an array of values you want to randomly pick from. Select that list with a new column of generated GUID. Sort that list using the guid, pick the top one. In the back of my mind I have a nagging doubt that I'm missing a step from this one. Perhaps the GUID has to be trunctated also in this scenario.
Hope this helps.

auto increment of data(int type) which is not Id(identity already used) ASP.NET MVC

I am trying to auto increment data, which is not Id, I have used Sql Identity on Id so can't use it anymore. I tried sql sequence to bind data column and it works if I add information from sql via script but it does not work on adding from visual studio. I tried to [DatabaseGenerated(DatabaseGeneratedOption.Computed)] but it does not work too. I have been searching this topic for 2 days in web but can't find any solution
You can use SQL Sequences for this. According to the documentation by Microsoft
A sequence is a user-defined schema bound object that generates a sequence of numeric values according to the specification with which the sequence was created. The sequence of numeric values is generated in an ascending or descending order at a defined interval and can be configured to restart (cycle) when exhausted. Sequences, unlike identity columns, are not associated with specific tables. Applications refer to a sequence object to retrieve its next value. The relationship between sequences and tables is controlled by the application. User applications can reference a sequence object and coordinate the values across multiple rows and tables.
You can create a sequence using the syntax below:
CREATE SEQUENCE OrderNumber
START WITH 1
INCREMENT BY 1 ;
GO
To check how it can be used in MVC, please check this post.
Hope this helps!

Visual Studio 2010 Ultimate - Data Generation Plan Setting Incorrect Data Type for Column

I have been looking into how to generate test data in our database so that we can test CRUD operations without running into foreign key constraint issues on insert.
The approach I decided to take was through Visual Studio 2010 Ultimate's Data Generator feature. Setting up the Data Generator plan for our specific database wasn't too difficult, but I am being held up by a data type issue.
Specifically, one of the columns in the database is set to be of type Bit; however, the data generator plan is setting the data type to int. From here, the only generator options I can select are Data bound generator, Integer, Sequential data bound generator, SmallInt, and TinyInt.
All options except those with Int in their name don't produce an output value when running the generator. Running the generator with one of the Int generators to try and generate a value results in this error:
Error 1 TSD50003: The generator Int is not valid for column [dbo].[Contract_Relationship].[status] - type bit
This error is obvious given that the column is actually a bit instead of an Int. What isn't so obvious is how I can go about changing the data type on the column to be the correct one.
I have tried looking at the data type generator definitions under the Tools > Options > Database > Default Generators and Bit falls under the Default Data Generator Category which is tied to the Boolean type under the SQL Data Type Category.
From here I am also unable to change the generators as the dropdowns for the Default Data Generator category are tied to each SQL Data Type. Trying to change the data type of the Bit column in the Data Generator plan also doesn't work as it is read only.
Finally, I would set the column to null as a work around but it is set to be not null. Does anyone have any suggestions on how to change the data type of the column to be Bit?
I noticed after poking around a bit more in the Dev team's schema files that the column is actually set to an Int data type in there Create Table .sql files. It would seem to me that the information the Data Generator is using for the schema comes from these files.
It seems odd that the column is incorrect between the create table files and the actual database in the SQL Server client, but it is probably something not related to my question directly.
I would still be interested if anyone knew how to change the data type in the data generator, or even where the data generator is pulling the schema information from.

Enterprise Architect Oracle long field column properties

I have a little problem with Enterprise Architect by Sparx System.
Im trying to model database schema for Oracle. I created table with primary key with data type long. But when im trying to modify column properties (set AutoNum = true) I see empty properties. I read documentation of EA and saw that I need to setup this property to generate sequence syntax.
When I change data type to number, or switch database to mysql (for example) everything is alright, there are properties so Im able to modify AutoNum value.
Did you had similar problem and found solution ? or maybe im doing something wrong.
regards
It's becouse Oracle use sequence instead of autoincrement option. I've checked it and I think you have to use NUMBER column type and then set AutoNum property (you have to select Generate Sequences in options to get proper DDL code too). Instead of LONG data type you can set PRECISION and SCALE options on NUMBER type ie NUMBER(8) mean you can have 8 digits number and it can be set up to 38, so if you don't want to store info about every star in the universe will be enought for your scenario :)

LINQ FormatException

I currently have an existing database and I am using the LINQtoSQL generator tool to create the classes for me. The tool is working fine for this database and there are no errors with that tool.
When I run a LINQ to SQL query against the data, there is a row that has some invalid data somehow within the table and it is throwing a System.FormatException when it runs across this row. Does anyone know what that stems from? Does anyone know how I can narrow down the effecting column without adding them one by one to the select clause?
Do you have a varchar(1) that stores an empty string?
You need to change the type from char to string in the designer (or somehow prohibit empties). The .net char type cannot hold an empty string.

Resources