Passing DB Schema to Custom Function

Options
Is there an easy way to set the input to a custom function to match a table's schema?  I see the database link which gives me alllllllllll the fields as inputs, but if I stick it in an object I don't get any of them.  

The context of my question:

I've got a custom function that calculates a number of fields when a row is added or updated.  Currently I'm just passing the row ID and having the function lookup and then update the records.  As I start to use this function I realize this may not be the most efficient since I then need to :
1. create new record
2. pass ID to function
   2a. lookup record
   2b. update record
   2c. return object
3. return object

So I guess the second part of the question is, are there notable performance benefits to passing and returning an object from the custom function (notable enough to outweigh the annoyance of linking all the fields every time I use the function, which stands in the 25ish range)

Comments

  • Sean Montgomery
    Sean Montgomery Administrator

    ADMIN

    Options
    Objects require you to build out all the schema which can be annoying if there is a lot. You probably want to use the json type.
  • Brian Giometti
    Options
    Hmm that's an option I hadn't considered.  I assume the only downside to JSON is making sure I'm addressing everything correctly, which is easy enough when I know what object is going to end up getting passed in.
  • Valentin R
    Options

    I have the same question. But I found a way to auto-map values to the object's schema (add object input, add additional schema that is a database link, map var1 to the sub-schema of custom function + push a value to “@meta” key which is required for some reason). But the downside, just like with JSON is that one needs to address everything by hand withing the custom function.