Sponsored Content
Top Forums Shell Programming and Scripting PERL : SQL array bind issue while grouping Post 302490185 by sinpeak on Monday 24th of January 2011 07:09:42 AM
Old 01-24-2011
PERL : SQL array bind issue while grouping

Hi,

I have an array of strings. Each string has 4 comma separated values. I am binding this array to a SQL where I am required to do an INSERT after grouping.

The binding is done as :

Code:
$insertADWSth->bind_param_array(1,A_CONSTANT_STRING);
$insertADWSth->bind_param_array(2,B_CONSTANT_STRING); 
$insertADWSth->bind_param_array(3,\@lineRecArray);
 
$insertADWSth->execute_array({ArrayTupleStatus=>\my @tuple_status})

..and the SQL is :

Code:
INSERT INTO ABCD
(A,B,C,D,E,F,G)
(SELECT 
LINE_ARR.A, 
LINE_ARR.B, 
REGEXP_SUBSTR( LINE_ARR.LINE_REC,'[^,]+',1,2),
XYZ.D ,
XYZ.E , 
REGEXP_SUBSTR( LINE_ARR.LINE_REC,'[^,]+',1,3),
SUM(TO_NUMBER(REGEXP_SUBSTR( LINE_ARR.LINE_REC,'[^,]+',1,4))) 
FROM 
(SELECT ? A, ? B, ? LINE_REC FROM DUAL) LINE_ARR,
XYZ
WHERE XYZ.X = REGEXP_SUBSTR( LINE_ARR.LINE_REC,'[^,]+',1,1)
GROUP BY 
LINE_ARR.A, 
LINE_ARR.B, 
REGEXP_SUBSTR( LINE_ARR.LINE_REC,'[^,]+',1,2),
XYZ.D ,
XYZ.E , 
REGEXP_SUBSTR( LINE_ARR.LINE_REC,'[^,]+',1,3))

This gets executed successfully. But the issue is all records are inserted without being grouped. If I replace the arrays with a table having the same data then the grouping goes successful.

Does this mean when an array is bound to the SQL, the SQL is executed once for each element of the array ? and thats why it won't group ?

If yes, then is there a way to achieve such a thing ? where we have the data in an array and we need to group and sum it ?

Thanks
Dhritman

Moderator's Comments:
Mod Comment Please use code tags for listings

Last edited by pludi; 01-24-2011 at 08:30 AM..
sinpeak
 

8 More Discussions You Might Find Interesting

1. Solaris

rpc bind issue

Hi all, I am using Solaris 10 OS on X86 platform. Long back i tried to configure DHCP server on my system but because of rpc-bind, total went in vein.Even now i am unable to access even USB also. When i tried to look for "volfs" service it was offline because one of its dependant... (0 Replies)
Discussion started by: vvpotugunta
0 Replies

2. Shell Programming and Scripting

PERL : Bind 2D array to SQL

Hi, I am in the need of doing a bulk insert via : SQL - INSERT INTO <table> (SELECT..) OR PLSQL Block - FORALL i IN 1 .. count INSERT INTO <table>(arrayname(i)) I have a 2D array in my perl code which has the rows to be bulk inserted. Is there a way to bind the 2D array to the SQL... (4 Replies)
Discussion started by: sinpeak
4 Replies

3. Solaris

BIND DNS Server issue on Solaris 10

Hi all, I have some sort of problem with BIND DNS server my environment as follows. bash-3.00# cat /etc/release Solaris 10 6/06 s10s_u2wos_09a SPARC Copyright 2006 Sun Microsystems, Inc. All Rights Reserved. Use is subject to... (3 Replies)
Discussion started by: h@foorsa.biz
3 Replies

4. UNIX and Linux Applications

SQL database call into Multidimensional Array using Perl Script

#!/usr/local/bin/perl use DBI; use File::Copy; use Time::Local; use Data::Dumper; -Comments Describing what I'm doing-------------- -I'm pulling information from a database that has an ID and Name. They are separated by a space and I'm trying to load them into a multidimensional array so as... (3 Replies)
Discussion started by: eazyeddie22
3 Replies

5. Programming

SQL Grouping SUM

Hello people, I'm scratching my head to find a solution to this query. I have a simple SQL table: data | tot ================== 111201/0000 | 3 111201/0001 | 5 111201/0002 | 7 111201/0003 | 2 ..... 111201/0059 | 1 111201/0100 | 5 111201/0101 | 8 111201/0102 | 6... (7 Replies)
Discussion started by: Lord Spectre
7 Replies

