简体   繁体   中英

syntax error at or near “RETURNING” PSQL Select with returning statement

I have the following query:

WITH data AS (
    SELECT
        profileid as id_user,
        terms_accepted as terms_accepted_passport,
        lastname as last_name_user,
        firstname as first_name_user,
        picture_serving_url as picture_user,
        is_active as status_user,
        is_passport_active as status_passport,
        language as language_id_user,
        created as created_user,
        modified as modified_user,
        passport_completion_level as completion_level_passport,
        email as email_user,
        about_me as description_user,
        uni_code as institution_id_user,
        metadata as metadata_misc
    FROM import_temp_table
    RETURNING
        id_user
)
select * FROM data

The output is:

ERROR:  syntax error at or near "RETURNING"
LINE 19:     RETURNING

Am I doing something wrong?

this?..

WITH data AS (
    SELECT
        profileid as id_user,
        terms_accepted as terms_accepted_passport,
        lastname as last_name_user,
        firstname as first_name_user,
        picture_serving_url as picture_user,
        is_active as status_user,
        is_passport_active as status_passport,
        language as language_id_user,
        created as created_user,
        modified as modified_user,
        passport_completion_level as completion_level_passport,
        email as email_user,
        about_me as description_user,
        uni_code as institution_id_user,
        metadata as metadata_misc
    FROM import_temp_table
)
select id_user FROM data

and in case I guessed, this should do:

select profileid as id_user from import_temp_table

SELECT profileid as id_user FROM import_temp_table RETURNING id_user into id_user_

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM