Plain query does not transform in PostgreSQL function

Posts   
 
    
dodyg
User
Posts: 42
Joined: 04-Dec-2014
# Posted on: 28-Jan-2019 05:25:49   

I am using LLBLGen 5.5 and the latest driver for NPGSql.


await adapter.ExecuteSQLAsync(@"
DO $$
BEGIN
    SELECT * FROM institute_view WHERE institute_id=@instituteid AND day=@day AND month=@month AND year=@year;
END
$$
", new{
        instituteid = notification.Id,
        day = notification.DateUTC.Day,
        month = notification.DateUTC.Month,
        year = notification.DateUTC.Year
        })

returns PostgresException: 42703: column "instituteid" does not exist.

If I remove the function declaration, it will work


await adapter.ExecuteSQLAsync(@"
    SELECT * FROM institute_view WHERE institute_id=@instituteid AND day=@day AND month=@month AND year=@year;
", new{
        instituteid = notification.Id,
        day = notification.DateUTC.Day,
        month = notification.DateUTC.Month,
        year = notification.DateUTC.Year
        })

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 28-Jan-2019 06:56:29   

It's seems like if the parameter name is not recognized as it's out of scope of the function. Any reason you would like to use an anonymous code block here (function)?

David Elizondo | LLBLGen Support Team