6. Shell Programming and Scripting

Pass perl array to SQL oracle

Hello, Could someone please suggest if there is a way to pass an perl array(pass @v_array) to SQL as in below eg : #!/usr/bin/perl @v_array = (1,2,4,5,6,8); $db_userid = 'ni71/ni711'; $bufTPO = qx{ sqlplus -s << EOF $db_userid set verify off set feedback off set... (1 Reply)
Discussion started by: arunshankar.c
1 Replies

7. Shell Programming and Scripting

awk and perl grouping.

Hello folks. After awk, i have decided to start to learn perl, and i need some help. I have following output : 1 a 1 b 2 k 2 f 3 s 3 p Now with awk i get desired output by issuing : awk ' { a = a FS $2 } END { for ( i in a) print i,a }' input 1 a b 2 k f 3 s p Can... (1 Reply)
Discussion started by: Peasant
1 Replies

8. Shell Programming and Scripting

Grouping array elements - possible?

I have a script which takes backup of some configuration files on my server. It does that by using an array which contains the complete path to the files to backup. It copys the files to a pre defined dir. Each "program" has it's own folder, ex. apache.conf is being copied to /predefined... (7 Replies)
Discussion started by: dnn
7 Replies
REVOKE(7)							   SQL Commands 							 REVOKE(7)

NAME
REVOKE - remove access privileges SYNOPSIS
REVOKE { { SELECT | INSERT | UPDATE | DELETE | RULE | REFERENCES | TRIGGER } [,...] | ALL [ PRIVILEGES ] } ON [ TABLE ] tablename [, ...] FROM { username | GROUP groupname | PUBLIC } [, ...] REVOKE { { CREATE | TEMPORARY | TEMP } [,...] | ALL [ PRIVILEGES ] } ON DATABASE dbname [, ...] FROM { username | GROUP groupname | PUBLIC } [, ...] REVOKE { EXECUTE | ALL [ PRIVILEGES ] } ON FUNCTION funcname ([type, ...]) [, ...] FROM { username | GROUP groupname | PUBLIC } [, ...] REVOKE { USAGE | ALL [ PRIVILEGES ] } ON LANGUAGE langname [, ...] FROM { username | GROUP groupname | PUBLIC } [, ...] REVOKE { { CREATE | USAGE } [,...] | ALL [ PRIVILEGES ] } ON SCHEMA schemaname [, ...] FROM { username | GROUP groupname | PUBLIC } [, ...] DESCRIPTION
REVOKE allows the creator of an object to revoke previously granted permissions from one or more users or groups of users. The key word PUBLIC refers to the implicitly defined group of all users. Note that any particular user will have the sum of privileges granted directly to him, privileges granted to any group he is presently a member of, and privileges granted to PUBLIC. Thus, for example, revoking SELECT privilege from PUBLIC does not necessarily mean that all users have lost SELECT privilege on the object: those who have it granted directly or via a group will still have it. See the description of the GRANT [grant(7)] command for the meaning of the privilege types. NOTES
Use psql(1)'s z command to display the privileges granted on existing objects. See also GRANT [grant(7)] for information about the format. EXAMPLES
Revoke insert privilege for the public on table films: REVOKE INSERT ON films FROM PUBLIC; Revoke all privileges from user manuel on view kinds: REVOKE ALL PRIVILEGES ON kinds FROM manuel; COMPATIBILITY
SQL92 The compatibility notes of the GRANT [grant(7)] command apply analogously to REVOKE. The syntax summary is: REVOKE [ GRANT OPTION FOR ] { SELECT | INSERT | UPDATE | DELETE | REFERENCES } ON object [ ( column [, ...] ) ] FROM { PUBLIC | username [, ...] } { RESTRICT | CASCADE } If user1 gives a privilege WITH GRANT OPTION to user2, and user2 gives it to user3 then user1 can revoke this privilege in cascade using the CASCADE keyword. If user1 gives a privilege WITH GRANT OPTION to user2, and user2 gives it to user3, then if user1 tries to revoke this privilege it fails if he specifies the RESTRICT keyword. SEE ALSO
GRANT [grant(7)] SQL - Language Statements 2002-11-22 REVOKE(7)
All times are GMT -4. The time now is 01:28 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy