Wednesday 12 August 2020

How To Display Output Message Like DBMS_OUTPUT.PUT_LINE In PostgreSQL Us...


Only 3.9% of viewers are subscribing to my channel 😓.
I request you to please give click on Subscribe button.
It really helps me grow 😢.



How To Display Output Message Like DBMS_OUTPUT.PUT_LINE In Oracle Using PostgreSQL || Learn PL/pgSQL
How To Display Output Message Like DBMS_OUTPUT.PUT_LINE In PostgreSQL Using PgAdmin | Learn PL/pgSQL










-- The Purpose is to Display Message like DBMS_OUTPUT.PUT_LINE

-- of Oracle in PostgreSQL





CREATE OR REPLACE PROCEDURE public.proc(p_num1 IN numeric,p_num2 IN numeric)

LANGUAGE 'plpgsql'

AS $BODY$

DECLARE

v_sum numeric;

v_mult numeric;

v_div numeric;

BEGIN

v_sum := p_num1 + p_num2;

v_mult := p_num1 * p_num2;

BEGIN

v_div := TRUNC(p_num1/p_num2);

EXCEPTION WHEN OTHERS THEN

v_div := 0;

END;

RAISE NOTICE 'The Sum is : %',v_sum;

RAISE NOTICE 'The Multiplication is : %',v_mult;

RAISE NOTICE 'The Division is : %',v_div;



END;

$BODY$;



CALL public.proc(10,2);


Tuesday 11 August 2020

How To Create A Stored Procedure And Return Multiple Values From The Sto...


Only 3.9% of viewers are subscribing to my channel 😓.
I request you to please give click on Subscribe button.
It really helps me grow 😢.



-- purpose is to return multiple values (more than one value) from a stored procedure

-- in PostgreSQL



How To Create A Stored Procedure And Return Multiple Values From The Stored Procedure In PostgreSQL





CREATE OR REPLACE PROCEDURE public.testing_procedure(p_num1 IN numeric,p_num2 IN numeric,p_sum INOUT numeric,p_mult INOUT numeric,p_div INOUT numeric)

LANGUAGE 'plpgsql'

AS $BODY$

DECLARE

BEGIN

p_sum := p_num1 + p_num2;

p_mult := p_num1 * p_num2;

BEGIN

p_div := p_num1/p_num2;

EXCEPTION WHEN OTHERS THEN

p_div := 0;

END;

END;

$BODY$;



CALL public.testing_procedure(10,0,null,null,0);







CREATE OR REPLACE PROCEDURE public.testing_procedure(p_num1 IN numeric,p_num2 IN numeric,p_sum INOUT numeric,p_mult INOUT numeric,p_div INOUT text)

LANGUAGE 'plpgsql'

AS $BODY$

DECLARE

BEGIN

p_sum := p_num1 + p_num2;

p_mult := p_num1 * p_num2;

BEGIN

p_div := p_num1/p_num2;

EXCEPTION WHEN OTHERS THEN

p_div := 'You cannot divide a value by zero';

END;

END;

$BODY$;



CALL public.testing_procedure(10,0,null,null,'0');


How To Create A Stored Procedure With Parameter Modes IN INOUT OUT Modes...



How To Create A Stored Procedure With Parameter Modes IN INOUT OUT Modes In Postgresql || PL/pgSQL

Only 3.9% of viewers are subscribing to my channel 😓.
I request you to please give click on Subscribe button.
It really helps me grow 😢.



-- purpose is to create a stored procedure with parameter mode (IN, INOUT) and call it



-- IN Only Input and it is default



-- OUT Only Output, only OUT is not allowed in Stored Procedure in PostgreSQL



-- INOUT Input + Output



CREATE OR REPLACE PROCEDURE public.testing_procedure(p_num1 IN numeric,p_num2 IN numeric, p_sum INOUT numeric)

LANGUAGE 'plpgsql'

AS $BODY$

DECLARE

BEGIN

p_sum := p_num1 + p_num2;

END;

$BODY$;



CALL public.testing_procedure(13,10,-1);









CREATE OR REPLACE PROCEDURE public.testing_procedure(p_num1 IN numeric,p_num2 IN numeric, p_sum INOUT numeric,p_mult INOUT numeric)

LANGUAGE 'plpgsql'

AS $BODY$

DECLARE

BEGIN

p_sum := p_num1 + p_num2;

p_mult := p_num1 * p_num2;

END;

$BODY$;



CALL public.testing_procedure(3,0,-1,-1);

How To Create A Stored Procedure And Insert Data Into A Table By Calling...



Only 3.9% of viewers are subscribing to my channel 😓.
I request you to please give click on Subscribe button.
It really helps me grow 😢.




How To Create A Stored Procedure And Insert Data Into A Table By Calling/Using The Stored Procedure



-- the purpose is to create a simple stored procedure in PostgreSQL
-- and Insert Data in the table by calling it using pgAdmin


CREATE TABLE public.testing_table (dummy_column text);

CREATE OR REPLACE PROCEDURE public.testing_procedure(p_msg text)
LANGUAGE 'plpgsql'
AS $BODY$
DECLARE
BEGIN
INSERT INTO public.testing_table(dummy_column) VALUES('Before Inserting Parameter Value');
INSERT INTO public.testing_table(dummy_column) VALUES (p_msg);
INSERT INTO public.testing_table(dummy_column) VALUES('After Inserting Parameter Value');
END;
$BODY$;

SELECT * FROM public.testing_table;

DELETE from public.testing_table;

CALL public.testing_procedure('Hello Akram, How are you?');

Before Inserting
the message I pass as a parameter
After Inserting...

How To Resolve/Fix Issue Could Not Connect To Server Connection Refused ...




Only 3.9% of viewers are subscribing to my channel 😓.
I request you to please give click on Subscribe button.
It really helps me grow 😢.



How To Resolve/Fix Issue Could Not Connect To Server Connection Refused In PostgreSQL pgAdmin 4
How To resolve Issue Application Server Could Not Be Contacted In PostgreSQL

Sunday 9 August 2020

Overloading Of A Stored Function In PostgreSQL || Stored Function Overlo...



Only 3.9% of viewers are subscribing to my channel 😓.
I request you to please give click on Subscribe button.
It really helps me grow 😢.



Overloading Of A Stored Function In PostgreSQL || Stored Function Overloading || PL/pgSQL Tutorials



CREATE OR REPLACE FUNCTION public.testing_function(p_num1 numeric, p_num2 numeric)

RETURNS numeric

LANGUAGE 'plpgsql'

COST 100

VOLATILE

AS $BODY$

DECLARE

v_result numeric;

BEGIN

v_result := p_num1 + p_num2;



RETURN v_result;

END;

$BODY$;







CREATE OR REPLACE FUNCTION public.testing_function(p_num1 numeric, p_num2 numeric,p_num3 numeric)

RETURNS numeric

LANGUAGE 'plpgsql'

COST 100

VOLATILE

AS $BODY$

DECLARE

v_result numeric;

BEGIN

v_result := p_num1 + p_num2 + p_num3;



RETURN v_result;

END;

$BODY$;





CREATE OR REPLACE FUNCTION public.testing_function(p_num1 numeric, p_num2 numeric,p_num3 numeric,p_num4 numeric)

RETURNS numeric

LANGUAGE 'plpgsql'

COST 100

VOLATILE

AS $BODY$

DECLARE

v_result numeric;

BEGIN

v_result := p_num1 + p_num2 + p_num3 + p_num4;



RETURN v_result;

END;

$BODY$;





SELECT public.testing_function(14,5);



SELECT public.testing_function(14,10,50);



SELECT public.testing_function(10,20,30,50);


Overloading Of A Stored Procedure In PostgreSQL | Stored Procedure Overl...




Only 3.9% of viewers are subscribing to my channel 😓.
I request you to please give click on Subscribe button.
It really helps me grow 😢.





Overloading Of A Stored Procedure In PostgreSQL | Stored Procedure Overloading | PL/pgSQL Tutorials



CREATE TABLE public.testing(demo_column text);



CREATE OR REPLACE PROCEDURE public.testing_procedure(p_msg text)

LANGUAGE 'plpgsql'

AS $BODY$

DECLARE

BEGIN

INSERT INTO public.testing(demo_column) VALUES (p_msg);

END;

$BODY$;







CREATE OR REPLACE PROCEDURE public.testing_procedure(p_num1 numeric, p_num2 numeric)

LANGUAGE 'plpgsql'

AS $BODY$

DECLARE

v_result numeric;

BEGIN

v_result := p_num1+p_num2;

INSERT INTO public.testing(demo_column) VALUES ('The Sum is '||v_result);

END;

$BODY$;





CREATE OR REPLACE PROCEDURE public.testing_procedure(p_num1 numeric, p_num2 numeric,p_num3 numeric)

LANGUAGE 'plpgsql'

AS $BODY$

DECLARE

v_result numeric;

BEGIN

v_result := p_num1+p_num2 +p_num3;

INSERT INTO public.testing(demo_column) VALUES ('The Sum is '||v_result);

END;

$BODY$;







CALL public.testing_procedure('Hello Akram');



CALL public.testing_procedure(3,5);



CALL public.testing_procedure(3,5,67);



SELECT * FROM public.testing;






How To Handle Exception In A Stored Procedure In PostgreSQL || PL/pgSQL ...




Only 3.9% of viewers are subscribing to my channel 😓.
I request you to please give click on Subscribe button.
It really helps me grow 😢.



The Purpose Is To Handle Exception In A Stored Procedure In PostgreSQL || PL/pgSQL Tutorials Exception Handling



-- without exception block



CREATE TABLE public.testing (demo_column text);



CREATE OR REPLACE PROCEDURE public.testing_procedure(p_num1 numeric,p_num2 numeric)

LANGUAGE 'plpgsql'

AS $BODY$

DECLARE

v_result numeric;

BEGIN

v_result := p_num1/p_num2;

INSERT INTO public.testing(demo_column) VALUES(v_result);

END;

$BODY$;



CALL public.testing_procedure(100,0);



SELECT * from public.testing;









-- with exception block



CREATE TABLE public.testing (demo_column text);



CREATE OR REPLACE PROCEDURE public.testing_procedure(p_num1 numeric,p_num2 numeric)

LANGUAGE 'plpgsql'

AS $BODY$

DECLARE

v_result text;

BEGIN

BEGIN

v_result := p_num1/p_num2;

EXCEPTION WHEN OTHERS THEN

v_result := 'You cannot divide a number by zero.';

END;

INSERT INTO public.testing(demo_column) VALUES(v_result);



END;

$BODY$;



CALL public.testing_procedure(100,20);



SELECT * from public.testing;


How To Create A Simple Parameterized Stored Procedure In PostgreSQL And ...



Only 3.9% of viewers are subscribing to my channel 😓.
I request you to please give click on Subscribe button.
It really helps me grow 😢.




-- purpose is to create a simple parameterized stored procedure in postgreSQL

-- and call it using pgAdmin



CREATE TABLE public.testing (demo_column text);



CREATE OR REPLACE PROCEDURE public.testing_procedure(p_msg text)

LANGUAGE 'plpgsql'

AS $BODY$

DECLARE

BEGIN

INSERT into public.testing(demo_column) values(p_msg);

END;

$BODY$;



call public.testing_procedure('Hello Akram, We are watching Knowledge 360');



SELECT * from public.testing;

How To Create A Simple Stored Procedure In PostgreSQL And Call Using pgA...




Only 3.9% of viewers are subscribing to my channel 😓.
I request you to please give click on Subscribe button.
It really helps me grow 😢.



-- purpose is to create a simple stored procedure in postgreSQL

-- and call it using pgAdmin





CREATE TABLE public.testing (demo_column text);





CREATE OR REPLACE PROCEDURE public.testing_procedure()

LANGUAGE 'plpgsql'

AS $BODY$

DECLARE

v_msg text;

BEGIN

v_msg := 'Hello Akram, We are watching Knowledge 360';



Insert into public.testing(demo_column) values (v_msg);

END;

$BODY$;





call public.testing_procedure();





SELECT * from public.testing;


Saturday 8 August 2020

How To Handle Exception In A Stored Function/Procedure In PostgreSQL | E...




Only 3.9% of viewers are subscribing to my channel 😓.
I request you to please give click on Subscribe button.
It really helps me grow 😢.



-- without exception block

-- purpose is to handle exception in a stored function in PostgreSQL and call it



SELECT public.testing_function(100,0);



CREATE OR REPLACE FUNCTION public.testing_function(p_num1 numeric, p_num2 numeric)

RETURNS numeric

LANGUAGE 'plpgsql'

COST 100

VOLATILE

AS $BODY$

DECLARE

v_result numeric;

BEGIN

v_result := p_num1/p_num2;

RETURN v_result;

END;

$BODY$;







---with exception block



SELECT public.testing_function(100,0);



CREATE OR REPLACE FUNCTION public.testing_function(p_num1 numeric, p_num2 numeric)

RETURNS text

LANGUAGE 'plpgsql'

COST 100

VOLATILE

AS $BODY$

DECLARE

v_result text;

BEGIN

BEGIN

v_result := p_num1/p_num2;

EXCEPTION WHEN OTHERS THEN

v_result := 'You cannot divide by Zero, try Again';

END;



RETURN v_result;

END;

$BODY$;


How To Create A Parameterized Stored Function In PostgreSQL || Pass Para...



Only 3.9% of viewers are subscribing to my channel 😓.
I request you to please give click on Subscribe button.
It really helps me grow 😢.




SELECT public.testing_function(101,'Hello Akram');


CREATE OR REPLACE FUNCTION public.testing_function(p_num numeric,p_msg text)



RETURNS text

LANGUAGE 'plpgsql'



COST 100

VOLATILE



AS $BODY$



DECLARE

v_return_msg text;

BEGIN



v_return_msg := p_msg ||' '||p_num;



return v_return_msg;



END;

$BODY$;


How To Create A Stored Function In PostgreSQL And Call Stored Function I...




Only 3.9% of viewers are subscribing to my channel 😓.
I request you to please give click on Subscribe button.
It really helps me grow 😢.



SELECT public.testing_function();



CREATE OR REPLACE FUNCTION public.testing_function()



RETURNS text

LANGUAGE 'plpgsql'



COST 100

VOLATILE



AS $BODY$



DECLARE

v_return_msg text;

BEGIN



v_return_msg := 'Hello Akram';



return v_return_msg;



END;

$BODY$;


Friday 31 July 2020

How To Load Database In PostgreSQL Using CMD Command Prompt Or PSQL Comm...



Only 3.9% of viewers are subscribing to my channel 😓.
I request you to please give click on Subscribe button.
It really helps me grow 😢.


pg_restore -U postgres -d dvdrental D:\dvdrental.tar
psql -U postgres postgres < D:\dvdrental.sql


The Purpose is to load database using CMD in PostgreSQL, 2 ways to do it.

How To Convert Table Records Into JSON Array In PostgreSQL | row_to_json...




Only 3.9% of viewers are subscribing to my channel 😓.
I request you to please give click on Subscribe button.
It really helps me grow 😢.





-- Purpose is to convert table records into JSON (JavaScript Object Notation)





--row_to_json()



select * from actor;



select row_to_json(row(actor_id,first_name)) from actor;





select row_to_json(actor_alias)

from (select actor_id,first_name from actor) actor_alias;





select row_to_json(actor) from actor;





explain

select array_to_json(array_agg(row_to_json(actor_alias)))

from (select * from actor) actor_alias;




Thursday 16 July 2020

How To Pass Array As Parameter Into A Stored Function/Procedure In Postg...



Only 3.9% of viewers are subscribing to my channel 😓.
I request you to please give click on Subscribe button.
It really helps me grow 😢.



CREATE TABLE public.testing

(

my_values numeric

);







CREATE OR REPLACE FUNCTION public.test_func(p_values numeric[])

RETURNS text

LANGUAGE 'plpgsql'



COST 100

VOLATILE

AS $BODY$

declare

v_array_length numeric(10,0) := 0;

v_msg character varying(100) := null;

begin

v_array_length := array_length(p_values,1);



if (v_array_length > 0) then

for i in 1..v_array_length loop

insert into public.testing (my_values) values (p_values[i]);

end loop;



v_msg := 'Array Processed Successfully With Length'||v_array_length;

else



v_msg := 'Array having no values';

end if;



return v_msg;



end;

$BODY$;







SELECT public.test_func('{123,34}'::numeric[]);  -- 1





SELECT public.test_func('{123,34}');  -- 2







SELECT public.test_func('{}');  -- 3







select * from public.testing;

How To Take Backup Of Database As SQL/TAR File And How Restore Database ...



Only 3.9% of viewers are subscribing to my channel 😓.
I request you to please give click on Subscribe button.
It really helps me grow 😢.



In this video, I have explained How To Take Backup Of Database As SQL/TAR File And How Restore Database In PostgreSQL Using pgAdmin4.
This is a very helpful video if you are a developer working with PostgreSQL.

Wednesday 15 July 2020

How To Export Table Data Into A CSV File And Import Data From CSV File I...




Only 3.9% of viewers are subscribing to my channel 😓.
I request you to please give click on Subscribe button.
It really helps me grow 😢.





The purpose is to Export table data into a CSV (comma-separated values) file and import data from a CSV file into a table in PostgreSQL using pgAdmin.

Tuesday 9 June 2020

The Snake Game Project In C Language With Source Code Explanation 2020 |...



Only 3.9% of viewers are subscribing to my channel 😓.
I request you to please give click on Subscribe button.
It really helps me grow 😢.




In this project, you can play the popular “Snake Game” just like you played it elsewhere.
You have to use the up, down, right or left arrows to move the snake.
Foods are provided at the several co-ordinates of the screen for the snake to eat.
Every time the snake eats the food, its length will be increased by one element along with the '*'.




Download Source Code Here

The Quiz Game Project In C Language With Source Code Explanation 2020 | ...



Only 3.9% of viewers are subscribing to my channel 😓.
I request you to please give click on Subscribe button.
It really helps me grow 😢.



In this project, a number of questions are asked, and the user is awarded a cash prize for each correct answer given.
In the quiz games, questions are chosen in such a way that they cover all fields of a typical quiz contest.
The user’s general knowledge is tested with quiz questions regarding science, technology, movies, sports, general health, geography, and many more.




Download Source Code Here

Monday 8 June 2020

The Calendar Project In C Language 2020 Download With Source Code Explan...



Only 3.9% of viewers are subscribing to my channel 😓.
I request you to please give click on Subscribe button.
It really helps me grow 😢.




In this Calender application project, there are 3 important operations are done.

Such as To find out the day corresponding to a given date, the date, month, and year

are asked and You can list the days and dates of any month of any year.

You can navigate the months using arrow keys, or press ‘n’ and ‘p’ keys to

view the next and previous months respectively.

The third feature is file handling which can add important notes with corresponding dates.



Download Source Code Here

The Student Record System Project In C Language With Source Code Explana...




Only 3.9% of viewers are subscribing to my channel 😓.
I request you to please give click on Subscribe button.
It really helps me grow 😢.



This project is used for files as a database to perform file handling operations such as

add, search, modify, and delete records to manage students’ records.

Using this project, you can also generate a mark-sheet for students.



Download Source Code Here

Sunday 7 June 2020

The Contact Management System Project In C Language Source Code Explanat...




Only 3.9% of viewers are subscribing to my channel 😓.
I request you to please give click on Subscribe button.
It really helps me grow 😢.



Using this project, we can easily add, view, edit, search, and delete contacts.
We can list contacts by name, phone no., address, and email.
File handling is used to record all data so that after the termination of the program data persists.
Here a data structure is used to store the name, email, and contact.
The coding of the project is short and simple.




Download Source Code Here

The Phone Book Application Project In C Language With Source Code Explan...



Only 3.9% of viewers are subscribing to my channel 😓.
I request you to please give click on Subscribe button.
It really helps me grow 😢.



In this project Adding new records, listing them, modifying them,

Search for contacts saved, and deleting the phonebook records, are the basic functions,

which make up the main menu of this Phonebook application.

A structure is used to carry information about a contact.

The phonebook is a very simple mini project in C that can help you understand the basic concepts of functions,

file handling, and data structure.

This application will teach you how to add, list, modify or edit, search, and delete data from the file.



The coding of the project is very short and simple.



Download Source Code Here

Saturday 6 June 2020

The Employee Record System Project In C Language With Source Code Explan...



Only 3.9% of viewers are subscribing to my channel 😓.
I request you to please give click on Subscribe button.
It really helps me grow 😢.



In this Employee record system project, you can manage employee records by adding, listing, modifying, and deleting records.

 Understanding this project will help you learn how to add, view, change, and remove data using file handling.



Download Source Code Here

The Telecom Billing System Project In C Language With Source Code Explan...



Only 3.9% of viewers are subscribing to my channel 😓.
I request you to please give click on Subscribe button.
It really helps me grow 😢.



Using this project you can perform and manage billing operations like they do in Telecom companies.
You can also make payment by providing your phone number instead of name and all data added or modified are recorded in a file.
You can add records with name, phone number, and the amount of payment, and You can view, modify, search, and delete existing records.
This project will also teach you how to add, list, edit, search, and delete records using file handling.

NB: You Need to change Drive/File path accordingly, Here I am doing in D:




Download Source Code Here

The TicTacToe Game In C Language With Source Code Explanation Free Downl...



Only 3.9% of viewers are subscribing to my channel 😓.
I request you to please give click on Subscribe button.
It really helps me grow 😢.



In the C Tic Tac Toe game is a simple console application without graphics.
While making a Tic Tac Toe game using C language, it is important to make use of arrays.
The Xs and Os are kept in different arrays, and they are passed between several functions in the code to keep track of how the game goes.
With the code here you can play the game choosing either X or O against the computer.

To put your turn, you need to specify the position thinking it as a 3x3 array. For example,
if you want to put your turn in the middle of 3rd row, you should enter 8 and so on.

The game is so built, either it's Drawn or the Computer Wins, challenge for you to play this game and win against the computer !!!






Download Source Code Here

The Hangman Game In C Language With Source Code Explanation And Free Dow...



Only 3.9% of viewers are subscribing to my channel 😓.
I request you to please give click on Subscribe button.
It really helps me grow 😢.



The main purpose of this Hangman game project is to illustrate the use of control structures.
Hangman Game has been designed to demonstrate different application formats and syntaxes of C programming language.

The source code of the game is easy, short, understandable, and user friendly and when you start the game, the game asks you to guess a character.
The Hangman Game in C gives five chances to guess and If you are able to match the character in five guesses, you will be the winner.
If you fail to match the character in fives guesses, you will lose the game and hanged by Hangman Game in C.




Download Source Code Here

Friday 5 June 2020

How To Create And Call Stored Procedure In PostgreSQL Using pgAdmin4 || ...



Only 3.9% of viewers are subscribing to my channel 😓.
I request you to please give click on Subscribe button.
It really helps me grow 😢.



How To Create And Call Stored Procedure In PostgreSQL Using pgAdmin4
Procedure In PostgreSQL.
In this video, I explained How To Create and Call a Stored Procedure in PostgreSQL.

How To Convert Date Timestamp Value To Numeric And Numeric To Timestamp ...



Only 3.9% of viewers are subscribing to my channel 😓.
I request you to please give click on Subscribe button.
It really helps me grow 😢.




How To Convert Date Timestamp Value To Numeric And Numeric To Timestamp In PostgreSQL Using pgAdmin4


select cast(extract(epoch from now()) as integer);


select to_timestamp(1591369682);



-- Purpose is to Cast/ Convert A Date value (timestap) to Number and Vice-Versa


SELECT CAST(EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) AS INTEGER);

SELECT CURRENT_TIMESTAMP;

SELECT TO_TIMESTAMP(1591372301);

-- 1591372301

Saturday 30 May 2020

How To Download/Restore/Load Sample Database In PostgreSQL Using pgAdmin4





Only 3.9% of viewers are subscribing to my channel 😓.
I request you to please give click on Subscribe button.
It really helps me grow 😢.






We will use the DVD rental database for demonstrating the features of PostgreSQL.



The DVD rental database represents the business processes of a DVD rental store. The DVD rental database has many objects including:



15 tables

1 trigger

7 views

8 functions

1 domain

13 sequences



PostgreSQL Sample Database Tables

There are 15 tables in the DVD Rental database:



actor – stores actors data including first name and last name.

film – stores films data such as title, release year, length, rating, etc.

film_actor – stores the relationships between films and actors.

category – stores film’s categories data.

film_category- stores the relationships between films and categories.

store – contains the store data including manager staff and address.

inventory – stores inventory data.

rental – stores rental data.

payment – stores customer’s payments.

staff – stores staff data.

customer – stores customers data.

address – stores address data for staff and customers

city – stores the city names.

country – stores the country names.



You can use the pgAdmin tool to restore the sample database from the downloaded database file using the following steps:





First, launch the pgAdmin tool and connect to the PostgreSQL server.



Next, right-click on the dvdrental database and choose Restore… menu item as shown:



After that, wait for a few seconds to let the restoration process completes.



Finally, open the dvdrental database from object browser panel, you will see the tables in the public schema and other database objects as shown.



We have shown you how to load the dvdrental sample database into the PostgreSQL database server for learning and practicing PostgreSQL.



Let’s start learning PostgreSQL and have fun!

How To Return A Table From A Function In PostgreSQL || PostgreSQL Tips




Only 3.9% of viewers are subscribing to my channel 😓.
I request you to please give click on Subscribe button.
It really helps me grow 😢.





RETURNING A TABLE FROM A FUNCTION IN POSTGRESQL

Sometimes for our needs, we may need to return a table from a user-defined function a table. In this blog, we will see how to accomplish this using the PostgreSQL database.

Before going to function and it’s implementation, let’s create a table and store several dummy records in it.
After insertion, let’s check the table values by executing the below statement.

select * from public.functiontest;

CREATE TABLE public.FunctionTest
(
id numeric,
name character varying
);

ALTER TABLE public.FunctionTest
OWNER to postgres;


We have created a table named FunctionTest having 2 columns only.

Let’s put records in it.

INSERT INTO public.functiontest(
id, name)
VALUES (1, 'Akram');

INSERT INTO public.functiontest(
id, name)
VALUES (2, 'Sohail');

The output is shown in the above snapshot.

Now suppose we want to retrieve all the data available in the table by using a user-defined function.

To do it, let’s create a function.

CREATE OR REPLACE FUNCTION public.get_data(
)
RETURNS TABLE(v_id numeric, v_name character varying)
LANGUAGE 'plpgsql'

COST 100
VOLATILE
ROWS 1000

AS $BODY$
DECLARE

BEGIN
RETURN QUERY
SELECT
id,name
FROM
public.functiontest;
END;
$BODY$;

ALTER FUNCTION public.get_data()
OWNER TO postgres;


We have created a simple function get_data() that will return us all the data present in the table functiontest.

To return a table from the function, we use RETURNS TABLE syntax and specify the columns of the table. Each column is separated by a comma (,).

In the function, we return a query that is a result of a SELECT statement. We can see that the columns in the SELECT statement must match with the columns of the table that we want to return.


To call the function, we use the following statement.

SELECT public.get_data();


As we know, the function is returning a table, so here is the output for the called function.
We can also call the function as below, that gives better tabular form output.

SELECT * from get_data();

The above snapshot are the outcome of the function get_data().
So in this way we return a table from a function in PostgreSQL.

Saturday 23 May 2020

How To Download And Install PostgreSQL 12.3 Latest Release In 64 Bit Windows 10 in 2020 || Knowledge 360



Only 3.9% of viewers are subscribing to my channel 😓.
I request you to please give click on Subscribe button.
It really helps me grow 😢.




Hello Friends, I am Akram and in this blog, I will tell you how to download and install the PostgreSQL 12.3 latest release in your windows 10 PC of 64 bit.




1. Click this link to download the installation file, which is of 190 MBs.






2. Install the file and follow step by step procedure.







3. When the installation is done, click on the finish.








4. Search for PgAdmin.







5. Now Enter the password you had given while installing.







Note:- Please take a screenshot of the configuration summary. If you forgot to, please watch the video again and uninstall the file and again install it.