[midPoint] - Execute stored procedure in SQLScript resource

Rodrigo Yanis ryanis at identicum.com
Tue Aug 30 21:48:01 CEST 2016


Hello everyone,

I'm currently trying to perform a call on a stored procedure in my Oracle
DB through a SQLScript resource. The use case is as follows:
1. The resource is assigned to the user X
2. Resource performs a call to a stored procedure on the database, sending
one of the user attributes as a parameter for the stored procedure to do
its magic
3. Stored procedure outputs a value, and its written into a different
attribute on my midPoint user.

I've tried to do this by modifying the CreateScript in the midPoint
examples, here:
https://github.com/Evolveum/midpoint/blob/master/samples/resources/scriptedsql/CreateScript.groovy

The script I've come up with is the following:

> log.info("Entering "+action+" Script");
> def sql = new Sql(connection);
> try {
>         sql.call("{? = call STORED_PROCEDURE(?, ?)}",[Sql.VARCHAR,
> attributes?.get("pidm")?.get(0), Sql.VARCHAR])
>         {
>                 alias -> return alias
>         };
> }
> catch(all) {
>         log.error("Exception in Stored Procedure execution");
> }
> return "errorInCall";

Stored procedure logic is out of the scope of this case.

I've configured the resource so it maps the "pidm" attribute i'm requesting
in my script to the user attribute in midPoint. I've also mapped "alias" as
an inbound attribute to my attribute in midPoint.

Does this scenario make any sense to you? Is this being approached
correctly? Is there a way to perform a "set attribute" on the script itself?

Right now I'm getting the following error in step 1. of the use case I
described:

> Error executing changes for (account (default) on
> resource:e1054471-b559-4f13-bc32-aec273c51e46(Banner Personas)): Couldn't
> add object. Schema violation: Schema violation during processing shadow:
> shadow: null (OID:null): Attempt to add shadow without any attributes:
> shadow:null(null)
> com.evolveum.midpoint.util.exception.SchemaException: Couldn't add object.
> Schema violation: Schema violation during processing shadow: shadow: null
> (OID:null): Attempt to add shadow without any attributes: shadow:null(null)


Thanks in advance,

*Rodrigo Yanis.*
Identicum S.A.
Jorge Newbery 3226
Tel: +54 (11) 4824-9971
ryanis at identicum.com
www.identicum.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.evolveum.com/pipermail/midpoint/attachments/20160830/adf6f4a3/attachment.htm>


More information about the midPoint mailing list