v3 - can I execute a native sql?

Posts   
 
    
miloszes
User
Posts: 222
Joined: 03-Apr-2007
# Posted on: 07-Jul-2010 15:07:09   

Hi,

how can I execute a following query via LLBLGen:

SELECT nextval('importid_seq');

I need to retreive a next sequence value.

Kind Regards, MiloszeS

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 07-Jul-2010 15:22:46   

Why do you need to fetch the sequence nextVal?

LLBLGen automatically fetches the nextVal of the sequence when inserting an entity using that sequence.

miloszes
User
Posts: 222
Joined: 03-Apr-2007
# Posted on: 07-Jul-2010 15:31:05   

Walaa wrote:

Why do you need to fetch the sequence nextVal?

LLBLGen automatically fetches the nextVal of the sequence when inserting an entity using that sequence.

Yes I know that LLBLGen will automatically fetch that.

The sequence is used to produce a specific identifier. It's made by the application, based on the business logic rule. In other words a sequence is only a part of an identifier.

MiloszeS

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 07-Jul-2010 15:36:10   

You can use a DynamicList which has one field defined. While using a DBFunctionCall for the nextVal(), which should be set as the Expression used by this field.

miloszes
User
Posts: 222
Joined: 03-Apr-2007
# Posted on: 07-Jul-2010 16:01:34   

Walaa wrote:

You can use a DynamicList which has one field defined. While using a DBFunctionCall for the nextVal(), which should be set as the Expression used by this field.

The nextVal() is a native postgres procedure. How can I invoke that? Like a standard procedure? The funny thing is that I remember, that in the past the 3rd form in the refresh db schema allows me to choose stored procedures to retreive. Now I Can't see that screen - after a tables choose it goes directly to the last screen skipping a stored procedures selection screen.

MiloszeS

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 07-Jul-2010 16:18:32   

Please check DBFunctionCalls in the manual. Link

miloszes
User
Posts: 222
Joined: 03-Apr-2007
# Posted on: 08-Jul-2010 10:59:15   

Maybe this will be usefull for someone:

ResultsetFields fields = new ResultsetFields(1);

                fields.DefineField(GdmFields.Importid, 0);


                fields[0].ExpressionToApply = new DbFunctionCall(@"nextval", new object[] { "importid_seq" });



                DataTable dynamicList = new DataTable();

                adapter.FetchTypedList(fields, dynamicList, null, 1, true);

                var ret = dynamicList.Rows[0][0];