Caffeinated
Caffeinated

Reputation: 12484

In Oracle SQL, what would code like this be used for?

Just studying some code , and came across this line:

v_VLDT_TOKEN_VLU := v_onl_acctID || ‘|’ || p_onl_external_id || ‘|’ ||  p_validation_target

It's a "validation token value" , but why would you concatenate the pipe symbol? I understand this is for dynamic SQL.

Upvotes: 0

Views: 61

Answers (4)

turboc
turboc

Reputation: 153

I have actually seen similar code, but it was used to generate a unix statement that piped (|) the output of one command to another. If I remember correctly, they had a table with all of our database hosts, and oracle data directories. They used code similar to this to shell over to the specific database host, get a directory of the datafiles and write the output to a logfile back on the parent server which they then read in to update disk usage for reporting. This was years ago so I'm sure there is a better way to do it now.

Upvotes: 1

ngrashia
ngrashia

Reputation: 9894

Here Pipe symbol is used as a delimiter/separator between the fields:

Assume,

v_onl_acctID = 123
p_onl_external_id  = abc
p_validation_target = xyz

then

v_VLDT_TOKEN_VLU := v_onl_acctID || ‘|’ || p_onl_external_id || ‘|’ ||  p_validation_target

will evaluate to

v_VLDT_TOKEN_VLU = 123|abc|xyz

It is just another character for delimiter purpose and can be replaced with any other delimiter too. For reference, if the | is replaced by *, say

v_VLDT_TOKEN_VLU := v_onl_acctID || ‘*’ || p_onl_external_id || ‘*’ ||  p_validation_target

then the expression's value would be 123*abc*xyz

Note: || is used for concatenation

Upvotes: 1

Twelfth
Twelfth

Reputation: 7180

Comment = answer apparently.

v_vldt_token_vlu looks like it's built up of three fields, with a pipe between each of them...I assume the pipe is built into the token_vlu field and then being compared to the same fields concatonated together here. Pipe was probably a developers preference. No real reference to dynamic SQL here

Upvotes: 0

ivan.sim
ivan.sim

Reputation: 9268

Looks like the pipe symbol is being used as a delimiter between the three fields.

Upvotes: 1

Related Questions