Skip to main content
AI Assist is now on Stack Overflow. Start a chat to get instant answers from across the network. Sign up to save and share your chats.
added 2 characters in body
Source Link
Brian Burns
  • 22.4k
  • 10
  • 93
  • 80

I only know two ways.

First is to use PREPARED STATEMENT (Example after PostgreSQL Manual):

PREPARE usrrptplan (int) AS SELECT * FROM users u, logs l WHERE u.usrid=$1 AND u.usrid=l.usrid AND l.date = $2;   EXECUTE usrrptplan(1, current_date); 

PREPARE creates a prepared statement. When the PREPARE statement is executed, the specified statement is parsed, analyzed, and rewritten. When an EXECUTE command is subsequently issued, the prepared statement is planned and executed.

Prepared statements can take parameters: values that are substituted into the statement when it is executed. When creating the prepared statement, refer to parameters by position, using $1, $2, etc.

Prepared statements only last for the duration of the current database session. When the session ends, the prepared statement is forgotten, so it must be recreated before being used again.

Second is to "find-and-replace" $1, $2, .. etc. by proper values. But you want to avoid this one.

I only know two ways.

First is to use PREPARED STATEMENT (Example after PostgreSQL Manual):

PREPARE usrrptplan (int) AS SELECT * FROM users u, logs l WHERE u.usrid=$1 AND u.usrid=l.usrid AND l.date = $2; EXECUTE usrrptplan(1, current_date); 

PREPARE creates a prepared statement. When the PREPARE statement is executed, the specified statement is parsed, analyzed, and rewritten. When an EXECUTE command is subsequently issued, the prepared statement is planned and executed.

Prepared statements can take parameters: values that are substituted into the statement when it is executed. When creating the prepared statement, refer to parameters by position, using $1, $2, etc.

Prepared statements only last for the duration of the current database session. When the session ends, the prepared statement is forgotten, so it must be recreated before being used again.

Second is to "find-and-replace" $1, $2, .. etc. by proper values. But you want to avoid this one.

I only know two ways.

First is to use PREPARED STATEMENT (Example after PostgreSQL Manual):

PREPARE usrrptplan (int) AS SELECT * FROM users u, logs l WHERE u.usrid=$1 AND u.usrid=l.usrid AND l.date = $2;   EXECUTE usrrptplan(1, current_date); 

PREPARE creates a prepared statement. When the PREPARE statement is executed, the specified statement is parsed, analyzed, and rewritten. When an EXECUTE command is subsequently issued, the prepared statement is planned and executed.

Prepared statements can take parameters: values that are substituted into the statement when it is executed. When creating the prepared statement, refer to parameters by position, using $1, $2, etc.

Prepared statements only last for the duration of the current database session. When the session ends, the prepared statement is forgotten, so it must be recreated before being used again.

Second is to "find-and-replace" $1, $2, .. etc. by proper values. But you want to avoid this one.

update url, add quotes
Source Link
Brian Burns
  • 22.4k
  • 10
  • 93
  • 80

I only know two ways.

First is to use PREPARED STATEMENTPREPARED STATEMENT (Example after PostgreSQL Manual):

PREPARE usrrptplan (int) AS SELECT * FROM users u, logs l WHERE u.usrid=$1 AND u.usrid=l.usrid AND l.date = $2; EXECUTE usrrptplan(1, current_date); 

PREPARE creates a prepared statement. When the PREPARE statement is executed, the specified statement is parsed, analyzed, and rewritten. When an EXECUTE command is subsequently issued, the prepared statement is planned and executed.

Prepared statements can take parameters: values that are substituted into the statement when it is executed. When creating the prepared statement, refer to parameters by position, using $1, $2, etc.

Prepared statements only last for the duration of the current database session. When the session ends, the prepared statement is forgotten, so it must be recreated before being used again.

SeccondSecond is to "find-and-replace" $1, $2, .. etc. by proper values. But you want to avoid this one.

I only know two ways.

First is to use PREPARED STATEMENT (Example after PostgreSQL Manual):

PREPARE usrrptplan (int) AS SELECT * FROM users u, logs l WHERE u.usrid=$1 AND u.usrid=l.usrid AND l.date = $2; EXECUTE usrrptplan(1, current_date); 

Seccond is to "find-and-replace" $1, $2, .. etc. by proper values. But you want to avoid this one.

I only know two ways.

First is to use PREPARED STATEMENT (Example after PostgreSQL Manual):

PREPARE usrrptplan (int) AS SELECT * FROM users u, logs l WHERE u.usrid=$1 AND u.usrid=l.usrid AND l.date = $2; EXECUTE usrrptplan(1, current_date); 

PREPARE creates a prepared statement. When the PREPARE statement is executed, the specified statement is parsed, analyzed, and rewritten. When an EXECUTE command is subsequently issued, the prepared statement is planned and executed.

Prepared statements can take parameters: values that are substituted into the statement when it is executed. When creating the prepared statement, refer to parameters by position, using $1, $2, etc.

Prepared statements only last for the duration of the current database session. When the session ends, the prepared statement is forgotten, so it must be recreated before being used again.

Second is to "find-and-replace" $1, $2, .. etc. by proper values. But you want to avoid this one.

Source Link

I only know two ways.

First is to use PREPARED STATEMENT (Example after PostgreSQL Manual):

PREPARE usrrptplan (int) AS SELECT * FROM users u, logs l WHERE u.usrid=$1 AND u.usrid=l.usrid AND l.date = $2; EXECUTE usrrptplan(1, current_date); 

Seccond is to "find-and-replace" $1, $2, .. etc. by proper values. But you want to avoid this one.