enter image description here

i have four columns named as start_time,end_time,class_time and class_duration and insert whole record in a single row like start_time should be 0900AM , end_time should be 1000AM , class_time should be 0930AM:0930AM and class_duration should be 60 that is 60 minutes

1

There are 1 best solutions below

6
On

Shuttle item, as any select list item, uses list of values whose select statement has to contain exactly two columns:

  • display value
  • return value

Display value is what users see, return value is what you store into the database, usually some kind of an ID.

If you want to display all those 4 values, you'll have to concatenate them, such as

select 'Start time: ' || start_time ||
       'End time:   ' || end_time   ||
       'Class time: ' || class_time ||
       'Duration:   ' || duration       as display_value,
       --
       something  as return_value
from your_table

If there's nothing "special" to return (i.e. no ID), you can use the same concatenated columns for both display and return values.


[EDIT: how to insert data into a table?]

Suppose this is the target table:

SQL> create table schedule
  2    (id       number,
  3     cstart   varchar2(6),
  4     cend     varchar2(6),
  5     cclass   varchar2(6),
  6     duration varchar2(6));

Table created.

Then suppose that values shuttle item contains looks like this:

Start=0900AM,End=1000AM,Class=1030AM,Duration=60

Values are separated by commas (because, if you select multiple values in a shuttle item, they will be separated by colons so - you'd rather pick something else for your separator).

Those multiple values look like this: 1:2:4:8 represents 4 shuttle values.

Now, insert: see comments within code:

SQL> insert into schedule (id, cstart, cend, cclass, duration)
  2  with shuttle (col) as
  3    (select 'Start=0900AM,End=1000AM,Class=1030AM,Duration=60' ||':'||
  4            'Start=1100AM,End=1130AM,Class=1015AM,Duration=30' from dual
  5    ),
  6  tsplit as
  7    -- split shuttle value into rows. For multiple selection, values
  8    -- are separated by colon. Therefore, you'll have to use something
  9    -- different than that - I used the "=" sign and "," to separate columns
 10    (select level lvl,
 11            regexp_substr(col, '[^:]+', 1, level) val
 12     from shuttle
 13     connect by level <= regexp_count(col, ':') + 1
 14    )
 15  -- now split each value to columns. They are separated by commas
 16  select lvl,
 17    regexp_substr(val, '\w+', 1, 2) cstart,
 18    regexp_substr(val, '\w+', 1, 4) cend,
 19    regexp_substr(val, '\w+', 1, 6) cclass,
 20    regexp_substr(val, '\w+', 1, 8) cduration
 21  from tsplit;

2 rows created.

SQL>
SQL> select * From schedule;

        ID CSTART CEND   CCLASS DURATI
---------- ------ ------ ------ ------
         1 0900AM 1000AM 1030AM 60
         2 1100AM 1130AM 1015AM 30

SQL>

WITH factoring clause will - in your case - be shuttle item value.

That's all, I presume.