Sponsored Content
Top Forums Shell Programming and Scripting Shell script with sql script error Post 303003530 by srilinux09 on Friday 15th of September 2017 10:11:20 AM
Old 09-15-2017
Shell script with sql script error

Hi All

when I execute from psql prompt, I get the result, when I try to automate
using a shell script, the query is not working

HTML Code:
# `/usr/bin/psql -U postgres  -d coba1 -c  "select name from users where 
"Date" > current_date - 30;"`
ERROR: column "Date" does not exist
LINE 1: select name from users where Date >current_...


========

works below

^
HTML Code:
 sudo -u postgres psql
psql (9.4.5)
Type "help" for help.

HTML Code:
postgres=# \connect coba1
You are now connected to database "coba1" as user "postgres".
HTML Code:
coba1=# select name from users where "Date" >current_date - 30; 
        name 
--------------------- 
 coba11 
 testCoba11
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

passing parameter from Shell-script to Sql-script

Dear Friends, Please help me to achieve the following: I want to pass one parameter from Shell-script to Sql-script. Example: My ShellScript.sh is calling report.sql like this: /bin/sqlplus /reports.sql And My report.sql is calling many Stored-Procedures like this: exec... (0 Replies)
Discussion started by: subodhbansal
0 Replies

2. Shell Programming and Scripting

Calling SQL LDR and SQL plus scripts in a shell script

Hi- I am trying to achieve the following in a script so I can schedule it on a cron job. I am fairly new to the unix environment... I have written a shell script that reads a flat file and loads the data into an Oracle table (Table1) via SQLLDR. This Works fine. Then, I run a nested insert... (5 Replies)
Discussion started by: rajagavini
5 Replies

3. Shell Programming and Scripting

error connecting sql through a shell script

Hi I am getting this error while connecting to sql through a shell script, whereas i am able to connect to sql directly. It was working properly earlier, no clue why i am getting this. Please find the log below: FTP to <IP> completed Wed Apr 30 11:42:01 BST 2008 Program ended. Wed Apr 30... (1 Reply)
Discussion started by: nehak
1 Replies

4. Shell Programming and Scripting

Shell script which runs sql script

Hi all, I need a shell script which runs a sql script but I couldn't find how to finish it. This is the code that I have: #! /usr/bin/ksh export SHELL=/bin/ksh export ORACLE_SID=database export ORACLE_HOME=/opt/oracle/product/9.2.0.8 sqlplus user <<EOF @/path/path/path/scriptname.sql... (3 Replies)
Discussion started by: Geller
3 Replies

5. Shell Programming and Scripting

(Urgent):Creating flat file using sql script and sqlplus from UNIX Shell Script

Hi, I need help urgently for following issue. Pls help me to resolve this issue. I am calling sql script file(file1.sql) from UNIX Shell Script(script1.ksh) using sql plus and trying to create flat file that contains all records returned from SQL query in SQL script(file1.sql) I given... (6 Replies)
Discussion started by: praka
6 Replies

6. Shell Programming and Scripting

How to grep sql error in shell script and exit the script?

I need help in the following script. I want to grep the sql errors insert into the error table and exit the shell script if there is any error, otherwise keep running the scripts. Here is my script #!/bin/csh -f source .orapass set user = $USER set pass = $PASS cd /opt/data/scripts echo... (2 Replies)
Discussion started by: allinshell99
2 Replies

7. Shell Programming and Scripting

LIKE in SQL shell script

sqlplus -s <<__END__ ${USER}/${PASS}@${DB} WHENEVER SQLERROR EXIT SQL.SQLCODE ROLLBACK WHENEVER OSERROR EXIT FAILURE ROLLBACK SET ECHO ON SET TIMING ON SET SERVEROUTPUT ON SIZE 1000000 select count(*) from table where start LIKE '10-JUN-10'; EXIT __END__ result=$? echo $resultThis gives... (9 Replies)
Discussion started by: sandy1028
9 Replies

8. Shell Programming and Scripting

pass null value to sql script from korn shell script

There are 4 parameters that I have to pass from korn shell to sql script. 1) I have to check if $1 , $2 , $3 and $4 are null values or not . How can I do that ? 2) Once its determined that these values are null (in the sense they are empty) how can I pass null values to sql script... (11 Replies)
Discussion started by: megha2525
11 Replies

9. Shell Programming and Scripting

How to pass Oracle sql script as argument to UNIX shell script?

Hi all, $ echo $SHELL /bin/bash Requirement - How to pass oracle sql script as argument to unix shell script? $ ./output.sh users.sql Below are the shell scripts and the oracle sql file in the same folder. Shell Script $ cat output.sh #!/bin/bash .... (7 Replies)
Discussion started by: a1_win
7 Replies

10. Shell Programming and Scripting

Call sql script from UNIX shell script

I know this question is out there in many forums, but I tried all the combinations in vain. I'm basically trying to call a sql script from a shell script. Below is my sql script (plsql.sql) DELCARE v_empno NUMBER := '&empno'; BEGIN select ename,sal from emp where empno = v_empno;... (3 Replies)
Discussion started by: FName_LName
3 Replies
OCF_HEARTBEAT_PGSQL(7)						OCF resource agents					    OCF_HEARTBEAT_PGSQL(7)

NAME
ocf_heartbeat_pgsql - Manages a PostgreSQL database instance SYNOPSIS
pgsql [start | stop | status | monitor | meta-data | validate-all | methods] DESCRIPTION
Resource script for PostgreSQL. It manages a PostgreSQL as an HA resource. SUPPORTED PARAMETERS
pgctl Path to pg_ctl command. (optional, string, default /usr/bin/pg_ctl) start_opt Start options (-o start_opt in pg_ctl). "-i -p 5432" for example. (optional, string, no default) ctl_opt Additional pg_ctl options (-w, -W etc..). (optional, string, no default) psql Path to psql command. (optional, string, default /usr/bin/psql) pgdata Path to PostgreSQL data directory. (optional, string, default /var/lib/pgsql/data) pgdba User that owns PostgreSQL. (optional, string, default postgres) pghost Hostname/IP address where PostgreSQL is listening (optional, string, no default) pgport Port where PostgreSQL is listening (optional, integer, default 5432) config Path to the PostgreSQL configuration file for the instance (optional, integer, no default) start_opt Additional options passed to the PostgreSQL server daemon. (optional, string, no default) pgdb Database that will be used for monitoring. (optional, string, default template1) logfile Path to PostgreSQL server log output file. (optional, string, default /dev/null) stop_escalate Number of shutdown retries (using -m fast) before resorting to -m immediate (optional, integer, no default) SUPPORTED ACTIONS
This resource agent supports the following actions (operations): start Starts the resource. Suggested minimum timeout: 120. stop Stops the resource. Suggested minimum timeout: 120. status Performs a status check. Suggested minimum timeout: 60. monitor Performs a detailed status check. Suggested minimum timeout: 30. Suggested interval: 30. meta-data Retrieves resource agent metadata (internal use only). Suggested minimum timeout: 5. validate-all Performs a validation of the resource configuration. Suggested minimum timeout: 5. methods Suggested minimum timeout: 5. EXAMPLE
The following is an example configuration for a pgsql resource using the crm(8) shell: primitive example_pgsql ocf:heartbeat:pgsql op monitor depth="0" timeout="30" interval="30" SEE ALSO
http://www.linux-ha.org/wiki/pgsql_(resource_agent) AUTHOR
Linux-HA contributors (see the resource agent source for information about individual authors) resource-agents 1.0.3 07/05/2010 OCF_HEARTBEAT_PGSQL(7)
All times are GMT -4. The time now is 05:25 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy