Question: For a data ingester service, I'd like to strictly restrict its access to the database in the following way. This ingester service must be able to:

* Create new tables to store new kind of data (i.e. a dynamic ingester able to store new type of data on-the-fly).
* Add a new column to one of the tables the ingester created (backward-forward schema compatibility only).
* Insert new rows in one of the tables the ingester created.

Another way to specify this ingester role is to look at what it shouldn't be able to do:

* DROP any table, including the tables it created
* SELECT, DELETE, UPDATE any rows in any table
* Remove or update a column in any table

I didn't find any way to satisfy all these constraints with PostgreSQL. 
For example, to Alter a table the ingester role need to own the table, but when you own a table you automatically have access to DELETE, SELECT, UPDATE, ... operations on this table. Ideally, I'd like all these tables owned by a database admin user. This admin user will be the only user allowed to execute any destructive operations. 

Can we use a combination of trigger and function to satisfy those constraints or can we specify that only based on roles and grant operations?

Answer: 
Try replacing the for statement with

```
for(int i=0; i<n; i++)
{ 
     con += string.substring(0,n-i);
}

```
you could use the `n` for the loop 

```
    System.out.println("Please input a string: ");
    String string = in.next();

    System.out.println("Please input an integer: ");
    int n = in.nextInt();

    String con = "";
    String tring = string.substring(0,n);
    for(; n>0; n--)
    {
        con += string.substring(0,n-1);
    }
    System.out.println(tring+con);

```