Sponsored Content
Full Discussion: sql variable as array index
Top Forums UNIX for Advanced & Expert Users sql variable as array index Post 302284987 by fimblo on Friday 6th of February 2009 05:26:36 PM
Old 02-06-2009
This wont work because of scope issues. The array $arr[..] is declared in the shell, so it has to be interpreted by the shell. When you try to send it into sqsh's STDIN it won't be able to expand it since at that time the shell has no idea what value the SQL variable @foo will have.

One way of solving this (very ugly, but I have seen it in the wild) is to write some SQL code which generates some ksh code which (yes I said it was gawdugly) creates SQL code.

Don't do this. It might work but someone is going to have to maintain it. Prolly you.

Instead ask yourself why you are using an array in ksh in the first place. Could you use a file? A table in the DB? Is the data available from the inside of a SQL session?
 

10 More Discussions You Might Find Interesting

1. Filesystems, Disks and Memory

why the inode index of file system starts from 1 unlike array index(0)

why do inode indices starts from 1 unlike array indexes which starts from 0 its a question from "the design of unix operating system" of maurice j bach id be glad if i get to know the answer quickly :) (0 Replies)
Discussion started by: sairamdevotee
0 Replies

2. UNIX for Dummies Questions & Answers

wh inode index starts from 1 unlike array index (0)

brothers why inode index starts from 1 unlike array inex which starts from 0 its a question from the design of unix operating system of maurice j.bach i need to know the answer urgently...someone help please (1 Reply)
Discussion started by: sairamdevotee
1 Replies

3. Shell Programming and Scripting

Problem when assign the array with the string index

I come across the problems when assigning the array in the script below . How to use the array with the 'string index' correctly ? When I assign a new string index , the array elements that are previously assigned are all changed .:eek::eek::eek: $ array=211 $ echo ${array} 211 $... (4 Replies)
Discussion started by: youareapkman
4 Replies

4. Shell Programming and Scripting

awk array index help

$ cat file.txt A|X|20 A|Y|20 A|X|30 A|Z|20 B|X|10 A|Y|40 Summing up $NF based on first 2 fields, $ awk -F "|" 'BEGIN {OFS="|"} { sum += $NF } END { for (f in sum) print f,sum } ' file.txt o/p: A|X|50 A|Y|60 A|Z|20 (4 Replies)
Discussion started by: uwork72
4 Replies

5. Shell Programming and Scripting

dynamic index for array in while loop

Hi, I'm just trying to use a dynamic index for some array elements that I'm accessing within a loop. Specifically, I want to access an array at variable position $counter and then also at location $counter + 1 and $counter + 2 (the second and third array positions after it) but I keep getting... (0 Replies)
Discussion started by: weak_code-fu
0 Replies

6. Shell Programming and Scripting

how to search array and print index in ksh

Hi, I am using KSH shell to do some programming. I want to search array and print index value of the array. Example.. nodeval4workflow="DESCRIPTION ="" ISENABLED ="YES" ISVALID ="YES" NAME="TESTVALIDATION" set -A strwfVar $nodeval4workflow strwfVar=DESCRIPTION=""... (1 Reply)
Discussion started by: tmalik79
1 Replies

7. Shell Programming and Scripting

error while updating rows in sql with values in array variable

Hi, I need to update rows in a table based on the values in an array variable. code is : while read line do error_msg="$(echo $line)" index=`expr $index+1` done <"logs/$ffile" rows_count=${#error_msg } i=0 while do echo "error msgs is... (2 Replies)
Discussion started by: RP09
2 Replies

8. Shell Programming and Scripting

build array name based on loop index

Hi, I am new to perl and I have the following query please help here. I have following array variables declaration @pld1 = qw(00 01 02 03 04 05); @pld2 = qw(10 11 12 13 14 15); for(my $k=1;$k<=2;$k++) { //I want here to use @pld1 if $k is 1 // and @pld2 if $k is 2. How to do... (3 Replies)
Discussion started by: janavan
3 Replies

9. Shell Programming and Scripting

Associative array index question

I am trying to assign indexes to an associative array in a for loop but I have to use an eval command to make it work, this doesn't seem correct I don't have to do this with regular arrays For example, the following assignment fails without the eval command: #! /bin/bash read -d "\0" -a... (19 Replies)
Discussion started by: Riker1204
19 Replies

10. Shell Programming and Scripting

Copy of array by index value fails

Hello, I have a complicated situational find and replace that I wrote in bash because I didn't know how to do everything in awk. The code works but is very slow, as expected. To create my modified file, I am looping through an array that was populated earlier and making some replacements at... (6 Replies)
Discussion started by: LMHmedchem
6 Replies
SQL::Translator::Schema::Trigger(3pm)			User Contributed Perl Documentation		     SQL::Translator::Schema::Trigger(3pm)

NAME
SQL::Translator::Schema::Trigger - SQL::Translator trigger object SYNOPSIS
use SQL::Translator::Schema::Trigger; my $trigger = SQL::Translator::Schema::Trigger->new( name => 'foo', perform_action_when => 'before', # or after database_events => [qw/update insert/], # also update, update_on, delete fields => [], # if event is "update" on_table => 'foo', # table name action => '...', # text of trigger schema => $schema, # Schema object scope => 'row', # or statement ); DESCRIPTION
"SQL::Translator::Schema::Trigger" is the trigger object. METHODS
new Object constructor. my $schema = SQL::Translator::Schema::Trigger->new; perform_action_when Gets or sets whether the event happens "before" or "after" the "database_event". $trigger->perform_action_when('after'); database_event Obsolete please use database_events! database_events Gets or sets the events that triggers the trigger. my $ok = $trigger->database_events('insert'); fields Gets and set which fields to monitor for "database_event". $view->fields('id'); $view->fields('id', 'name'); $view->fields( 'id, name' ); $view->fields( [ 'id', 'name' ] ); $view->fields( qw[ id name ] ); my @fields = $view->fields; table Gets or set the table on which the trigger works, as a SQL::Translator::Schema::Table object. $trigger->table($triggered_table); on_table Gets or set the table name on which the trigger works, as a string. $trigger->on_table('foo'); action Gets or set the action of the trigger. $trigger->action( q[ BEGIN select ...; update ...; END ] ); is_valid Determine whether the trigger is valid or not. my $ok = $trigger->is_valid; name Get or set the trigger's name. my $name = $trigger->name('foo'); order Get or set the trigger's order. my $order = $trigger->order(3); scope Get or set the trigger's scope (row or statement). my $scope = $trigger->scope('statement'); schema Get or set the trigger's schema object. $trigger->schema( $schema ); my $schema = $trigger->schema; compare_arrays Compare two arrays. equals Determines if this trigger is the same as another my $is_identical = $trigger1->equals( $trigger2 ); AUTHORS
Anonymous, Ken Youens-Clark <kclark@cpan.org>. perl v5.14.2 2012-01-18 SQL::Translator::Schema::Trigger(3pm)
All times are GMT -4. The time now is 01:42 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy