Usina BRAdvPL Guide
Sign in
← All topics
FUNCTIONUnder review

DbCreate

DBCreate( <cName>, <aStruct>, [cDriver] )

Defines a new table and its field structure.

DbCreateAdvPL
01 · OVERVIEW

Overview

DBCreate accepts a name, schema and optional RDD. Each field specifies name, type, length and decimals; creating does not open an alias. Driver choice affects limits and persistence, and documentation restricts creation to the server. The example prepares an uninvoked action for a new file in an existing test directory. Do not use DBCreate to modify the dictionary or replace Protheus tables. EDTRB identifies only an owned test table already open with the required schema and permissions; examples are not intended for standard tables. (TOTVS, n.d., ref. 1)

02 · SYNTAX

Syntax

DBCreate( <cName>, <aStruct>, [cDriver] )

Parameters

cName
CharacterRequired

New server-side name.

aStruct
ArrayRequired

Fields: name, type, length, decimals.

cDriver
CharacterOptional

RDD; omission uses configured local driver.

Return value

Not formalized by the page; failures raise errors rather than an assumed logical return.

03 · PRACTICAL EXAMPLE

Commented example

#Include "Protheus.ch"

User Function Ed328()
    Local aFields := {{"ED_COD", "C", 10, 0}}
    Local bCreate
    // Test directory must exist on the server without this file.
    bCreate := {|| DBCreate("ednova.dbf", aFields, "DBFCDX")}
Return Nil
Expected result

Action prepared without file creation. ED_COD identifies the fixed teaching schema. Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

BEST PRACTICES
  • Check RDD, alias and pending operations. Navigation can flush updates; preserve context under the caller contract and handle errors in the complete routine.
  • Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

Related content

REFERENCES
  1. TOTVS. DbCreate. TDN. Accessed on 2026-10-26.
Status
Under review
Page created on
Last reviewed on
Original language
Portuguese
Reviewed by
Usina.BR
0 approved comment(s)

Comments

There are no approved comments yet.

Sign in with Google or Microsoft to comment.

Powered by Usina Docs · Alpha