11
In the following show, we have an example already running in PHP. The scenario of the question is the assembly of a "navigation link" based on a data structure.
$node = '006002009'; // Esta informação é obtida dinamicamente.
$segmentos = strlen($node)/3;
$sql = 'SELECT ACESSO_SCRIPT FROM ACESSO_ADMIN WHERE ACESSO_NIVEL';
$or = '';
Concatenation loop of the SQL command
for($x = 0; $x < $segmentos; $x++){
$comp = $x+1;
$sql.= $OR.'="'.substr($node,0,($indent*$comp)).'" ';
$or = ' OR ACESSO_NIVEL';
}
The result of the loop generates the string:
SELECT ACESSO_SCRIPT FROM ACESSO_ADMIN WHERE ACESSO_NIVEL="006" OR ACESSO_NIVEL="006002" OR ACESSO_NIVEL="006002009"`
The challenge is to achieve the same concatenation as the above loop within the Stored Procedure.
Remembering that SP would receive as a parameter only the value of $node
. This value is of variable length and follows a 3-digit segment composition rule.
I’ve seen that it’s correct and I understand, but if you could explain in a summary the steps you asked the question would be more complete.
– Jorge B.
Simply perfect.
– Bertonni Magnus
@Humbertowilsonrondeico glad you helped him if you can mark the answer as solution to your problem
– Adir Kuhn