Determining how many tabs to create and how many lines per each tab

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;







up vote
1
down vote

favorite












I wrote this PL/SQL code for Oracle Apex, works perfectly. At the beginning I had more than 200 lines for the same code. I’m new and I’m still learning. After searching on multiple websites I found what functions to use in order to create dynamically my components but I couldn't find everything I needed. Please review my code and tell me what I should not use.



The code takes from two input fields how many tabs to create and how many lines per each tab.



I didn't know how to create tabs dynamically and I used bootstrap code for this.



declare
number_of_tabs number(10) := :P2_CREATE_TABS;
number_of_lines number(10) := :P2_LINES;
half_number_of_lines number(10) := CEIL(number_of_lines / 2);
lock_column boolean := false;
begin
-- Check if value of number_of_tabs && number_of_lines is not 0 or null
if ((number_of_tabs != 0 OR number_of_tabs is not null) and number_of_tabs <= 5) and ((number_of_lines != 0 or number_of_lines is not null) and number_of_lines <= 20) then
-- Start navigation block
htp.p ('<nav><div class="nav nav-tabs" id="nav-tab" role="tablist">');
-- Generate tabs
for tab_count in 1..number_of_tabs
loop
-- Check if it's the first tab. If true, selected as default, else it's not selected as default
if tab_count = 1 then
htp.p ('<a class="nav-item nav-link active" id="nav-'||tab_count||'-tab" data-toggle="tab" href="#nav-'||tab_count||'" role="tab" aria-controls="nav-'||tab_count||'" aria-selected="true">Document '||tab_count||'</a>');
else
htp.p ('<a class="nav-item nav-link" id="nav-'||tab_count||'-tab" data-toggle="tab" href="#nav-'||tab_count||'" role="tab" aria-controls="nav-'||tab_count||'" aria-selected="false">Document '||tab_count||'</a>');
end if;
end loop;
-- End tabs block
htp.p('</div></nav><div class="tab-content" id="nav-tabContent">');
-- Loop each tab
for tab_index in 1..number_of_tabs
loop
-- Create area for each tab and set first as selected
if tab_index = 1 then
htp.p ('<div class="tab-pane fade show active" id="nav-'||tab_index||'" role="tabpanel" aria-labelledby="nav-'||tab_index||'-tab"><div class="row"><div class"col-md-6" style="margin-left: 17em;"><table class="table">');
else
htp.p ('<div class="tab-pane fade show" id="nav-'||tab_index||'" role="tabpanel" aria-labelledby="nav-'||tab_index||'-tab"><div class="row"><div class"col-md-6" style="margin-left: 17em;"><table class="table">');
end if;
-- Loop each line
for line_index in 1..number_of_lines
loop
-- Check if it's in the first column
if half_number_of_lines >= tab_index then
-- Check if it's the first element from the first column
if line_index = 1 then
htp.p ('<thead><tr><th scope="col"> </th><th scope="col">Name</th><th scope="col">Type</th><th scope="col">Width</th><tbody>');
end if;
end if;
-- Check if it's in the second column
if half_number_of_lines < line_index then
-- Check if it's first value from second column
if lock_column = false then
htp.p ('</tbody></table></div><div class"col-md-6" style="margin-left: 17em;"><table class="table"><thead><tr><th scope="col"> </th><th scope="col">Name</th><th scope="col">Type</th><th scope="col">Width</th><tbody>');
end if;
-- Lock for next element
lock_column := true;
end if;
-- Create table row and element
htp.p ('<tr><th scope="row">'|| line_index ||'</th><td>');
-- Create text field
htp.p ( APEX_ITEM.TEXT(
p_idx => tab_index,
p_value =>'array element '||tab_index ,
p_item_label => 'Name',
p_attributes => 'class="form-control"')
);
-- Close table row for element and opens next element
htp.p ('</td><td>');
-- Create dropdown field
htp.p ( APEX_ITEM.SELECT_LIST(
p_idx => tab_index,
p_list_values => 'Numeric;Numeric',
p_show_null => 'YES',
p_null_value => 'Alphnumeric',
p_null_text => 'Alphnumeric',
p_item_label => 'Type',
p_attributes => 'class="form-control"')
);
-- Close table row for element and opens next element
htp.p ('</td><td>');
-- Create number field
htp.p ( APEX_ITEM.TEXT(
p_idx => tab_index,
p_value =>'123' ,
p_item_label => 'Width',
p_attributes => 'class="form-control"')
);
-- Close table row for element and opens next element
htp.p ('</td></tr>');
end loop;
-- Close table
htp.p ('</tbody></table></div></div>');
-- Reset lock for the next tab
lock_column := false;
htp.p ('</div>');
end loop;
htp.p('</div>');
end if;
end;






share|improve this question





















  • Why don't you use a standard APEX Tabs? You can manage their visibility by server-side conditions and authentication schemes.
    – Dmitry
    May 16 at 11:18
















up vote
1
down vote

favorite












I wrote this PL/SQL code for Oracle Apex, works perfectly. At the beginning I had more than 200 lines for the same code. I’m new and I’m still learning. After searching on multiple websites I found what functions to use in order to create dynamically my components but I couldn't find everything I needed. Please review my code and tell me what I should not use.



The code takes from two input fields how many tabs to create and how many lines per each tab.



I didn't know how to create tabs dynamically and I used bootstrap code for this.



declare
number_of_tabs number(10) := :P2_CREATE_TABS;
number_of_lines number(10) := :P2_LINES;
half_number_of_lines number(10) := CEIL(number_of_lines / 2);
lock_column boolean := false;
begin
-- Check if value of number_of_tabs && number_of_lines is not 0 or null
if ((number_of_tabs != 0 OR number_of_tabs is not null) and number_of_tabs <= 5) and ((number_of_lines != 0 or number_of_lines is not null) and number_of_lines <= 20) then
-- Start navigation block
htp.p ('<nav><div class="nav nav-tabs" id="nav-tab" role="tablist">');
-- Generate tabs
for tab_count in 1..number_of_tabs
loop
-- Check if it's the first tab. If true, selected as default, else it's not selected as default
if tab_count = 1 then
htp.p ('<a class="nav-item nav-link active" id="nav-'||tab_count||'-tab" data-toggle="tab" href="#nav-'||tab_count||'" role="tab" aria-controls="nav-'||tab_count||'" aria-selected="true">Document '||tab_count||'</a>');
else
htp.p ('<a class="nav-item nav-link" id="nav-'||tab_count||'-tab" data-toggle="tab" href="#nav-'||tab_count||'" role="tab" aria-controls="nav-'||tab_count||'" aria-selected="false">Document '||tab_count||'</a>');
end if;
end loop;
-- End tabs block
htp.p('</div></nav><div class="tab-content" id="nav-tabContent">');
-- Loop each tab
for tab_index in 1..number_of_tabs
loop
-- Create area for each tab and set first as selected
if tab_index = 1 then
htp.p ('<div class="tab-pane fade show active" id="nav-'||tab_index||'" role="tabpanel" aria-labelledby="nav-'||tab_index||'-tab"><div class="row"><div class"col-md-6" style="margin-left: 17em;"><table class="table">');
else
htp.p ('<div class="tab-pane fade show" id="nav-'||tab_index||'" role="tabpanel" aria-labelledby="nav-'||tab_index||'-tab"><div class="row"><div class"col-md-6" style="margin-left: 17em;"><table class="table">');
end if;
-- Loop each line
for line_index in 1..number_of_lines
loop
-- Check if it's in the first column
if half_number_of_lines >= tab_index then
-- Check if it's the first element from the first column
if line_index = 1 then
htp.p ('<thead><tr><th scope="col"> </th><th scope="col">Name</th><th scope="col">Type</th><th scope="col">Width</th><tbody>');
end if;
end if;
-- Check if it's in the second column
if half_number_of_lines < line_index then
-- Check if it's first value from second column
if lock_column = false then
htp.p ('</tbody></table></div><div class"col-md-6" style="margin-left: 17em;"><table class="table"><thead><tr><th scope="col"> </th><th scope="col">Name</th><th scope="col">Type</th><th scope="col">Width</th><tbody>');
end if;
-- Lock for next element
lock_column := true;
end if;
-- Create table row and element
htp.p ('<tr><th scope="row">'|| line_index ||'</th><td>');
-- Create text field
htp.p ( APEX_ITEM.TEXT(
p_idx => tab_index,
p_value =>'array element '||tab_index ,
p_item_label => 'Name',
p_attributes => 'class="form-control"')
);
-- Close table row for element and opens next element
htp.p ('</td><td>');
-- Create dropdown field
htp.p ( APEX_ITEM.SELECT_LIST(
p_idx => tab_index,
p_list_values => 'Numeric;Numeric',
p_show_null => 'YES',
p_null_value => 'Alphnumeric',
p_null_text => 'Alphnumeric',
p_item_label => 'Type',
p_attributes => 'class="form-control"')
);
-- Close table row for element and opens next element
htp.p ('</td><td>');
-- Create number field
htp.p ( APEX_ITEM.TEXT(
p_idx => tab_index,
p_value =>'123' ,
p_item_label => 'Width',
p_attributes => 'class="form-control"')
);
-- Close table row for element and opens next element
htp.p ('</td></tr>');
end loop;
-- Close table
htp.p ('</tbody></table></div></div>');
-- Reset lock for the next tab
lock_column := false;
htp.p ('</div>');
end loop;
htp.p('</div>');
end if;
end;






share|improve this question





















  • Why don't you use a standard APEX Tabs? You can manage their visibility by server-side conditions and authentication schemes.
    – Dmitry
    May 16 at 11:18












up vote
1
down vote

favorite









up vote
1
down vote

favorite











I wrote this PL/SQL code for Oracle Apex, works perfectly. At the beginning I had more than 200 lines for the same code. I’m new and I’m still learning. After searching on multiple websites I found what functions to use in order to create dynamically my components but I couldn't find everything I needed. Please review my code and tell me what I should not use.



The code takes from two input fields how many tabs to create and how many lines per each tab.



I didn't know how to create tabs dynamically and I used bootstrap code for this.



declare
number_of_tabs number(10) := :P2_CREATE_TABS;
number_of_lines number(10) := :P2_LINES;
half_number_of_lines number(10) := CEIL(number_of_lines / 2);
lock_column boolean := false;
begin
-- Check if value of number_of_tabs && number_of_lines is not 0 or null
if ((number_of_tabs != 0 OR number_of_tabs is not null) and number_of_tabs <= 5) and ((number_of_lines != 0 or number_of_lines is not null) and number_of_lines <= 20) then
-- Start navigation block
htp.p ('<nav><div class="nav nav-tabs" id="nav-tab" role="tablist">');
-- Generate tabs
for tab_count in 1..number_of_tabs
loop
-- Check if it's the first tab. If true, selected as default, else it's not selected as default
if tab_count = 1 then
htp.p ('<a class="nav-item nav-link active" id="nav-'||tab_count||'-tab" data-toggle="tab" href="#nav-'||tab_count||'" role="tab" aria-controls="nav-'||tab_count||'" aria-selected="true">Document '||tab_count||'</a>');
else
htp.p ('<a class="nav-item nav-link" id="nav-'||tab_count||'-tab" data-toggle="tab" href="#nav-'||tab_count||'" role="tab" aria-controls="nav-'||tab_count||'" aria-selected="false">Document '||tab_count||'</a>');
end if;
end loop;
-- End tabs block
htp.p('</div></nav><div class="tab-content" id="nav-tabContent">');
-- Loop each tab
for tab_index in 1..number_of_tabs
loop
-- Create area for each tab and set first as selected
if tab_index = 1 then
htp.p ('<div class="tab-pane fade show active" id="nav-'||tab_index||'" role="tabpanel" aria-labelledby="nav-'||tab_index||'-tab"><div class="row"><div class"col-md-6" style="margin-left: 17em;"><table class="table">');
else
htp.p ('<div class="tab-pane fade show" id="nav-'||tab_index||'" role="tabpanel" aria-labelledby="nav-'||tab_index||'-tab"><div class="row"><div class"col-md-6" style="margin-left: 17em;"><table class="table">');
end if;
-- Loop each line
for line_index in 1..number_of_lines
loop
-- Check if it's in the first column
if half_number_of_lines >= tab_index then
-- Check if it's the first element from the first column
if line_index = 1 then
htp.p ('<thead><tr><th scope="col"> </th><th scope="col">Name</th><th scope="col">Type</th><th scope="col">Width</th><tbody>');
end if;
end if;
-- Check if it's in the second column
if half_number_of_lines < line_index then
-- Check if it's first value from second column
if lock_column = false then
htp.p ('</tbody></table></div><div class"col-md-6" style="margin-left: 17em;"><table class="table"><thead><tr><th scope="col"> </th><th scope="col">Name</th><th scope="col">Type</th><th scope="col">Width</th><tbody>');
end if;
-- Lock for next element
lock_column := true;
end if;
-- Create table row and element
htp.p ('<tr><th scope="row">'|| line_index ||'</th><td>');
-- Create text field
htp.p ( APEX_ITEM.TEXT(
p_idx => tab_index,
p_value =>'array element '||tab_index ,
p_item_label => 'Name',
p_attributes => 'class="form-control"')
);
-- Close table row for element and opens next element
htp.p ('</td><td>');
-- Create dropdown field
htp.p ( APEX_ITEM.SELECT_LIST(
p_idx => tab_index,
p_list_values => 'Numeric;Numeric',
p_show_null => 'YES',
p_null_value => 'Alphnumeric',
p_null_text => 'Alphnumeric',
p_item_label => 'Type',
p_attributes => 'class="form-control"')
);
-- Close table row for element and opens next element
htp.p ('</td><td>');
-- Create number field
htp.p ( APEX_ITEM.TEXT(
p_idx => tab_index,
p_value =>'123' ,
p_item_label => 'Width',
p_attributes => 'class="form-control"')
);
-- Close table row for element and opens next element
htp.p ('</td></tr>');
end loop;
-- Close table
htp.p ('</tbody></table></div></div>');
-- Reset lock for the next tab
lock_column := false;
htp.p ('</div>');
end loop;
htp.p('</div>');
end if;
end;






share|improve this question













I wrote this PL/SQL code for Oracle Apex, works perfectly. At the beginning I had more than 200 lines for the same code. I’m new and I’m still learning. After searching on multiple websites I found what functions to use in order to create dynamically my components but I couldn't find everything I needed. Please review my code and tell me what I should not use.



The code takes from two input fields how many tabs to create and how many lines per each tab.



I didn't know how to create tabs dynamically and I used bootstrap code for this.



declare
number_of_tabs number(10) := :P2_CREATE_TABS;
number_of_lines number(10) := :P2_LINES;
half_number_of_lines number(10) := CEIL(number_of_lines / 2);
lock_column boolean := false;
begin
-- Check if value of number_of_tabs && number_of_lines is not 0 or null
if ((number_of_tabs != 0 OR number_of_tabs is not null) and number_of_tabs <= 5) and ((number_of_lines != 0 or number_of_lines is not null) and number_of_lines <= 20) then
-- Start navigation block
htp.p ('<nav><div class="nav nav-tabs" id="nav-tab" role="tablist">');
-- Generate tabs
for tab_count in 1..number_of_tabs
loop
-- Check if it's the first tab. If true, selected as default, else it's not selected as default
if tab_count = 1 then
htp.p ('<a class="nav-item nav-link active" id="nav-'||tab_count||'-tab" data-toggle="tab" href="#nav-'||tab_count||'" role="tab" aria-controls="nav-'||tab_count||'" aria-selected="true">Document '||tab_count||'</a>');
else
htp.p ('<a class="nav-item nav-link" id="nav-'||tab_count||'-tab" data-toggle="tab" href="#nav-'||tab_count||'" role="tab" aria-controls="nav-'||tab_count||'" aria-selected="false">Document '||tab_count||'</a>');
end if;
end loop;
-- End tabs block
htp.p('</div></nav><div class="tab-content" id="nav-tabContent">');
-- Loop each tab
for tab_index in 1..number_of_tabs
loop
-- Create area for each tab and set first as selected
if tab_index = 1 then
htp.p ('<div class="tab-pane fade show active" id="nav-'||tab_index||'" role="tabpanel" aria-labelledby="nav-'||tab_index||'-tab"><div class="row"><div class"col-md-6" style="margin-left: 17em;"><table class="table">');
else
htp.p ('<div class="tab-pane fade show" id="nav-'||tab_index||'" role="tabpanel" aria-labelledby="nav-'||tab_index||'-tab"><div class="row"><div class"col-md-6" style="margin-left: 17em;"><table class="table">');
end if;
-- Loop each line
for line_index in 1..number_of_lines
loop
-- Check if it's in the first column
if half_number_of_lines >= tab_index then
-- Check if it's the first element from the first column
if line_index = 1 then
htp.p ('<thead><tr><th scope="col"> </th><th scope="col">Name</th><th scope="col">Type</th><th scope="col">Width</th><tbody>');
end if;
end if;
-- Check if it's in the second column
if half_number_of_lines < line_index then
-- Check if it's first value from second column
if lock_column = false then
htp.p ('</tbody></table></div><div class"col-md-6" style="margin-left: 17em;"><table class="table"><thead><tr><th scope="col"> </th><th scope="col">Name</th><th scope="col">Type</th><th scope="col">Width</th><tbody>');
end if;
-- Lock for next element
lock_column := true;
end if;
-- Create table row and element
htp.p ('<tr><th scope="row">'|| line_index ||'</th><td>');
-- Create text field
htp.p ( APEX_ITEM.TEXT(
p_idx => tab_index,
p_value =>'array element '||tab_index ,
p_item_label => 'Name',
p_attributes => 'class="form-control"')
);
-- Close table row for element and opens next element
htp.p ('</td><td>');
-- Create dropdown field
htp.p ( APEX_ITEM.SELECT_LIST(
p_idx => tab_index,
p_list_values => 'Numeric;Numeric',
p_show_null => 'YES',
p_null_value => 'Alphnumeric',
p_null_text => 'Alphnumeric',
p_item_label => 'Type',
p_attributes => 'class="form-control"')
);
-- Close table row for element and opens next element
htp.p ('</td><td>');
-- Create number field
htp.p ( APEX_ITEM.TEXT(
p_idx => tab_index,
p_value =>'123' ,
p_item_label => 'Width',
p_attributes => 'class="form-control"')
);
-- Close table row for element and opens next element
htp.p ('</td></tr>');
end loop;
-- Close table
htp.p ('</tbody></table></div></div>');
-- Reset lock for the next tab
lock_column := false;
htp.p ('</div>');
end loop;
htp.p('</div>');
end if;
end;








share|improve this question












share|improve this question




share|improve this question








edited Apr 3 at 14:39









Jamal♦

30.1k11114225




30.1k11114225









asked Apr 3 at 13:41









Adrian Nicolae

93




93











  • Why don't you use a standard APEX Tabs? You can manage their visibility by server-side conditions and authentication schemes.
    – Dmitry
    May 16 at 11:18
















  • Why don't you use a standard APEX Tabs? You can manage their visibility by server-side conditions and authentication schemes.
    – Dmitry
    May 16 at 11:18















Why don't you use a standard APEX Tabs? You can manage their visibility by server-side conditions and authentication schemes.
– Dmitry
May 16 at 11:18




Why don't you use a standard APEX Tabs? You can manage their visibility by server-side conditions and authentication schemes.
– Dmitry
May 16 at 11:18















active

oldest

votes











Your Answer




StackExchange.ifUsing("editor", function ()
return StackExchange.using("mathjaxEditing", function ()
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
);
);
, "mathjax-editing");

StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "196"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);








 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f191165%2fdetermining-how-many-tabs-to-create-and-how-many-lines-per-each-tab%23new-answer', 'question_page');

);

Post as a guest



































active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes










 

draft saved


draft discarded


























 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f191165%2fdetermining-how-many-tabs-to-create-and-how-many-lines-per-each-tab%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

Chat program with C++ and SFML

Function to Return a JSON Like Objects Using VBA Collections and Arrays

Will my employers contract hold up in court?