# Defining a Post Query

The post query script lets you manipulate the data after it is fetched from the database. You must write the post query script in the Java programming language.

{% hint style="warning" %}
In order to use a post query, you must ensure that you select the **Call Post Query** checkbox while [defining the data source details.](/creating-datasources/working-with-datasources/creating-a-data-source/defining-data-source-details.md)
{% endhint %}

* To define a post query, open the **\</>Post Query** tab. The query editor is displayed. You can define your post query here as per the requirement.

![](/files/-M3LDO345DsqmVSCwIQl)

{% hint style="info" %}
You can call the predefined post query methods directly from the editor. On entering *db.* in the text editor, the list of methods is displayed. You can click on the required method from this list.
{% endhint %}

![](/files/-M3j0vZqPHENW5q_IUNy)

## Examples

1. If you add the following post query to your datasource, on refreshing the data, the user will not able to view the time component in the start date. However, in the database, the start date will store the time component.

```
Date startDate =   data.get("startDate");
data.set("startDate",dateUtils.clearTime(startDate));
```

Another example

```
Object fileName = db.evaluateSeIectSQL("select File_name from RA_FILES WHERE FILE_ID = "+data.get("attachmentId") + "AND FILE_REVISION = 1");

Object fileSize = db.evaluateSelectSQL("seIect File_size from RA_FILES WHERE FILE_ID = "+ data.get("attachmentId") + " AND FILE_REVISION = 1");

if (fileName ! = null && fileName.trim().lastIndexOf(".") ! = -1) {
data.set("filetype", fileName.substring(fileName.trim().lastlndexOf(".")));
}

if (data.get("parentdocument") != null ) {
Object parentDocName = db.evaluatese1ectSQL("se1ect DOC_NAME from DMS_DOCUMENT_DATA WHERE DOC_ID =" + data.get("parentDocument"));
data.set("parentDocumentName", parentDocName);
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.cloudio.io/creating-datasources/working-with-datasources/creating-a-data-source/defining-a-post-query.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
