Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

241
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!