Sponsored Content
Top Forums Shell Programming and Scripting Getting unknown operator error while using a function Post 302995789 by Samah on Wednesday 12th of April 2017 09:45:57 AM
Old 04-12-2017
Getting unknown operator error while using a function

Hi,

I wrote a function for the first time and not able to get the desired result.

I have requirement to execute 10 queries. For this i wrote a function like below.
Code:
function Command {
  typeset var SOL;
  if [ ${1:-0} -ne 0 ]; then CONNECTION="${CONNECTION} -e -time";
  else SOL="`nzsql ${CONNECTION} -c "${1}"`";
  fi;
  echo "${SOL}";
}

CHECK1="$(Command "SELECT COUNT(*) FROM ${DATABASE}..EMPLOYEE WHERE NVL(EMPLOYEE_ID, 0) <= 0;")"
if [ ${?} -ne 0 ] ; then
echo "CHECK1 : ${CHECK1}";
fi;

Above code is throwing an error.
Code:
.[16]: Command[10]: [: COUNT(*): unknown operator

I need to put the check 1 result in a file and need to attach the file to email and send once all the 10 checks performed.

Could any one please tell me what went wrong in this function!?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

:0: unknown test operator

I have gotten the script up to this point and it works fine a system but when i copy it to another unix server running solaris 9 as the original one , its gives an error './mon_fs.sh: 0: unknown test operator' . (see script bellow) can the Gurus see to this as i am just a beginner with... (2 Replies)
Discussion started by: ibroxy
2 Replies

2. UNIX for Advanced & Expert Users

unknown test operator

Hi, I have the following shell script : Nbr_BD_Link=0 Nbr_BD_Link=` sqlplus sysadm/${PSWD}@${DB_Name} << EOF | tail -4 | head -1 2>/dev/null set head off feedback off ; select count(*) from dba_db_links ; exit ; EOF ` echo ${Nbr_BD_Link} if ; then ... (4 Replies)
Discussion started by: big123456
4 Replies

3. Shell Programming and Scripting

test: unknown operator status

hi I get test: unknown operator status if then echo "OK." return 0 else echo "not ok" 2>&1 exit -1 fi I tried to change "A" with 'A' --> same error I tried to change if , I am getting: (3 Replies)
Discussion started by: melanie_pfefer
3 Replies

4. Shell Programming and Scripting

syntax error in shell test: unknown operator

Hi All, can some one figure out the syntax issue here. How to overcome this? #!/bin/sh $ HFR_MAIL=NO $ PRP_MAIL=NO $ MC_MAIL=NO $ if && && ]; then > echo "NO " > else > echo "YES" > fi test: unknown operator NO $ if && && ]; then > echo "NO" > else > echo "YES" >... (4 Replies)
Discussion started by: shellscripter
4 Replies

5. Shell Programming and Scripting

if returns "unknown test operator"

Greetings, using ksh on Solaris, I am trying to identify the current version of a package installed on multiple servers using if statement in a precursor to upgrading. I have searched the forums and have found many hits, reviewed 3 pages and have tried the different variations noted there. Also... (3 Replies)
Discussion started by: 22blaze
3 Replies

6. Shell Programming and Scripting

unknown test operator

hi all, i am using the below command in my script if ; then This statement is causing the problme "ScriptName.ksh: XXX-XXX: unknown test operator" could you please suggest me , how can i avoid these messages. Singhal (7 Replies)
Discussion started by: singhald
7 Replies

7. Shell Programming and Scripting

Unknown error - ``' unmatched

Hi Guys, I get the error while running below commands. Earlier the command used to execute, but after enclosing them in a function, the error is occuring backupPath=`echo $folderName | sed -e 's,/vobs/dte/itgClient/client/RegressionTestLibPostOHS/,,'` check_event=`cat... (7 Replies)
Discussion started by: ajincoep
7 Replies

8. Programming

Help Unknown Syntax Error

Please excuse me if this is an easy fix, for I am new to Unix and C '/problem1.c: line2: syntax error near unexpected token ` '/problem1.c: line2: `main() and for one program it has : command not found2: (above the syntax error) As mentioned this is in C not C++, I have complied all... (3 Replies)
Discussion started by: apolo93
3 Replies

9. Shell Programming and Scripting

Unknown test operator

Hi , Os - Solaris Shell - Ksh I am getting below error in if condition + id + ./om_wf_complete.sh: gid=4081(Infadmn): unknown test operator + exit 1 if ; then touch /home/odwt/1.0.0/out/oworkflow.dat chmod 777 /home/odwt/1.0.0/out/oworkflow.dat elif ; then touch... (8 Replies)
Discussion started by: nag_sathi
8 Replies

10. Shell Programming and Scripting

Unknown test operator

O/S solaris 9 shell ksh if then chk_op="WARNING...reboot within the last 24hrs, restarted at `who -r | awk '{print $4$5"@"$6}'`" ; else if ; then last_reboot1=`who -b | awk '{print $4" "$5" "$6}'` last_reboot2='..OK..'`uptime | awk '{print$3" "$4}'` ... (4 Replies)
Discussion started by: squrcles
4 Replies
CREATE 
DATABASE(7) SQL Commands CREATE DATABASE(7) NAME
CREATE DATABASE - create a new database SYNOPSIS
CREATE DATABASE name [ [ WITH ] [ OWNER [=] dbowner ] [ TEMPLATE [=] template ] [ ENCODING [=] encoding ] [ LC_COLLATE [=] lc_collate ] [ LC_CTYPE [=] lc_ctype ] [ TABLESPACE [=] tablespace ] [ CONNECTION LIMIT [=] connlimit ] ] DESCRIPTION
CREATE DATABASE creates a new PostgreSQL database. To create a database, you must be a superuser or have the special CREATEDB privilege. See CREATE USER [create_user(7)]. Normally, the creator becomes the owner of the new database. Superusers can create databases owned by other users, by using the OWNER clause. They can even create databases owned by users with no special privileges. Non-superusers with CREATEDB privilege can only create databases owned by themselves. By default, the new database will be created by cloning the standard system database template1. A different template can be specified by writing TEMPLATE name. In particular, by writing TEMPLATE template0, you can create a virgin database containing only the standard objects predefined by your version of PostgreSQL. This is useful if you wish to avoid copying any installation-local objects that might have been added to template1. PARAMETERS
name The name of a database to create. dbowner The name of the database user who will own the new database, or DEFAULT to use the default (namely, the user executing the command). template The name of the template from which to create the new database, or DEFAULT to use the default template (template1). encoding Character set encoding to use in the new database. Specify a string constant (e.g., 'SQL_ASCII'), or an integer encoding number, or DEFAULT to use the default encoding (namely, the encoding of the template database). The character sets supported by the PostgreSQL server are described in in the documentation. See below for additional restrictions. lc_collate Collation order (LC_COLLATE) to use in the new database. This affects the sort order applied to strings, e.g. in queries with ORDER BY, as well as the order used in indexes on text columns. The default is to use the collation order of the template database. See below for additional restrictions. lc_ctype Character classification (LC_CTYPE) to use in the new database. This affects the categorization of characters, e.g. lower, upper and digit. The default is to use the character classification of the template database. See below for additional restrictions. tablespace The name of the tablespace that will be associated with the new database, or DEFAULT to use the template database's tablespace. This tablespace will be the default tablespace used for objects created in this database. See CREATE TABLESPACE [create_tablespace(7)] for more information. connlimit How many concurrent connections can be made to this database. -1 (the default) means no limit. Optional parameters can be written in any order, not only the order illustrated above. NOTES
CREATE DATABASE cannot be executed inside a transaction block. Errors along the line of ``could not initialize database directory'' are most likely related to insufficient permissions on the data direc- tory, a full disk, or other file system problems. Use DROP DATABASE [drop_database(7)] to remove a database. The program createdb [createdb(1)] is a wrapper program around this command, provided for convenience. Although it is possible to copy a database other than template1 by specifying its name as the template, this is not (yet) intended as a general-purpose ``COPY DATABASE'' facility. The principal limitation is that no other sessions can be connected to the template database while it is being copied. CREATE DATABASE will fail if any other connection exists when it starts; otherwise, new connections to the tem- plate database are locked out until CREATE DATABASE completes. See in the documentation for more information. The character set encoding specified for the new database must be compatible with the chosen locale settings (LC_COLLATE and LC_CTYPE). If the locale is C (or equivalently POSIX), then all encodings are allowed, but for other locale settings there is only one encoding that will work properly. (On Windows, however, UTF-8 encoding can be used with any locale.) CREATE DATABASE will allow superusers to specify SQL_ASCII encoding regardless of the locale settings, but this choice is deprecated and may result in misbehavior of character-string func- tions if data that is not encoding-compatible with the locale is stored in the database. The encoding and locale settings must match those of the template database, except when template0 is used as template. This is because other databases might contain data that does not match the specified encoding, or might contain indexes whose sort ordering is affected by LC_COLLATE and LC_CTYPE. Copying such data would result in a database that is corrupt according to the new settings. template0, however, is known to not contain any data or indexes that would be affected. The CONNECTION LIMIT option is only enforced approximately; if two new sessions start at about the same time when just one connection ``slot'' remains for the database, it is possible that both will fail. Also, the limit is not enforced against superusers. EXAMPLES
To create a new database: CREATE DATABASE lusiadas; To create a database sales owned by user salesapp with a default tablespace of salesspace: CREATE DATABASE sales OWNER salesapp TABLESPACE salesspace; To create a database music which supports the ISO-8859-1 character set: CREATE DATABASE music ENCODING 'LATIN1' TEMPLATE template0; In this example, the TEMPLATE template0 clause would only be required if template1's encoding is not ISO-8859-1. Note that changing encod- ing might require selecting new LC_COLLATE and LC_CTYPE settings as well. COMPATIBILITY
There is no CREATE DATABASE statement in the SQL standard. Databases are equivalent to catalogs, whose creation is implementation-defined. SEE ALSO
ALTER DATABASE [alter_database(7)], DROP DATABASE [drop_database(7)] SQL - Language Statements 2010-05-14 CREATE DATABASE(7)
All times are GMT -4. The time now is 06:08 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy