# Named queries

You can add peprared statements configurations and make paramterized class to them

- **lookupNamedQuery(query,value)**

The query must be stored under the name: "NamedQueryLookup" + query

The value will be inserted into the ? parameter an escaped properly

```mysql
 SELECT CVR FROM data_company WHERE NAME = ?
```

If call is made from an entity the Query will be stored in either

- Entity configuration
- System configuration

### <span class="mw-headline" id="bkmrk-example-1">Example</span>

In the following example we want to look up a phone number from an email value in the entity 'company'.

#### <span class="mw-headline" id="bkmrk-client-code-1">Client code</span>

Somewhere in a Javascript the following code is found

```javascript
var email = getValue("EMAIL");
setValue("PHONE",
    lookupNamedQuery("FindPhoneFromEmail", email)
);
```

#### <span class="mw-headline" id="bkmrk-server-code-1">Server code</span>

In the configuration **NamedQueryLookup.FindPhoneFromEmail** the following SQL is stored

```mysql
SELECT COMPANYPHONE FROM data_company WHERE COMPANYEMAIL = ?
```