3

The given Oracle query inserts data into table by substituting variables. How I achieve the same in PostgreSQL?

INSERT INTO control_threshold (
    threshold_id, group_name, description, sql, low_value, high_value)
VALUES(
    threshold_seq.nextval, '&2', '&1',  TRIM('&5' || '&6' || '&7' || '&8' || '&9'),
    trim('&3'), trim('&4'));
  • In reference to your deleted question: That deleted my answer as well, and I don't think your question was completely unfounded. There has been confusion before. I suggest you undelete it and edit in that your version of Postgres did not seem to support the type hstore. – Erwin Brandstetter Jul 14 '14 at 19:05
7

These variables are a feature of SQL*Plus.

psql, the equivalent program in the PostgreSQL world, also has variables.

Use

\set variable 'value'

and

insert into mytable(mycolumn)
values (:variable);
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.