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

  • Home
  • SEARCH
  • 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 6779889
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:26:29+00:00 2026-05-26T16:26:29+00:00

I have query building plsql code. I use bind variables and associative array to

  • 0

I have query building plsql code. I use bind variables and associative array to store their values. Something like that:

declare
    type myt table of varchar2(4000) index by varchar2(100);
    vars myt;
    v_cursor integer;
    newQuery varchar2(1000) := 'select * from blabla where ';
    bind_key varchar2(100);
    rows_count integer;
begin
    -- query building
    if 1=1 then
        newQuery := newQuery || 'col1 = :bind_col1';
        vars(':bind_col1') := sysdate; -- problem!!!
    end if;
    ....
    -- query execution
    v_cursor := dbms_sql.open_cursor;
    dbms_sql.parse(v_cursor, newQuery, dbms_sql.v7);
    bind_key := vars.first;
    loop
        exit when bind_key is null;
        dbms_sql.bind_variable(v_cursor, bind_key, vars(bind_key));
        bind_key := vars.next(bind_key);
    end loop;
    row_count := dbms_sql.execute(v_cursor);
    dbms_sql.close_cursor(v_cursor);
end;

Are there any more generic type than varchar2, so there will not be conversion date->varchar2->date?

  • 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-05-26T16:26:29+00:00Added an answer on May 26, 2026 at 4:26 pm

    dbms_sql.bind_variable can bind variables of many datatypes. You can’t however declare a table of <any_data_type> (which would be logically equivalent to something like Object[] in java for example.)

    When you’re working with VARCHAR2 you can use bijective explicit conversion, for example:

    newQuery := newQuery || 'col1 = to_date(:bind_col1, ''yyyymmdd hh24:mi:ss'')';
    vars(':bind_col1') := to_char(sysdate, 'yyyymmdd hh24:mi:ss');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this query: criteria = session.CreateCriteria(typeof (Building)) .CreateAlias(Estate, estate) .SetProjection(Projections.ProjectionList() .Add(Property.ForName(Name), BuildingName) .Add(Property.ForName(estate.Name),
I've noticed that a few Wordpress blogs have query statistics present in their footer
I have a query that originally looks like this: select c.Id, c.Name, c.CountryCode, c.CustomerNumber,
I have a query that looks like this: public IList<Post> FetchLatestOrders(int pageIndex, int recordCount)
I have a stored procedure that is dynamically building a query. The where clause
I need some help building an Query. I have a table Orders with 3
I want to use a datastructure like this: building string (indexed) date TDate (indexed)
I need help with building SQL query. I have 4 tables: Sellers, Goods, Projects
I have some JSON that looks like: groups: [ group_id: 8, group_name: Building, group_color:
Can/Should I use a LIKE criteria as part of an INNER JOIN when building

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.