> For the complete documentation index, see [llms.txt](https://docs.tibero.com/tibero-manuals_en/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.tibero.com/tibero-manuals_en/7.2.5.manuals_en/tibero-application-developers-guide/mod_tbpsm.md).

# mod\_tbPSM

## Overview

To request HTTP pages via a web browser, Tibero provides an Apache module named mod\_tbPSM that calls and transfers a procedure written with tbPSM.

When Apache HTTP server starts, it dynamically loads module libraries specified in the Apache configuration file. At this time, mod\_tbPSM is also loaded from the Apache HTTP server.

The following are the steps for using the mod\_tbPSM modules.

1. Install Apache HTTP Server
2. Register mod\_tbPSM
3. Write and execute a procedure For more information about each step, refer to each section.

Installing Apache HTTP Server

The version of Apache HTTP server optimized for mod\_tbPSM is 2.2.31 (for Unix) or 2.4.27 (for Windows). For detailed information about Apache HTTP server, refer to the following address.

```
UNIX: https://httpd.apache.org/download.cgi#apache22 
Windows 64bit: https://www.apachelounge.com/download
Windows 32bit: https://www.apachelounge.com/download
```

In UNIX systems, download and manually build the source code. In Windows systems, download the version of the binary that is appropriate for the version of VC installed in the system, and then install and execute it by referring to ReadMe.txt, which is included in the binary.

{% hint style="info" %}
**Note**

If Tibero Windows 64-bit is used, Apache HTTP must also be 64-bit.
{% endhint %}

Registering mod\_tbPSM

After Apache HTTP server is installed, modify Apache configuration file, which is $(Apache server installation path)/conf/httpd.conf, and then register mod\_tbPSM.

* In Unix

Add the following in httpd.conf:

```
LoadModule tbpsm_module     "${TB_HOME}/client/lib/libmod_tbpsm.so"
<Location /tbpsm>
    SetHandler tbpsm_handler
    AuthType Basic 
    AuthName "Tibero"
</Location>
```

* In Windows

Since Windows does not use the TB\_HOME environment variable, specify an absolute path or copy the dll file to the module folder in the Apache installation path, and then add the following in httpd.conf:

```
LoadModule tbpsm_module         modules/libmod_tbpsm.dll
<Location /tbpsm>
    SetHandler tbpsm_handler 
    AuthType Basic
    AuthName "Tibero"
</Location>
```

**\[Note]**

When specifying a path, use a back slash () for Windows and a slash (/) for Apache.

```
LoadModule tbpsm_module         c:/tibero/client/lib/libmod_tbpsm.dll
<Location /tbpsm>
    SetHandler tbpsm_handler
    AuthType Basic 
    AuthName "Tibero"
</Location>
```

{% hint style="info" %}
**Note**

The Location section in the Apache configuration file must be identical to the previous example.
{% endhint %}

Creating and Executing a Procedure

This section describes how to create and execute a procedure that returns HTML pages using the HTP package.

{% hint style="info" %}
**Note**

For more information about the usage of HTP package described in this section, refer to Tibero tbPSM Reference Guide.
{% endhint %}

### Creating a Procedure&#xD;

Based on syntax of tbPSM, create HTML source code by calling a member procedure of the HTP package.

**\[Example 1] Example of a tbPSM Procedure Using HTP Package**

```
CREATE OR REPLACE PROCEDURE hello (title in varchar2, text in varchar2) 
AS
BEGIN
    HTP.HTMLOPEN;
    
    HTP.HEADOPEN;
    HTP.TITLE(title);
    HTP.HEADCLOSE;
    
    HTP.BODYOPEN;
    HTP.PRINT(text);
    HTP.BODYCLOSE;
    
    HTP.HTMLCLOSE;
END;
/
```

Description of the previous example is as follows:

* In the HTML HEAD area, a string value of the title parameter is displayed in the web browser's title bar. For example, if 'abc' is passed to the hello procedure as the first argument, 'abc' is displayed in a title bar.
* In the HTML BODY section, a string value of the text parameter is displayed in the web browser's main body of the screen. For example, if 'def' is passed to the hello procedure as the second argument, 'def' is displayed in the main body of the screen.

### Executing a Procedure&#xD;

The URL address format for executing a procedure using the mod\_tbPSM module is as follows:

```
http://{http_server_ip}:{http_server_port}/tbpsm/{tibero_dsn}/
{package_name}.{procedure_name}?{parameter1}={value1}&{parameter2}={value2)&...
```

<table><thead><tr><th width="255">항목</th><th>설명</th></tr></thead><tbody><tr><td>http_server_ip</td><td>HTTP 서버의 IP 주소</td></tr><tr><td>http_server_port</td><td><ul><li>HTTP 서버의 포트 번호</li><li>설정되지 않으면, 기본값 80이 적용</li></ul></td></tr><tr><td>tbpsm</td><td>httpd.conf 파일에 지정한 경로처럼 mod_tbPSM와 연동되기 위해서 반드시 넣어줘야하는 상대 경로</td></tr><tr><td>tibero_dsn</td><td><ul><li>tbdsn.tbr 파일에 명시된 DSN 이름</li><li>프러시저가 저장되어있는 Tibero DBMS 서버를 가리킴</li></ul></td></tr><tr><td>package_name</td><td>호출할 프러시저가 패키지의 멤버일 경우 패키지 이름 및 점(.)을 명시해야 함</td></tr><tr><td>procedure_name</td><td>호출할 프러시저의 이름</td></tr><tr><td><p>parameter1, parameter2, ... ,</p><p>parametern</p></td><td><ul><li>프러시저의 파라미터 이름</li><li>URL 주소 형식에서는 질의에 해당</li></ul></td></tr><tr><td>value1. value2, ... , valuen</td><td>프러시저 해당 파라미터에 들어가는 IN값</td></tr></tbody></table>

For example, to access an HTTP server whose address is "12.34.56.78" and call the hello procedure, in the previous example, located in Tibero DBMS server with a DSN named "test", the URL address is written as follows:

```
http://12.34.56.78/tbpsm/test/hello?title=abc&text=def
```

If this address is entered and requested in a web browser, a login screen will appear. The ID and password for the login screen are the same as for a Tibero DBMS account used to execute the hello procedure.

## Configuring Auto Login

This section describes how to configure auto login for a URL address.

To request a web page from an HTTP server associated with mod\_tbPSM, the server must be logged in with an account and its password. If auto login is configured, the server can be logged in automatically with the specified account and password. When using auto login, note that all users can access the specified URL address.

mod\_tbPSM supports auto login by using the mod.tbr file in TB\_HOME/client/config. The following is a sample file.

**\[Example 2] Sample mod.tbr**

```
(LOCATION="/test")=(
    (USERNAME="tibero")
    (PASSWORD="tmax")
)

(LOCATION="/test2")=(
    (USERNAME="tibero") 
    (PASSWORD="tmax")
)

(LOCATION="/test3")=( (USERNAME="sys")
    (PASSWORD="tibero")
)
```

The following briefly describes each item in mod.tbr.

<table><thead><tr><th width="238">Item</th><th>Description</th></tr></thead><tbody><tr><td>LOCATION</td><td>Relative URL address.</td></tr><tr><td>USERNAME</td><td>Database user account for login.</td></tr><tr><td>PASSWORD</td><td>Password of the database user account.</td></tr></tbody></table>

For example, when accessing '<http://12.34.56.78/tbpsm/test/hello?title=abc\\&text=def>', a relative URL address is found based on '<http://12.34.56.78/tbpsm>. If there is a LOCATION value in mod.tbr that matches the relative address, auto login is performed with the specified USERNAME and PASSWORD values.

To use multiple connection information as in the previous example, DSN connection information must be modified in the tbdsn.tbr file.

**\[Example 3] Modifying tbdsn.tbr**

```
test=(
    (INSTANCE=(HOST=localhost)
              (PORT=8629)
              (DB_NAME=tibero)
          )
)

test2=(
          (INSTANCE=(HOST=localhost)
                    (PORT=8629)
                    (DB_NAME=tibero)
          )
)

test3=(
          (INSTANCE=(HOST=localhost)
                    (PORT=8629)
                    (DB_NAME=tibero)
          )
)
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.tibero.com/tibero-manuals_en/7.2.5.manuals_en/tibero-application-developers-guide/mod_tbpsm.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
