Trending December 2023 # What Is Ssis Datepart With Examples? # Suggested January 2024 # Top 18 Popular

You are reading the article What Is Ssis Datepart With Examples? updated in December 2023 on the website Katfastfood.com. We hope that the information we have shared is helpful to you. If you find the content interesting and meaningful, please share it with your friends and continue to follow and support us for the latest updates. Suggested January 2024 What Is Ssis Datepart With Examples?

Definition of SSIS DATEPART

The following article provides an outline for SSIS DATEPART. The DATEPART() function extracts a portion of a certain date, a day, month, year, or time. It generates an integer that is a component of a date every time. To which part of the date should the supplied number be added? For example, year (yy, yyyy), a quarter (qq, q), month (mm, m), day of the year (dy, y), day (dd, d), week (wk, ww), weekday (dw), hour (hh), minute (mi, n), second (ss, s), and millisecond (mm, m) are all valid values and acronyms (ms).

Start Your Free Data Science Course

Hadoop, Data Science, Statistics & others

What is SSIS DATEPART?

The syntax goes like this:

DATEPART(datepart, date)

datepart: This parameter defines which portion of the date should be used to generate a new integer.

date: Is a function that returns a valid date or a date-formatted text.

SELECT DATEDIFF(day, 0, GETDATE ()) %7 + 1;

The above query would return two if today were a Tuesday. In this post, I prefer a date diff-based method.

The SSIS formula below returns a YYYYMMDDHHMMSS style 14-character timestamp from a Date Time (for usage in a variable or generated column, for example). The current date and time are used in this instance; for different datetimes, change getdate() with the variable/column/expression having the relevant value. SSIS expression plays a vital role here. SSIS expressions are a collection of literals, procedures, and operators that produce a single data value. A specific value or composite kind can be used to make a statement.

(DT_STR,4,1252)DATEPART( "yyyy" , getdate() ) + RIGHT("0" + (DT_STR,4,1252)DATEPART( "mm" , getdate() ), 2) + RIGHT("0" + (DT_STR,4,1252)DATEPART( "dd" , getdate() ), 2) + RIGHT("0" + (DT_STR,4,1252)DATEPART( "Hh" , getdate() ), 2) + RIGHT("0" + (DT_STR,4,1252)DATEPART( "mi" , getdate() ), 2) + RIGHT("0" + (DT_STR,4,1252)DATEPART( "ss" , getdate() ), 2)

The above expression is a char count with 1252 cod pages and casting to another data type.

Expressions are a formula that can be used to calculate a value depending on a list of requirements. In this scenario, I’ll construct the file name for a file connection using an expression based on the current date in the format YYYYMMDD.

To demonstrate, I’ve written a simple SSIS package that executes a SQL statement (i.e., calculating the length of each database) and saves the findings to a file. There is only one Data Flow Task in the package:

When we switch to the Information Flow tab, you’ll notice that the job contains an OLE DB Source that utilizes a SQL Server connectivity, as well as a Flat File Endpoint that utilizes a File Connection:

The above Expression is given in the same way which is shown above:

"C:\DatabaseSizes_" + (DT_WSTR,4) DATEPART("yyyy",GetDate()) + RIGHT ("0" + (DT_WSTR,2) DATEPART("mm",GetDate()) ,2) + RIGHT ("0" + (DT_WSTR,2)DATEPART("dd",GetDate()),2) + ".csv"

This will generate a file name like: C:Data123.csv.

Next, to include a time in a file name, the other way expression is:

"C:\Datas_" + (DT_WSTR,4)DATEPART("yyyy",GetDate()) + RIGHT("0" + (DT_WSTR,2)DATEPART("mm",GetDate()) ,2) + RIGHT ("0" + (DT_WSTR,2) DATEPART("dd",GetDate()),2) + "_" + RIGHT ("0" + (DT_WSTR,2) DATEPART("hh",GetDate()),2)+ RIGHT ("0" + (DT_WSTR,2)DATEPART("mi",GetDate()),2) + ".csv" SSIS DATEPART function

Time from DateTime:

(DT_STR,8,1252)(DT_DBTIME)@[User::datetimeVar] (DT_STR,8,1252)(DT_DBTIME)[datetimeCol] (DT_STR,8,1252)(DT_DBTIME)GETDATE()

Choose a day for the week’s start.

The SSSIS DATEFIRST function can be used to determine the first day of the week. One can choose from 1 to 7 as a value. Whenever the value one is specified, Monday is the first day of the week. For SSIS DATEFIRST, one can use the table below to specify a value.

1. To calculate the number of days in the quarter of date field. Here the files are dtf.

For example

If the dtf is "2023-03-04" the count will be 60 If the dtf is "2023-06-20" the count will be 80

expression:

DATEDIFF("DAY",(DT_DATE)(((DT_WSTR,4)YEAR(dtf)) + "-" + ((DT_WSTR,2)(((DATEPART("QUARTER",dtf) – 1) * 3) + 1)) + "-1"),dtf)

2. To calculate the quarter number of a date

For example

If the Dtf is “2023-10-06,” the quarter count will be 5

(DT_WSTR,1)(DATEPART("QUARTER",Dtf)) SSIS DATEPART examples

In this part, let’s look at DATEPART SSIS with examples and interval values.

To get the Month’s name.

SUBSTRING("January February March April May June July August September October November December ",((DATEPART("MONTH",GETDATE())-1)*10)+1,10) SUBSTRING("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec ",((DATEPART("MONTH",GETDATE())-1)*4)+1,3)

Next, taking out to find the day or a week in SSIS, the below expression is given as :

(DT_STR,20,1252)((DATEPART("DW",[Transaction date]) == 7) ? "SUNDAY" : (DATEPART("DW",[Transaction date]) == 1) ? "MONDAY" : (DATEPART("DW",[Transaction date]) == 2) ? "TUESDAY" : (DATEPART("DW",[Transaction date]) == 3) ? "WEDNESDAY" : (DATEPART("DW",[Transaction date]) == 4) ? "THURSDAY" : (DATEPART("DW",[Transaction date]) == 5) ? "FRIDAY" : (DATEPART("DW",[Transaction date]) == 6) ? "SATURDAY" : "NULL")

How can I retrieve the date for a given weekday in SSIS? How can I get last Tuesday’s date, for instance?

To get the date for every given day in the current week, we could use the following command:

DECLARE @DesiredDay INT = 0; DECLARE @OutputDate DATE; SET DATEFIRST 2; /* Tuesday is day 2 */ SET @OutputDate = DATEADD(d, @DesiredDay - DATEPART(DW, GETDATE()), GETDATE()); SELECT @OutputDate;

To get YearMonthDay

@[User::Folder] + "\" + (DT_WSTR, 4)YEAR(GETDATE()) + "\" + Right("0" + (DT_STR,4,1252) DatePart("m",getdate()),3) + "\" + Right("0" + (DT_STR,4,1252) DatePart("d",getdate()),3)

This Returns -\Folder202322

Simple Year Month Day

"P_File" + REPLACE(SUBSTRING((DT_STR, 30, 1252)GETDATE(), 1, 9), "-", "") + ".txt"

This Returns P_File2023210

Conclusion

Coming to an end, we have seen how the Date part plays a significant role in Date Time functions in SSIS. And we have seen SSIS expression to evaluate the respective day/week in files and other things.

Recommended Articles

This is a guide to SSIS DATEPART. Here we discuss the definition, What SSIS DATEPART is, and Examples with code implementation. You may also have a look at the following articles to learn more –

You're reading What Is Ssis Datepart With Examples?

What Is Pascal Case? Definition & Alternatives (With Examples)

What Is Pascal Case?

Pascal Case is a coding convention for naming objects such that the first letters of each compound word are capitalized. Such a convention is used because programming languages don’t allow you to separate words with spaces. Here are some examples of the pascal case:

MyAge

MainViewController

DefaultUserParameters

What Problem Does Pascal Case Solve?

In software development, writing quality code is important. One of the key aspects of writing manageable and scalable code is by naming your code logically.

The problem with coding languages is they don’t allow using spaces in naming.

More often than not, a class, variable, or function needs a name that is a combination of multiple words. For example, you could use a name such as nearbydevicesviewcontroller.

But if you take a look at the name, it’s quite long and hard to read. Because of the restrictions of programming languages, you cannot introduce spaces to the name.

This is where different casing systems help. One of the popular letter casing systems in programming is known as the Pascal case. In Pascal case, the idea is to make each compound word start with a capital letter. The Pascal case makes it easier to read multi-word object names as each word is distinguishable thanks to the capital letters.

For example, let’s convert the previously mentioned 4-word object into the Pascal case:

As you can tell, the word combination is now much easier to read.

Why Is It Called the Pascal Case?

Pascal case became popular in the Pascal programming language community. This is where the term was coined.

The Pascal programming language is not case-sensitive. This meant that using the Pascal case was by no means a requirement!

Because the Pascal casing made code look so much better, it became a convention. From Pascal, the Pascal case has gained popularity and become a convention for many other programming languages. For instance, in Swift programming language, class names typically follow Pascal case naming conventions.

Other Case Systems

Pascal case is not the only case style out there. In total, there are four separate casing styles that are commonly used in software development. These styles are:

Pascal Case

Camel Case

Snake Case

Kebab Case

Let’s take a quick look at each case style.

1. Camel Case (camelCase)

Came case is very similar to Pascal case. The only difference is in the very first letter of a multi-word combination.

In Pascal case, the first letter is also capitalized.

In Camel case, the very first letter is not capitalized.

For instance, here is a variable with a name in camel case:

myBankBalance = 1000

Camel case is an even more popular convention for combining words than the Pascal case.

2. Snake Case (snake_case)

Snake case is another popular case style. Unlike the camel case or Pascal case, the snake case doesn’t use capital letters. Instead, the words are separated by underscores.

For example:

my_bank_balance = 100

In programming, you commonly see snake case when declaring constants. Typically, the letter is also capitalized when declaring constants.

PI_APPROX = 3.14159 MAX_CONNECTIONS = 32

Also, database fields are typically labeled with snake case.

{ username: "Alice", user_login_attempts: 13, last_attempt: 1662988728, } 3. Kebab Case (kebab-case)

A less common, yet still popular choice for combining multiple words in software development is by using the kebab case. The kebab case is reminiscent of the snake case. But instead of using underscores, the words are separated by dashes.

For example:

my-bank-balance = 101

Notice that most of the programming languages don’t support using a dash as a separator. This makes the kebab case not work in most programming languages.

You typically see kebab case in URLs.

Wrap Up

Today you learned what is the Pascal case in programming.

To recap, the Pascal case is a naming convention that keeps your code clean and readable. In the Pascal case, each compound word starts with a capital first letter.

The reason for Pascal case (and other case systems) is that programming languages don’t allow using blank spaces between words.

Pascal case originates from the Pascal coding language. The Pascal community started using the Pascal case to improve code quality. From there, it has spread across multiple coding languages.

In addition to the Pascal case, other popular case styles include:

Camel case (camelCase)

Snake case (snake_case)

Kebab case (kebab-case)

All the case styles serve the same purpose: make code or phrases more readable when spaces are not allowed. Camel and snake case are common in coding. The kebab case is popular in URL slugs.

Thanks for reading. Happy coding!

Read Also

What Is A Voltage Source � � Types And Examples

In electrical and electronic circuits, we have to provide necessary for the operation of the circuit. For this purpose, we used energy sources such as voltage sources and current sources. The energy sources are the active circuit elements, i.e. these elements can provide power or power gain in the circuit. In this article, we will discuss what a voltage source is, and different types of voltage sources.

What is a Voltage Source?

A voltage source is an electric circuit component that is used to create a potential different between two points in an electric circuit. It is basically an active circuit element that provides necessary potential energy in the circuit required to force the electric current through the circuit.

A voltage source is a two terminal device that is connected in a circuit and provide a continuous pressure for the movement of electrons (electric current) in the circuit. The common practical examples of voltage sources are cells, batteries, generators, and other devices that can generate a voltage.

Types of Voltage Sources

Based on the dependence of voltage, the voltage sources are mainly classified into two types −

Independent Voltage Sources

Dependent Voltage Sources

In the following sections of this article, we will discuss in detail about these two types of voltage sources.

Independent Voltage Sources

The type of voltage source whose voltage does not depend on any other current or voltage in the circuit is known as independent voltage source.

Independent voltage sources are further classified into two types depending on the nature of voltage −

Direct Voltage Sources

Alternating Voltage Sources

Direct Voltage Sources

The type of voltage source which produces a voltage of constant polarity, i.e. which has fixed positive and negative terminals, and these polarities do not change with time is known as a direct voltage source. Based on the magnitude of voltage, direct voltage sources can be either “constant voltage sources” or “time varying voltage sources”.

The symbol of direct voltage source is shown in Figure-1.

When a direct voltage source is connected in an electric circuit, it always forces an electric current through the circuit that flows from positive terminal to negative terminal, and such a circuit is commonly referred to as a DC circuit. Real examples of direct voltage sources are cells, batteries, solar cells, dc generators, etc.

Alternating Voltage Sources

A voltage source which produces a voltage whose magnitude changes continuously and the polarity changes periodically is known as alternating voltage source. Therefore, in case of an alternating voltage source, the direction of current through the circuit gets reversed at regular intervals, i.e., the alternating voltage causes the current to flow in one direction for a period of time and after that in the reverse direction for another period of time.

The circuit symbol of alternating voltage source is shown above in Figure-1. The common examples of alternating voltage sources are alternators, inverters, etc.

Dependent Voltage Sources

The type of voltage source whose output voltage depends on any other voltage or current in the circuit is known as a dependent voltage source. Dependent voltage sources are also known as controlled voltage sources.

The controlled voltage sources are classified into the following two types −

Voltage Controlled Voltage Source (VCVS)

Current Controlled Voltage Source (CCVS)

When the output voltage of the voltage source depends upon the voltage in any other part of the electric circuit, then it is known as voltage dependent voltage source (VDVS) or voltage controlled voltage source (VCVS).

On the other hand, when the output voltage of the voltage source depends upon the current in any other part of the circuit, then it is called as current dependent voltage source (CDVS) or current controlled voltage source (CCVS).

Dependent voltage sources are represented by a diamond shaped symbol with polarity marks as shown in Figure-2. The dependent sources are used to model electronic circuits.

Types of Independent Voltage Sources

The independent voltage sources may be also classified into the following two types depending on their internal resistance −

Ideal Voltage Source

Practical Voltage Source

Ideal Voltage Source

A voltage source which has zero internal resistance (or impedance) and can deliver a constant voltage to the circuit to which it connected is known as ideal voltage source. Since an ideal voltage source has zero internal resistance, the voltage across its terminal is equal to the source voltage (or emf). It is because when the current is drawn from an ideal voltage source, there is no voltage drop due to internal resistance. Another important point about the ideal voltage source is that it has 100% efficiency, i.e. there is no power loss in the internal circuit of the ideal voltage source.

The circuit symbol and the current/voltage graph of an ideal voltage source is shown in Figure-3. However, ideal voltage sources do not exist in practice, these are just mathematical models of practical voltage sources with no internal losses.

Practical Voltage Source

A voltage source which has a finite internal resistance and whose terminal voltage drops with the increase in current drawn from it, is known as a practical (or real) voltage source. The circuit symbol and current/voltage graph of a practical voltage source is shown in Figure-4.

From the current/ voltage graph of the real voltage source, it is clear that when current drawn from the source increases, the voltage across its terminals decreases. It is because, the increased current increases the voltage drop across the internal resistance. All the voltage sources that we use in actual practical circuits are the practical voltage sources and have certain internal resistance.

Conclusion

In this article, we discussed in detail about different types of voltage sources. A voltage source provides a constant or variable voltage to an electrical or electronic circuit. The voltage sources act like the excitation system for a circuit that supply required energy for the operation of the circuit.

Based on different parameters, there are several types of voltage sources such as direct voltage sources, alternating voltage sources, dependent voltage sources, ideal voltage sources, practical sources, etc. The common examples of voltage sources are cell, battery, alternator, generator, etc.

How Kafka Topic Works With Examples?

Introduction to Kafka Topic

The Kafka, we are having multiple things that are useful for real-time data processing. It is useful to store the records or data and publish. The topic will further be distributed on the partition level. The same functionality will helpful for the better reliability of the data. It will also helpful for the data or record replication (subject to cluster configuration). As per the requirement, we can store the record or data on the topic partition. While storing the data, the offset key plays an important role. With the help of this, we are able to store the data or record on the different partition with different offset keys.

Start Your Free Data Science Course

Hadoop, Data Science, Statistics & others

Syntax:

./kafka-topics.sh --create --zookeeper 10.10.132.70:2181 --replication-factor 1 --partitions 1 --topic kafka_topic

Shell Script: To create the Kafka topic, we need to use the chúng tôi file or script. We can use the default Kafka topic variable also.

Zookeeper: In the topic command, we need to pass the zookeeper server details.

Replication: We need to define the replication value. As per the recommended value, we need to define it as 3.

Partition: We can also define the partition while creating the topic.

Topic Name: At the end, we need to define the topic name.

How Kafka Topic Works?

It is useful to store the records or messages on a specific topic. For the proper data manipulation, we can use the different Kafka partition. Here, we can use the different key combinations to store the data on the specific Kafka partition.

Below are the lists of configuration options:

1. create. topics. enable: It will help to create an auto-creation on the cluster or server environment.

Update Mode: read-only

2. topic. enable: It will help to enable the delete topic. We can use the Kafka tool to delete. There is no impact if we will have no effect if we will disable the config with offsetting.

Update Mode: read-only

3. topic. compression.codec: With the help of this topic, we can compress codec for the offset topic. To get the automatic commit option, we need to use this configuration property.

Update Mode: read-only

4. topic. num.partitions: It will help for the number of topic partitions (point to the offset commit topic). Once the configuration was done at the time of deployment. After that, it will not change.

Valid Values: [ 1, … ] Update Mode: read-only

5. topic. replication.factor: It will help to set the replication factor of the Kafka offset topic. If we will choose the higher replication value then we will get the higher availability of the data. While creating the internal Kafka topic if we haven’t set the proper replication factor then it may get an error while creating a Kafka topic.

Valid Values: [1,…] Update Mode: read-only

Valid Values:[1,…] Update Mode: read-only

7. replication.factor: It will help to set the default replication factors. It will implement for the automatic Kafka topic creation.

8. partitions: It will help to for the default number of log partitions per Kafka topic.

Valid Values: [1,…] Update Mode: read-only

9. topic.policy.class.name: With the help of this property, we can create the topic policy class. Basically, it will use for validation purposes. The same configuration will help for the class (for the implementation of the org.apache.Kafka.server.policy.CreateTopicPolicy interface).

Update Mode: read-only

Example for the Kafka Topic

Overview

As we have discussed with the multiple components in the Kafka environment. We will create the Kafka topic in multiple ways like script file, variable path, etc. As per the production Kafka environment, it will be recommended that we need to go with Kafka topic replication value 3.

Syntax :

./kafka-topics.sh --create --zookeeper 10.10.132.70:2181 --replication-factor 1 --partitions 1 --topic KafkaTopic1

Explanation:

As per the above command, we are creating the Kafka topic. Here we are using the zookeeper host and port (Hostname: 10.10.132.70, Port No: 2181). Need to define the replication factor i.e. 1 and define the number of partition in the topic. At the last, we need to provide the topic name i.e. KafkaTopic1.

As per the below Screenshot 1 (B), we have connected the environment with the Kafka tool. Here, we need to define the zookeeper configuration in th tool.

As per the below Screenshot 1 (C), we can get the newly created Kafka topic in the Kafka tool. We will get detail information of Kafka topic like partition information, etc.

Output :

Screenshot 1 (A)

Screenshot 1 (B)

Screenshot 1 (C)

Conclusion

We have seen the uncut concept of “Kafka Topic” with the proper example, explanation, and cluster method. It is very important in terms of Kafka environment. It will help to store the messages or records on the Kafka topic. We can create multiple partitions. We can use the different offset keys to store the records or messages into the different Kafka partitions.

Recommended Articles

This is a guide to Kafka Topic. Here we discuss the introduction, syntax, How Kafka Topic Works? and examples with code implementation. You may also have a look at the following articles to learn more –

Working Of Scala Random With Examples

Introduction to Scala Random

The Scala Random function generates random numbers or characters in Scala. To generate the Random numbers over Scala, we use the Random process with Scala.util.Random class. The Random number generated can be anything,, be it Integer, Float, Double, or Char. This random no is important for various-level applications such as Validation. So it is used for the Random numbers generation in our Scala Application.

Start Your Free Software Development Course

Web development, programming languages, Software testing & others

Syntax:

val r = scala.util.Random r: chúng tôi = [email protected] r.nextInt res1: Int = 1825881164 r.nextInt(100) res2: Int = 99 r.nextFloat res3: Float = 0.10983747 Working of Scala Random with Examples

This function takes up the random function to generate numbers for processing; it generally uses the Linear congruential generator; this algorithm works on choosing the random number. We can also select the range over which we want to generate the number over. We will see the random number generation with some examples.

Example #1

Code:

val r = scala.util.Random r: chúng tôi = [email protected] r.nextInt res0: Int = 2123631858 r.nextInt res1: Int = -737405300 r.nextInt res2: Int = 377538368

Every Time the code is run or this function is called we will get the set of different values in the usual pattern without following any rule or pattern. Even we can also set an inclusive as well as an exclusive limit for the random number we want to generate.

Note: By default, the inclusive limit is 0 so we can also set only the exclusive one.

r.nextInt(100) res3: Int = 64 r.nextInt(100) res4: Int = 91 r.nextInt(100) res5: Int = 39 r.nextInt(100) res6: Int = 38

Output:

Example #2

We can also select the Random Float value by the method chúng tôi the range will lie from 0.0 decimal value to 1. Let us check that with some example:

Code:

r.nextFloat res8: Float = 0.59556204 r.nextFloat res9: Float = 0.8322488 r.nextFloat res10: Float = 0.6295014 r.nextFloat res11: Float = 0.69067985 r.nextFloat res12: Float = 0.7225474 r.nextFloat res13: Float = 0.9606658 r.nextFloat res14: Float = 0.77049905

Same as Float we can also create random numbers for Double Values.

r.nextDouble res18: Double = 0.34614360601266014 r.nextDouble res19: Double = 0.38648718502076507 r.nextDouble res20: Double = 0.31311541536121046 r.nextDouble res21: Double = 0.7410149595118738

It also prints the values between 0 to 1. The Boolean value can also use the same Random value and yields result based on Boolean Values.

r.nextBoolean res15: Boolean = true r.nextBoolean res16: Boolean = false r.nextBoolean res17: Boolean = false

Output:

Example #3

Code:

r.nextPrintableChar res24: Char = K r.nextPrintableChar res25: Char = g r.nextPrintableChar res26: Char = k r.nextPrintableChar res27: Char = K r.nextPrintableChar res28: Char = ' r.nextPrintableChar res29: Char = t

So it prints all the CharatcersRandomly. It is possible that the same character or integer value can come many times; there is no rule for the numbers not to be repeated.

Note: This Random function is widely used for Pattern Verification, security applications like Captcha, and other things.

Output:

Example #4

We can also use the Random function over a distribution. One known function that works with it is the Gaussian function. The Gaussian Function takes the Random data over the Gaussian Distribution and prints data accordingly. It returns a random number with a mean of 0 and a deviation of 1. To change this Gaussian value, we need to provide that explicitly.

Code:

r.nextGaussian res35: Double = 1.301074019733114 r.nextGaussian res36: Double = 0.37365693728172494 r.nextGaussian res37: Double = -0.2868649145689896 r.nextGaussian res38: Double = 2.108673488282321

Output:

This is what it generates randomly over a Gaussian Distribution.

Example #5

We can also merge random functions and create a List or store them in the collection we want. Let us check that with Example:

Code:

for(i<- 0 to r.nextInt(4)) yield r.nextDouble res40: scala.collection.immutable.IndexedSeq[Double] = Vector(0.020069508131527525) for(i<- 0 to r.nextInt(4)) yield r.nextDouble res41: scala.collection.immutable.IndexedSeq[Double] = Vector(0.6992494049547558) for(i<- 0 to r.nextInt(10)) yield r.nextDouble res42: scala.collection.immutable.IndexedSeq[Double] = Vector(0.9844960499444084, 0.06772285166187964, 0.9797605964534618, 0.6239437080597234, 0.015670036830630618, 0.8530556031658404) for(i<- 0 to r.nextInt(10)) yield r.nextDouble res43: scala.collection.immutable.IndexedSeq[Double] = Vector(0.0775137969760199, 0.3150585897780521, 0.5429361580144657, 0.7427799136029297, 0.7595647379710992, 0.6097524030728557, 0.5555829149364843, 0.031480808153179884, 0.9486129909099824, 0.1519146584718376) for(i<- 0 to r.nextInt(10)) yield r.nextPrintableChar res44: scala.collection.immutable.IndexedSeq[Char] = Vector(Q, q, n, ", [, r, K, 0, B) for(i<- 0 to r.nextInt(10)) yield r.nextPrintableChar res45: scala.collection.immutable.IndexedSeq[Char] = Vector(%, ?) for(i<- 0 to r.nextInt(10)) yield r.nextPrintableChar res46: scala.collection.immutable.IndexedSeq[Char] = Vector(m, =) for(i<- 0 to r.nextInt(3)) yield r.nextPrintableChar res47: scala.collection.immutable.IndexedSeq[Char] = Vector(6) for(i<- 0 to r.nextInt(10)) yield r.nextPrintableChar res48: scala.collection.immutable.IndexedSeq[Char] = Vector([, =, V, !, Q, f, 9, E)

Here we can see how we merged the different functions of Random and generated results accordingly.

Output:

As a result, this function is used to generate random values throughout the Scala application that may be required repeatedly.

Conclusion

From the above article, we saw how we could use the Scala Random function to generate random values and use it over the Scala Application. We also saw the various type by which we can create a random number. So it is a very good and important method used in Scala Programming for various Scala works.

Recommended Articles

We hope that this EDUCBA information on “Scala Random” was beneficial to you. You can view EDUCBA’s recommended articles for more information.

Postgresql In, Not In With Examples

What is PostgreSQL In ?

The IN operator is used in a WHERE clause that allows checking whether a value is present in a list of other values. In Operation helps to reduce the need for multiple OR conditions in SELECT, UPDATE, INSERT, or DELETE statements.

In this PostgreSQL Tutorial, you will learn the following:

Syntax

The IN operator takes the following syntax:

value IN (value_1, value_2, ...)

The value is the value that you are checking for in the list.

The value_1, value_2… are the list values.

If the value is found in the list, the operator will return a true.

The list can be a set of numbers of strings or even the output result of a SELECT statement as shown below:

value IN (SELECT value FROM table-name);

The statement placed inside the parenthesis is known as a subquery.

With Character

Let us demonstrate how you can use the IN operator with character values.

Consider the following table:

Employees:

Let us run the following query against the above table:

SELECT * FROM Employees WHERE name IN ('James John', 'Mercy Bush', 'Kate Joel');

It return the following:

We have a list of three names. We are searching for whether we can find any of these names in the name column of the Employees table. The Kate Joel was matched to one of the table’s records, and its details were returned.

With Numeric

Now, let us see how we can use the IN operator with numeric values.

Consider the Price table given below:

Price:

We can run the following query against the table:

SELECT * FROM Price WHERE price IN (200, 308, 250, 550);

This returns the following:

We have created a list with 4 numeric values. We are checking whether we can match any of these values with the values contained in the price column of the Price table. Two values were matched, and their details were returned.

Using NOT operator

The IN operator can be used together with the NOT operator. It returns the values that are not found in the specified column. We will use the Price table to demonstrate this.

SELECT * FROM Price WHERE price NOT IN (200, 400, 190, 230);

This will return the following:

We have created a list with 4 numerical values. We are checking the price column of the Price table for values that are not part of the list. Two values, 250 and 300, were not found. Hence their details have been returned.

Using pgAdmin

Now let’s see how the actions can be performed using pgAdmin.

With Character

To accomplish the same through pgAdmin, do this:

Step 1) Login to your pgAdmin account.

Step 2)

Step 3) Type the query in the query editor:

SELECT * FROM Employees WHERE name IN ('James John', 'Mercy Bush', 'Kate Joel');

It should return the following:

With Numeric

To accomplish the same through pgAdmin, do this:

Step 1) Login to your pgAdmin account.

Step 2)

Step 3) Type the query in the query editor:

SELECT * FROM Price WHERE price IN (200, 308, 250, 550);

It should return the following:

Using NOT operator

To accomplish the same through pgAdmin, do this:

Step 1) Login to your pgAdmin account.

Step 2)

Step 3) Type the query in the query editor:

SELECT * FROM Price WHERE price NOT IN (200, 400, 190, 230);

It should return the following:

Summary:

The IN operator is used with the WHERE operator. It allows checking whether a particular value is present in a specific table.

The IN operator helps in reducing the need for multiple OR operators in SELECT, UPDATE, INSERT, or DELETE statements.

When creating a character list to check for the presence of a value, each value in the list should be enclosed within single quotes.

The IN operator can also be used with numeric values.

When the IN operator is used together with the NOT operator, it returns all values that are not found in the specified column.

Download the Database used in this Tutorial

Update the detailed information about What Is Ssis Datepart With Examples? on the Katfastfood.com website. We hope the article's content will meet your needs, and we will regularly update the information to provide you with the fastest and most accurate information. Have a great day!