This is something that has bugged me for many many years and have never asked.

Why is it that when writing SQL against a schema in a databases, whether it be Oracle, Postgres, MySQL or MSSQL I have to specify the database name and the table name? e.g.
SELECT id FROM mydb.mytable;
and other times as
SELECT id FROM mytable;

Is this some sort of configuration thing of the database I really would like to know why.

I am currently using the Postgres PGAdmin SQL Editor. I am selecting in the drop down the DB schema to utilize. When connecting to DB A I wont have to specify the DB in the query but when connecting to DB B I do have to specify the DB in the query. This is inconsistent and does not make any sense to me.
['https://Stackoverflow.com/questions/29516573', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/588492/']
The main problem is that you have declared `position1` as a `VARCHAR(100)` instead of as an `INTEGER`. This leads to the unhelpful error here as there is no substring version that takes a varchar parameter (and in this context conversion from varchar to integer is not supported).

A working (or at least: compiling) version of your function is:

```sql
CREATE OR ALTER FUNCTION TRANSLATE_func
   (text varchar(10000), 
    toReplace varchar(10000), 
    replacePattern varchar(10000))
RETURNS VARCHAR(100)
AS
   declare variable resultat varchar(100);
   declare variable cut varchar(100);
   declare variable i integer;
   declare variable position1  integer;
   declare variable letter  varchar(100);
   declare variable lenght integer;
BEGIN
   i = 1;
   resultat ='';
   lenght =  char_length(text);
   while(i <= lenght) do
   begin
       cut = substring(text from i for 1);
       position1 = position(cut, toReplace);
       if (position1 > 0) then
       begin
           letter = substring(replacePattern from position1 for 1);
           resultat = resultat||''||letter;
       end
       else 
       begin
           resultat = resultat ||''|| cut;
       end
       i = i+1;
   end
   return resultat;
END

```
For Firebird 3

```sql
SET TERM ^ ;

create function translator (
    inp varchar(10000),
    pat varchar(1000),
    rep varchar(1000))
returns varchar(10000)
as
    declare variable tex varchar(10000);
    declare variable inp_idx integer = 1;
    declare variable cha char(1);
    declare variable pos integer;
begin
  tex = '';
  while (inp_idx <= char_length(inp)) do
  begin
    cha = substring(inp from inp_idx for 1);
    pos = position(cha, pat);
    if (pos > 0) then
      cha = substring(rep from pos for 1);
    tex = tex || cha;
    inp_idx = inp_idx + 1;
  end
  return tex;
end^

SET TERM ; ^

```

Test

```sql
select translator('džiná lasaí ireo dana kýrne číraž', 'ážíýč', 'AZIYC')
  from rdb$database;

```

Result

```
dZinA lasaI ireo dana kYrne CIraZ

```