usausa / Smart-Net-Data-Accessor

2-way/outside SQL build-time data accessor generator library.
MIT License
24 stars 3 forks source link

How to excute with for and declare an variable? #4

Open huuluan97 opened 4 years ago

huuluan97 commented 4 years ago

Dear usausa, I'm have an excute sql same here below. But when i run excute, the Smart-Net-Data-Accessor always display _42703: column \"p0\" does not exist . Please help me how to excute sql.

DO $$
DECLARE v_list text;
BEGIN
    v_list := TRIM (/*@list*/'')::text;

    FOR item IN SELECT unnest(STRING_TO_ARRAY(v_list , ','))ele
        LOOP
            INSERT INTO user(user_id, group_id, created_by) 
                         VALUES(
                /*@userId*/'',item ,/*@createdBy*/'');
                END LOOP; 
END;
$$;

Thank you so much.

usausa commented 4 years ago

1st, check the auto-generated source file. It is generated under the obj folder like obj\Debug\netcoreapp3.1\SmartDataAccessor.

huuluan97 commented 4 years ago

image

image

Hi usausa, i'm checked in images

usausa commented 4 years ago
  1. Can that SQL and parameters be run using a raw ADO.NET or Dapper?
  2. Show me the whole auto-generated source.

Smart is a library that automatically generates source code using ADO.NET, so if you compare it with the raw code, you can check the problem.