Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8850375
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:53:17+00:00 2026-06-14T12:53:17+00:00

i want to pass a ksh shell variable as an integer to sqlplus or

  • 0

i want to pass a ksh shell variable as an integer to sqlplus or convert the variable to number before using it .This is the code i have written (not working):

echo
echo "Enter the day of run (1,2,3,..,N ) :" | tee -a $sqllog
read day

typeset -i first_range

if [ $day -eq 1 ]; then
first_range=5000
elif [[ $day -eq 2 ]]; then
first_range=105000
elif [[ $day -eq 3 ]]; then
first_range=205000
elif [[ $day -eq 4 ]]; then
first_range=305000
elif [[ $day -eq 5 ]]; then
first_range=405000
elif [[ $day -eq 6 ]]; then
first_range=505000
elif [[ $day -eq 7 ]]; then
first_range=605000
fi

echo "first_range value : ${first_range}" | tee -a $sqllog
{
sqlplus -S ${SF_PSTN_CONN_STRING} << EOF

alter session enable parallel DML;
--alter session set  db_file_multiblock_read_count=128;
alter session enable parallel query;

set heading off
set verify off
set echo off
set pages 0
set timi on
set lines 300
set trimspool on

# Drop table TMP_DAILY_PSTN_CMP_11035

drop table TMP_DAILY_PSTN_CMP_11035;


# Create TMP Table TMP_DAILY_PSTN_CMP_11035 from TMP_OA_PSTN_CMP_11035

Create table TMP_DAILY_PSTN_CMP_11035 (
        ACTION_OBJID NUMBER,
        CONTRACT_OBJID NUMBER,
        STATUS varchar2(40),
        UPDATE_DATE DATE
)
partition by range(ACTION_OBJID)(
partition p1 values less than (${first_range})) NOLOGGING parallel;

prompt the day of run is $day;

begin
        for k in 2..200
        loop
                execute immediate
                        'alter table TMP_DAILY_PSTN_CMP_11035 add partition p'||k||' values less than ('||${first_range}+(k*5000)||')';
        end loop;
end;
/

The error i am getting for it is:

Enter the day of run (1,2,3,..,N ) :
2
first_range value : 105000

Session altered.


Session altered.


Table dropped.

Elapsed: 00:00:00.03

Table created.

Elapsed: 00:00:00.02
the day of run is 2
begin
*
ERROR at line 1:
ORA-06502: PL/SQL: numeric or value error: character to number conversion error
ORA-06512: at line 4

how do i solve this problem,ie to convert the char to number,even typeset -i does not seem to be working.passing a variable to sqlplus is easy and many question refer to it but i specifically want to pass an integer value and use it

EDIT:
i am using oracle 10g db.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T12:53:18+00:00Added an answer on June 14, 2026 at 12:53 pm

    problem solved by using this code to convert the char to integer in sql:

    VARIABLE ret_val NUMBER
    :ret_val := 1;
    PRINT ret_val
    begin
                                    for k in 2..200
                                    loop
                                       SELECT (select to_number(${first_range}) from dual)+5000*(k-1) INTO :ret_val FROM dual;
                    execute immediate
                            'alter table TMP_DAILY_PSTN_CMP_11035 add partition p'||k||' values less than ('||:ret_val||')';
            end loop;
    end;
    /
    

    Do tell if you find better alternatives.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to pass a command to a shell script. This command is a
want to pass a simple integer to function after finding it. Code is as
By using javascript confim i have done suspending. Now i want to turn this
My data is just number, I want pass it from VC1 to VC2 for
I want to pass data from second tab to first tab using delegates.But delegate
I have a loop in my KornShell (ksh) script that I want to execute
I want pass a parameter of javascript functiona which is a string. This javascript
I want pass a number from my ViewController to the the TweetViewController. Everything worked
I want pass a value to ssis package, but i have an error back
i want to pass this paramater topic to another page, p.s. the page is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.