Skip to content

Instantly share code, notes, and snippets.

@klaaz0r
Created December 19, 2015 11:52
Show Gist options
  • Save klaaz0r/f74f44bad92fa7294f6f to your computer and use it in GitHub Desktop.
Save klaaz0r/f74f44bad92fa7294f6f to your computer and use it in GitHub Desktop.
DECLARE
v_amount_of_columns_total NUMBER;
apex_templateid NUMBER;
apex_businessruleid NUMBER;
v_amount_of_columns_used NUMBER;
BEGIN
apex_templateid := :P70_TEMPLATEID;
apex_businessruleid := :P70_ID;
--CHECK THE AMOUNT OF VALUES A TEMPLATE IS ALLOWED TO USE
SELECT amount_of_values
INTO v_amount_of_columns_total
FROM template
WHERE id = apex_templateid;
--CHECK HOW MANY VALUES ARE ALREADY USED
SELECT Count(*)
INTO v_amount_of_columns_used
FROM rule_column
WHERE businessruleid = apex_businessruleid;
--THIS IS PURE FOR TESTING!
htp.P ('<script>console.log("testing function\n COLUMNS USED:'
||v_amount_of_columns_used
||' \nCOLUMNS TOTAL:'
|| v_amount_of_columns_total
||'\nRULE ID:'
||:P70_ID
||'");</script> ');
IF( v_amount_of_columns_total = v_amount_of_columns_used ) THEN
htp.P ('<script>console.log("correct amount of rows shown");</script> ');
ELSE
LOOP
--ADDING ROWS IF NEEDED
htp.P ('<script>
$(document).ready(function(){
apex.widget.tabular.addRow();
});
</script> ');
v_amount_of_columns_used := v_amount_of_columns_used + 1;
EXIT WHEN v_amount_of_columns_used >= v_amount_of_columns_total;
END LOOP;
END IF;
END;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment