Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

243
Visualizações
Using Custom defined variables in PgAdmin III?

First of all, thank you beforehand for helping me with this. Please do not state that this is a repeat question as I have searched a lot but still none of the threads I found here relate to my query. Actually I have a simple query which I'm failing to pass through and needed some help. My issue is as follows,

I want to run a simple SQL query to insert some data into a table i.e.,

INSERT INTO "public"."plan" (id,name,description) VALUES (6,"Plan Name","Plan Description");

But instead of passing Plan Name and Plan Description as text, I'm looking to define variables and pass those instead, in short something like this,

INSERT INTO "public"."plan" (id,name,description) VALUES (6,customPlanName,customPlanDescription);

I've tried using the following but this doesn't work,

DECLARE 
   planname TEXT;
   plandesc TEXT;
SET planname = 'MidasName';
SET plandesc = 'PlanDescription';
INSERT INTO "public"."plan" (id,name,description) VALUES (6,planname,plandesc);

Can you please help me out with this? I want something to be run using PostgreSQL on PgAdmin III

Thank you in advance for any help provided.

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

example with prepared statements:

prepare plan_insert (text,text) 
  as INSERT INTO "public"."plan" (id,name,description) VALUES (6,$1,$2);
execute plan_insert ('MidasName','PlanDescription');
execute plan_insert ('Some Other','Some more');
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda