# PostgreSQL - Calling Clarion Function from a PSQL Function / Trigger

**URL:** <https://clarionhub.com/t/postgresql-calling-clarion-function-from-a-psql-function-trigger/5845>\
**Category:** questions\
**Tags:** postgresql, dll, sql\
**Created:** [January 18, 2023, 4:45pm UTC](https://clarionhub.com/t/postgresql-calling-clarion-function-from-a-psql-function-trigger/5845 "2023-01-18T16:45:09Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![anon23294430](https://clarionhub.com/user_avatar/clarionhub.com/anon23294430/32/3829_2.png) [@anon23294430](https://clarionhub.com/u/anon23294430)\
**Post date:** [January 19, 2023, 3:27am UTC](https://clarionhub.com/t/postgresql-calling-clarion-function-from-a-psql-function-trigger/5845/3 "2023-01-19T03:27:31Z")

</div>

> [@seanh](#):
>
> But it should be possible to create a C windows Dll that calls into a clarion one.

That will be quicker than translating the C into Clarion.

@KevinErskine if you do fancy having a go at translating it from C to Clarion

You’ll be using the C instead of typical Pascal for the calling convention,

so the  
pass by value, fixed-length = someproc (Datatypes)  
pass by reference, fixed-length = someproc (long) where long is the address to the datatype  
pass by reference, variable-length = someproc (long) where long is the address to the datatype  
or you could use \*[DataType] where asterisk is the address (long) to the [DataType].

The other thing to watch out for is when you need to use RAW. Raw removes the length of strings, groups and ? (any’s).

I couldnt find any source code that refers to these C functions, only snippets at that webpage, but you have the Topspeed C & C++ compiler built into Clarion, so maybe find some small postgres source code and see if you can get that compiling in clarion.

Some of the questions you might encounter can probably be found on here, like  
[How can a C typedef stucture containing an array be converted to a clarion structure? - questions - ClarionHub](https://clarionhub.com/t/how-can-a-c-typedef-stucture-containing-an-array-be-converted-to-a-clarion-structure/492)

Linking C C++

> **[Msbuild example for Clarion](https://clarionhub.com/t/msbuild-example-for-clarion/274/4)**
>
> Instead we have a hand coded project that includes a .prj with a bunch of #implib statements that creates all of the libs from all of the EXPs. That way we can do a single pass compile. – c/o @d.harms Neat idea Dave, thanks! Excerpt From...

> **[Why does an ANY data type in API call StringFromGuid2() not give me a fixed...](https://clarionhub.com/t/why-does-an-any-data-type-in-api-call-stringfromguid2-not-give-me-a-fixed-guid/5493/9)**
>
> You would certain know more than I would on what happens in the compiled code. I agree with what you said. An External Function works with or without the DLL(1). I’m asking is with DLL(1) better? My understanding is DLL(1) is like Microsoft...

You’ll just have to hunt around a bit, but I’d start with finding the postgres source code you want to compile or translate, or better still see if they have supplied any dll’s that you want to use, and then just make a lib file using the libmaker and then define some api’s in your code.

---

_[View the full topic](https://clarionhub.com/t/postgresql-calling-clarion-function-from-a-psql-function-trigger/5845)._
