How to split a list of values into a variable and how to make a insert
function work under a for each loop in postgreSQL
I am Having two Tables.
partyList
create table partyList
(
sno serial NOT NULL,
Party_title text,
Party_venue text,
Party_date date,
Party_list character varying
);
list
create table list(
sno integer,
participant_name text
);
This is the full SQL FIDDLE.
I want to call a function which can insert values into both tables. and my
output should look like this . partyList table
| SNO | PARTY_TITLE | PARTY_VENUE | PARTY_DATE |
PARTY_LIST |
-------------------------------------------------------------------------------------------------------------------------------------------
| 1 | games | indoor stadium | August, 10 2013 00:00:00+0000 |
ronald;sania;sachin;pointing;samueal;gibbs;gayle;smith; |
| 2 | dance | stage | August, 15 2013 00:00:00+0000 |
micheal jakson; britney ; daddy yankee; ar rehaman; jestin bebber; |
list table
| SNO | PARTICIPANT_NAME |
--------------------------
| 1 | ronald |
| 1 | sania |
| 1 | sachin |
| 1 | pointing |
| 1 | samueal |
| 1 | gibbs |
| 1 | gayle |
| 1 | smith |
| 2 | micheal jakson |
| 2 | britney |
| 2 | daddy yankee |
| 2 | ar rehaman |
| 2 | jestin bebber |
When i call my function by these values as in example below.
insert_function('games','indoor
stadium','08-10-2013','ronald;sania;sachin;pointing;samueal;gibbs;gayle;smith;'),
('dance','stage','08-15-2013','micheal jakson; britney ; daddy yankee; ar
rehaman; jestin bebber;');
Is there a way to split the list items and call the insert query of the
list table in a loop ?
No comments:
Post a Comment