Sponsored Content
Full Discussion: problem with an IF statement
Top Forums Shell Programming and Scripting problem with an IF statement Post 35557 by oombera on Thursday 17th of April 2003 09:25:53 AM
Old 04-17-2003
Which shell are you using?

Try using one set of brackets instead of two. All the ways you listed work fine in ksh...

CX="CR"

if [[ $CX != "CP" ]]; then
echo "not equal"
fi

if [ $CX != "CP" ]; then
echo "not equal"
fi
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

if statement problem

I keep getting an error at line 21, it doesn't like my if statement. Previously I have tried using (( )), but still get errors. The current error is that server_busy is not found. This is the script: #! /bin/ksh server_busy="na" for file in $1 $2 $3 $4 $5 $6 do echo " ${file}\t\c" ... (1 Reply)
Discussion started by: coughlin74
1 Replies

2. UNIX for Dummies Questions & Answers

if statement problem

hi all. i just have a very small problem. i have a menu of 7 choices. i want an if statement so that if the user chooses anything except inside the 1 to 7 range, i can handle the error for it. i tried this: if ] then ....... fi (but it dont work) ...any suggestions? ... (4 Replies)
Discussion started by: djt0506
4 Replies

3. Shell Programming and Scripting

If Statement Problem..

The problem I am having here is that only the 1st option is executed, no matter if I pick yes or no. What am I doing wrong? How can I get this working right without resorting to a case statement? echo "This is the max size your lvol can be:" echo $MAXSIZE echo echo Do you want to max out... (2 Replies)
Discussion started by: LinuxRacr
2 Replies

4. UNIX for Dummies Questions & Answers

if statement problem

See https://www.unix.com/shell-programming-scripting/96846-if-statement-problem.html (0 Replies)
Discussion started by: f_o_555
0 Replies

5. Shell Programming and Scripting

if statement problem

Hi I have a bash script like this if then echo "A" else echo "B" fi $1 is something like 02350 (there is always a trailing '0') and I would like to have an if based on the value of the digits after the 0. Can anybody help? Thanks, Sarah (3 Replies)
Discussion started by: f_o_555
3 Replies

6. UNIX for Dummies Questions & Answers

Having problem with if statement

Could someone help me out with this if statement? It's supposed to get a person's website, but it isn't working when I run it. website="" echo "Would you like to enter a website? Enter Yes/No" read choice if then while do echo "Please enter a website:"; read... (4 Replies)
Discussion started by: Sotau
4 Replies

7. Shell Programming and Scripting

if statement problem

Writing my script and I'm banging my head on the desk right now ... My biggest problem is the 3rd IF statement where I check if the username exists. Doing the grep command on it's own in the shell gives me a 1 or 0 value. Running the script, it always returns a false value (runs the ELSE... (4 Replies)
Discussion started by: ADay2Long
4 Replies

8. Shell Programming and Scripting

while statement problem

Hi, Here is a big head scratcher for me.... I'm creating a loop with while reading lines from a file called example.txt: #!/bin/sh while read line do some command > another file ----- output to another file done < example.txt I would like that another file to be unique for every... (5 Replies)
Discussion started by: svetoslav_sj
5 Replies

9. Shell Programming and Scripting

Problem if statement

echo "Enter the variable: " " read var1 echo " " for i in ib eb atm do if ; then mv properties environment.properties break else echo "No changes to $var1 " fi done When i run and enter the eb it's not working.Any suggestions please.. (7 Replies)
Discussion started by: bhas85
7 Replies

10. UNIX for Beginners Questions & Answers

Problem with If statement

Hi All, I am writing an if statement to check multiple conditions, but when I try to execute the script it is breaking at the point of if statement by showing the issue below. Code I am using is given below. if -a ] then .... else ... fi I am not understanding... (3 Replies)
Discussion started by: ginrkf
3 Replies
SPI_PREPARE(3)						  PostgreSQL 9.2.7 Documentation					    SPI_PREPARE(3)

NAME
SPI_prepare - prepare a statement, without executing it yet SYNOPSIS
SPIPlanPtr SPI_prepare(const char * command, int nargs, Oid * argtypes) DESCRIPTION
SPI_prepare creates and returns a prepared statement for the specified command, but doesn't execute the command. The prepared statement can later be executed repeatedly using SPI_execute_plan. When the same or a similar command is to be executed repeatedly, it is generally advantageous to perform parse analysis only once, and might furthermore be advantageous to re-use an execution plan for the command. SPI_prepare converts a command string into a prepared statement that encapsulates the results of parse analysis. The prepared statement also provides a place for caching an execution plan if it is found that generating a custom plan for each execution is not helpful. A prepared command can be generalized by writing parameters ($1, $2, etc.) in place of what would be constants in a normal command. The actual values of the parameters are then specified when SPI_execute_plan is called. This allows the prepared command to be used over a wider range of situations than would be possible without parameters. The statement returned by SPI_prepare can be used only in the current invocation of the procedure, since SPI_finish frees memory allocated for such a statement. But the statement can be saved for longer using the functions SPI_keepplan or SPI_saveplan. ARGUMENTS
const char * command command string int nargs number of input parameters ($1, $2, etc.) Oid * argtypes pointer to an array containing the OIDs of the data types of the parameters RETURN VALUE
SPI_prepare returns a non-null pointer to an SPIPlan, which is an opaque struct representing a prepared statement. On error, NULL will be returned, and SPI_result will be set to one of the same error codes used by SPI_execute, except that it is set to SPI_ERROR_ARGUMENT if command is NULL, or if nargs is less than 0, or if nargs is greater than 0 and argtypes is NULL. NOTES
If no parameters are defined, a generic plan will be created at the first use of SPI_execute_plan, and used for all subsequent executions as well. If there are parameters, the first few uses of SPI_execute_plan will generate custom plans that are specific to the supplied parameter values. After enough uses of the same prepared statement, SPI_execute_plan will build a generic plan, and if that is not too much more expensive than the custom plans, it will start using the generic plan instead of re-planning each time. If this default behavior is unsuitable, you can alter it by passing the CURSOR_OPT_GENERIC_PLAN or CURSOR_OPT_CUSTOM_PLAN flag to SPI_prepare_cursor, to force use of generic or custom plans respectively. This function should only be called from a connected procedure. SPIPlanPtr is declared as a pointer to an opaque struct type in spi.h. It is unwise to try to access its contents directly, as that makes your code much more likely to break in future revisions of PostgreSQL. The name SPIPlanPtr is somewhat historical, since the data structure no longer necessarily contains an execution plan. PostgreSQL 9.2.7 2014-02-17 SPI_PREPARE(3)
All times are GMT -4. The time now is 12:06 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy